CLI-Reference DB overlay: lossless ETL, inspect crosswalks, export (#124)#126
Conversation
Maintainer decision (2026-07-20): store only the entry-level crosswalk (it carries the non-derivable exact/alias resolution); derive field↔inspect links via CREATE VIEW so the version-less overlay never pins to a versioned schema_nodes snapshot. Also records the entry-link ambiguity policy (ambiguous alias → manual-only + loud validation) and confirms toc_group = URL-parent. Full schema accepted; #124 cleared to implement in one unit. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Schema layer for the CLI-Reference overlay: - SCHEMA_VERSION 10→11 - schema_nodes.inspect_type preserves the raw path|dir|cmd|arg class that `type` normalizes (path→dir); populated by extract-schema.ts, additive ALTER for existing DBs. Roundtrip test proves the path→dir divergence. - cliref_pages/entries/fields/flags source tables (occurrence-based identity, raw Markdown + sha256 retention, no path on fields) - cliref_entry_schema_links stored crosswalk (entry_id PK = ≤1 link invariant) - cliref_field_inspect_links VIEW (field→arg derived, never stored) Extractor/linking/export follow in subsequent commits. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Populates cliref_pages/entries/fields/flags from manual.mikrotik.com/docs/ cli-reference/*. Reuses sitemap discovery; offline --from-cache lists cached files. Retains exact page Markdown + sha256, verbatim entry/field/flag descriptions (no whitespace flattening — 103 multiline field descriptions preserved), occurrence order + line spans, document heading ancestry (source_parent_id). Fails loud on unknown Type/ArgTable labels; asserts parsed entries == **Type:** markers and fields+flags == <ArgTableRow> count. Excludes the section-landing index.md (argument-type glossary, prose-only, no Type markers) — a separate future task. Verified: 228 pages / 1051 entries / 10118 fields / 948 flags, integrity ok, FK clean, sha256 round-trips. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
link-cliref.ts resolves each cliref entry to a schema_nodes dir/cmd node: exact, else single INTERNAL-segment-drop alias (unambiguous only; never the root or leaf segment — dropping the leaf would false-alias a genuinely-absent submenu onto its parent), else manual-only. Reproduces the experiment exactly: 907 exact, 24 alias (19 distinct spurious segments), 120 manual-only. Rewrote cliref_field_inspect_links as a UNION of the cmd/dir cases (the OR form forced a full arg-by-type scan). With a new (parent_path, name) index the whole view materializes in ~200ms (was >14s). certificate.name → 7, verified. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Extends the DB-only exporter with six cli-reference/*.tsv datasets (pages/entries/fields/flags/entry-inspect-links/field-inspect-links) plus byte-exact source/<slug>.md files reconstructed from cliref_pages.source_markdown. - fields.tsv labels the entry column entry_source_path — never invents a field_path; the zero-to-many coordinates live in field-inspect-links.tsv (from the view). Read-only name-collision caveat disclosed in the manifest. - Emitted only when the overlay is populated (row-presence guard), so an empty schema exports nothing new. Raw md files are manifest-owned and pruned like the existing variable-file sets. Verified against a full build: 228/1051/10118/948 rows, entry-links 931 (907 exact + 24 alias), field-links 13144, 228 source md all sha256-exact, every TSV round-trips through parseTsv. Base export tests still green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- fixtures/cli-reference/sample.md exercises all three entry kinds, Flag/ Argument/Read-only tables, a multiline field description, gate markers, a nested (parent) heading, and a #-prefixed line inside a code fence. - extract-cliref.test.ts: parse structure, ancestry, flags-vs-fields, no whitespace flattening, fenced false-heading guard, fail-loud on bad labels. - link-cliref.test.ts: exact / internal-only alias / never-first-or-last / ambiguous→manual-only, plus the shipped field view (dir fan-out + cmd direct). - export.test.ts: appended a cliref block (runs last, unique paths) asserting the six TSVs, entry_source_path not field_path, view derivation, and byte-exact source md → manifest sha256. Full `bun test`: 1028 pass, 0 fail. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…N/MANUAL/DESIGN) - Makefile: extract-cliref / extract-cliref-from-cache / link-cliref targets, added to extract + extract-full (link-cliref after schema_nodes is populated). - CHANGELOG: cliref_* overlay + schema_nodes.inspect_type under [Unreleased]; schema 10→11. - VALIDATION.md: V-cliref-parse-reconcile / -source-roundtrip / -inspect-type (blocking, test-backed) + honest GAP rows for full-DB integrity and link drift. - MANUAL.md: CLI Reference data source + the cli-reference/* export datasets. - DESIGN.md: "CLI Reference overlay: source vs inspect identity" — entries have paths / fields don't, store-entry-link vs compute-field-link, occurrence identity, auditable aliasing, inspect_type. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughChangesThe PR adds a lossless CLI-Reference overlay, preserves raw inspect node classes, links entries to schema nodes, extends extraction and export pipelines, and adds parser, linking, schema, and export validation. CLI-Reference overlay
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Build as Makefile
participant Extractor as extract-cliref
participant Database as SQLite
participant Linker as link-cliref
participant Exporter as export
Build->>Extractor: fetch or read cached Markdown
Extractor->>Database: store pages, entries, fields, and flags
Linker->>Database: resolve and store entry schema links
Exporter->>Database: read overlay datasets and field-inspect view
Exporter->>Build: publish TSV and source Markdown
Possibly related issues
Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Implements the CLI-Reference DB overlay (issue #124) as a DB/ETL/export-only addition: new cliref_* source-faithful tables, a stored entry→inspect crosswalk, a computed field→inspect view, export artifacts, and associated tests/docs. This extends Rosetta’s SQLite corpus without changing MCP/TUI/query behavior (those remain scoped to #25).
Changes:
- Adds schema v11:
cliref_pages/cliref_entries/cliref_fields/cliref_flags, storedcliref_entry_schema_links, computedcliref_field_inspect_linksview, and newschema_nodes.inspect_type. - Adds new extract/link pipelines (
src/extract-cliref.ts,src/link-cliref.ts) plus fixtures/tests proving source fidelity, link policy, andinspect_typeroundtrip behavior. - Extends
rosetta exportto emitcli-reference/*.tsvplus byte-exactcli-reference/source/<slug>.md, and updates docs/validation/changelog accordingly.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| VALIDATION.md | Adds V-* rows for CLI-Reference parse reconciliation, source roundtrip/export contract, and inspect_type preservation; records known gaps. |
| src/schema-roundtrip.test.ts | Updates test schema and adds coverage for inspect_type vs normalized type behavior. |
| src/paths.ts | Bumps SCHEMA_VERSION to 11 and documents the v11 schema intent. |
| src/link-cliref.ts | Adds entry-level linker that populates cliref_entry_schema_links using exact/alias/manual-only rules. |
| src/link-cliref.test.ts | Tests alias policy and validates the field-link view behavior against a minimal schema tree. |
| src/extract-schema.ts | Plumbs raw inspect node class into inspectType and stores it as schema_nodes.inspect_type. |
| src/extract-cliref.ts | Adds CLI-Reference extractor that caches/fetches Markdown, parses entries/fields/flags losslessly, and stores into cliref_* tables. |
| src/extract-cliref.test.ts | Adds fixture-driven tests for slug filtering, parsing correctness, fence-guard behavior, and fail-loud parsing. |
| src/export.ts | Adds conditional CLI-Reference export datasets and raw source page emission + disclosures. |
| src/export.test.ts | Adds export test ensuring six TSVs + source md are emitted and contract details (e.g., entry_source_path not field_path). |
| src/db.ts | Adds schema v11 tables/view and indexes; adds inspect_type column migration logic and view indexes. |
| project-words.txt | Adds new tokens used in tests/fixtures (e.g., vcmd, ztname). |
| MANUAL.md | Documents CLI-Reference overlay tables, link pass, and export outputs. |
| Makefile | Adds extract-cliref/link-cliref targets and wires them into extract / extract-full. |
| fixtures/cli-reference/sample.md | Adds a representative CLI-Reference MD fixture to validate parsing and preservation behavior. |
| DESIGN.md | Documents the CLI-Reference identity model, stored vs computed crosswalk, aliasing policy, and inspect_type rationale. |
| CHANGELOG.md | Adds [Unreleased] entries describing the overlay and schema version bump. |
| briefings/B-0016-cli-reference-overlay-design.md | Updates design briefing to reflect accepted schema (stored entry link + computed field view). |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Makefile`:
- Around line 136-138: The extract target must run the schema_nodes-producing
step before link-cliref. Update the extract dependency list to include
extract-all-versions, or otherwise place link-cliref after the schema import
dependency, while preserving the existing extract-full behavior and target
ordering.
In `@src/extract-cliref.ts`:
- Around line 319-339: Guard both field-marker matching and `<ArgTable>` block
detection with `!inFence`, so fenced transcript content remains prose. Update
the checks around the field regex and `<ArgTable ` branch, while preserving
their existing parsing behavior outside fenced sections.
- Around line 92-110: Update loadTocNames so FROM_CACHE never enters the
network-fetch branch when the cached _llms.txt file is absent; return the
appropriate empty/no-data result instead, matching fetchPage’s existing
FROM_CACHE behavior while preserving normal fetching when caching is not
requested.
In `@src/link-cliref.test.ts`:
- Around line 59-98: Update the test’s seed setup to initialize the in-memory
database through the project’s real initDb/schema-setup path instead of manually
creating cliref_field_inspect_links and duplicating its SQL. Retain only the
minimal seed data required for the assertions, including any FK-adjacent tables,
and ensure the test continues exercising the shipped view definition.
In `@src/link-cliref.ts`:
- Around line 52-55: Update pickNode to return no candidate when nodes does not
contain a node matching preferredType(sourceType), rather than falling back to
nodes[0]. Adjust resolveEntry to treat that null result like no candidate at the
path: continue alias search or remain manual-only for the exact branch,
preventing links to nodes whose type conflicts with the entry source type.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: a5fe72fe-93d1-4561-a678-a3b15d8b9e1c
⛔ Files ignored due to path filters (1)
fixtures/cli-reference/sample.mdis excluded by!fixtures/**
📒 Files selected for processing (17)
CHANGELOG.mdDESIGN.mdMANUAL.mdMakefileVALIDATION.mdbriefings/B-0016-cli-reference-overlay-design.mdproject-words.txtsrc/db.tssrc/export.test.tssrc/export.tssrc/extract-cliref.test.tssrc/extract-cliref.tssrc/extract-schema.tssrc/link-cliref.test.tssrc/link-cliref.tssrc/paths.tssrc/schema-roundtrip.test.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
- GitHub Check: copilot-pull-request-reviewer
- GitHub Check: Analyze (javascript-typescript)
🧰 Additional context used
📓 Path-based instructions (12)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use Bun and TypeScript, including Bun-native runtime APIs such as
bun:sqlite,Bun.serve, andbunx.Rosetta uses Bun and TypeScript; prefer
bun,bun test, andmake verifywhere applicable, rather than Node/npm-oriented substitutes.
Files:
src/link-cliref.test.tssrc/paths.tssrc/extract-cliref.test.tssrc/export.test.tssrc/link-cliref.tssrc/extract-schema.tssrc/db.tssrc/schema-roundtrip.test.tssrc/extract-cliref.tssrc/export.ts
src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Rosetta is read-only documentation/schema context and must not connect to or modify a user's router.
Files:
src/link-cliref.test.tssrc/paths.tssrc/extract-cliref.test.tssrc/export.test.tssrc/link-cliref.tssrc/extract-schema.tssrc/db.tssrc/schema-roundtrip.test.tssrc/extract-cliref.tssrc/export.ts
**/*.{ts,tsx,md}
📄 CodeRabbit inference engine (AGENTS.md)
Keep the attribution boundary visible when community RouterOS skills surface, because they are supplemental rather than official MikroTik documentation.
Files:
src/link-cliref.test.tssrc/paths.tsVALIDATION.mdsrc/extract-cliref.test.tssrc/export.test.tsCHANGELOG.mdDESIGN.mdMANUAL.mdsrc/link-cliref.tssrc/extract-schema.tssrc/db.tsbriefings/B-0016-cli-reference-overlay-design.mdsrc/schema-roundtrip.test.tssrc/extract-cliref.tssrc/export.ts
*
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Keep this Copilot instructions file short; put substantive rules in narrow instruction files under
.github/instructions/*.instructions.md.
Files:
project-words.txtVALIDATION.mdCHANGELOG.mdDESIGN.mdMANUAL.mdMakefile
**/*.md
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.md: Keep each project documentation file limited to its canonical role; prefer the documented canonical home instead of creating a new top-level Markdown file.
Do not duplicate content from this routing index; move operational detail, schema blocks, or long rule lists to their canonical documentation or instruction files.
Apply the repository's Markdown linting and fenced-code conventions, while excluding LLM instruction files where the repository explicitly requires that exclusion.
Files:
VALIDATION.mdCHANGELOG.mdDESIGN.mdMANUAL.mdbriefings/B-0016-cli-reference-overlay-design.md
VALIDATION.md
📄 CodeRabbit inference engine (CLAUDE.md)
Document load-bearing invariants and how CI proves them in
VALIDATION.md.
Files:
VALIDATION.md
CHANGELOG.md
📄 CodeRabbit inference engine (CLAUDE.md)
Record user-visible shipped changes in
CHANGELOG.mdunder[Unreleased]or release sections.
Files:
CHANGELOG.md
DESIGN.md
📄 CodeRabbit inference engine (CLAUDE.md)
Store durable project rationale, data-source provenance, and architecture tradeoffs in
DESIGN.md.Read
DESIGN.mdwhen changing retrieval, MCP/TUI behavior, data sources, extraction, skills, command validation, or Docusaurus migration work.
Files:
DESIGN.md
MANUAL.md
📄 CodeRabbit inference engine (CLAUDE.md)
Store installation, operations, release or re-extraction procedures, and schema reference material in
MANUAL.md.
Files:
MANUAL.md
{README.md,MANUAL.md,src/setup.ts}
📄 CodeRabbit inference engine (AGENTS.md)
Keep public client setup snippets aligned across
README.md,src/setup.ts, andMANUAL.md, includingcodex mcp add rosetta -- bunx@tikoci/rosetta``.
Files:
MANUAL.md
src/db.ts
📄 CodeRabbit inference engine (CLAUDE.md)
When touching
src/db.ts, follow both the Bun/runtime conventions and the database-specific instructions.
Files:
src/db.ts
briefings/B-*.md
📄 CodeRabbit inference engine (CLAUDE.md)
Store grounded research and decision support in
briefings/B-*.md.
Files:
briefings/B-0016-cli-reference-overlay-design.md
🪛 ast-grep (0.44.1)
src/extract-cliref.ts
[warning] 224-224: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp(\\b${n}="([\\s\\S]*?)")
Note: [CWE-1333] Inefficient Regular Expression Complexity
(regexp-from-variable)
🪛 GitHub Check: CodeQL
src/extract-cliref.ts
[failure] 120-120: Potential file system race condition
The file may have changed since it was checked.
[warning] 102-102: Network data written to file
Write to file system depends on Untrusted data.
[warning] 120-120: Network data written to file
Write to file system depends on Untrusted data.
🪛 LanguageTool
DESIGN.md
[style] ~213-~213: To elevate your writing, try using more formal phrasing here.
Context: ...h/dir/cmd/argclass whiletype` keeps normalizing, so the crosswalk can reason about the ...
(CONTINUE_TO_VB)
🔇 Additional comments (16)
src/export.ts (1)
448-603: LGTM!Also applies to: 733-749, 789-790, 819-823, 837-837, 850-854
src/export.test.ts (1)
552-600: LGTM!src/db.ts (1)
465-502: LGTM!Also applies to: 512-621
src/extract-schema.ts (1)
53-54: LGTM!Also applies to: 105-105, 378-382, 396-396
src/paths.ts (1)
135-141: LGTM!src/schema-roundtrip.test.ts (1)
34-53: LGTM!Also applies to: 195-207, 284-292
CHANGELOG.md (1)
25-33: LGTM!project-words.txt (1)
135-135: LGTM!Also applies to: 444-444, 480-481
DESIGN.md (1)
201-216: 📐 Maintainability & Code Quality | ⚡ Quick winFigure mismatch: "4,161" vs the briefing's own table ("4,164").
Line 205 states 4,161 of 6,171 settable fields match 2–4 inspect nodes.
briefings/B-0016-cli-reference-overlay-design.md's pre-existing table for the same metric says 4,164 (and the sum 1,177+822+4,164+8=6,171 checks out against that table). Pick one number and reconcile the other; see the consolidated comment for the paired site.briefings/B-0016-cli-reference-overlay-design.md (2)
201-203: LGTM!Also applies to: 272-273, 302-307, 351-372
225-254: 📐 Maintainability & Code Quality | ⚡ Quick winNumeric discrepancy carried into DESIGN.md — see consolidated comment.
Line 245-246 says 4,161 of 6,171 settable fields match 2–4 inspect nodes; the file's own unchanged table (~line 176) puts that same bucket at 4,164.
DESIGN.mdline 205 then repeats the "4,161" figure. Reconcile the source-of-truth number.src/extract-cliref.ts (1)
1-91: LGTM!Also applies to: 112-317, 340-508
src/extract-cliref.test.ts (1)
1-116: LGTM!MANUAL.md (2)
100-102: 📐 Maintainability & Code Quality | ⚡ Quick winStale "not yet ingested" claim left elsewhere in this file.
Line 118 (unchanged by this PR) still reads: CLI Reference "...not yet ingested — see B-0012's proposed follow-up tasks." That directly contradicts the new overlay description just added here. Update or remove line 118's parenthetical now that
extract-cliref.ts/link-cliref.tsingest it.
328-329: LGTM!VALIDATION.md (1)
56-60: LGTM!
- extract-cliref: nothing inside a fenced code block parses as structure — the inFence guard now also covers **gate markers** and <ArgTable>, not just headings (CodeRabbit). Fixture + test cover a fenced fake **Package:** and <ArgTable>. - extract-cliref: --from-cache is a hard offline contract — loadTocNames throws instead of silently fetching llms.txt when the cache is missing (CodeRabbit). - extract-cliref: fail hard on any missing page in a full live run (non --from-cache, no --limit) rather than storing a partial overlay (Copilot). - extract-cliref: cache writes go through safeCachePath() (containment guard) and reads use try/catch instead of existsSync-then-read — closes CodeQL "network data written to file" (traversal) + "file system race condition". - link-cliref: pickNode no longer silently falls back to nodes[0] on a type mismatch; a wrong-typed node is treated as no-match (would corrupt the type-branched field view). New test covers the only-wrong-type-at-path case. - link-cliref: fail fast before the DELETE when schema_nodes has no dir/cmd nodes, so running before extract-schema can't wipe good links (Copilot/CR). - Makefile: `extract` (dev) no longer runs link-cliref (extract-commands leaves schema_nodes empty); `extract-full` keeps it. Documented. - db.ts: view SQL centralized as exported CLIREF_FIELD_VIEW_SQL; link-cliref test imports it instead of a hand-copied duplicate (CodeRabbit/Copilot). Full bun test: 0 fail. Biome/tsc/markdownlint/cspell clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
mobileskyfi
left a comment
There was a problem hiding this comment.
Independent DB/data-quality review complete. I do not see a need for structural rework after the follow-up commit ba067a0.
The source model is the right boundary for future consumers: occurrence-based pages/entries/fields/flags, exact source Markdown + hash, a stored non-derivable entry decision, and a computed field view that follows the current inspect snapshot. I ran a full cached extract → link → DB audit → export against the 7.23.2 release tree: 228 pages / 1,051 entries / 10,118 fields / 948 flags; 907 exact / 24 alias / 120 manual-only; clean SQLite integrity/FKs; all 228 source pages round-trip through export.
The review found and fixed four data-quality risks:
- The view previously emitted 108 links for 96
Read-only Argumentrows merely because their names collided with inspect inputs. It now only maps settableArgumentrows: 13,036 link rows across 5,124 fields, and zero read-only links. - Alias discovery previously accepted any uniquely droppable internal segment. It now allowlists the 19 observed source artifacts, so an unknown future mismatch stays manual-only and is visible to the drift gate.
- A missing per-entry
Typecould be masked by a duplicate marker elsewhere, and cached discovery could silently omit a missing page. Both full live/offline runs now fail closed from the cached sitemap inventory; fenced examples are excluded from marker reconciliation. - SQLite now enforces the raw inspect-type enum, source-order/line bounds, and exact-vs-alias
match_detailconsistency. I simulated the v10→v11 migration and verified invalid rows are rejected.
Tests cover the new read-only, unknown-alias, duplicate/missing-Type, and fenced-marker semantics. TypeScript/Biome/Markdown/cspell are clean; the full run passed 1,032 tests, and the stdio test passes when the isolated worktree is explicitly pointed at the schema-v11 test DB.
The remaining work is appropriately separate and now sharpened in #127: release/QA publish wiring, a committed 907/24/120 drift baseline, and full-artifact DB integrity checks (including the read-only=zero view invariant). Until that issue lands, released DBs still will not contain this overlay.
|
@coderabbitai full review |
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/extract-cliref.ts`:
- Around line 256-295: Update parseArgTable so each ArgTableRow requires
non-empty arg and typ attributes instead of converting missing values to empty
strings. Validate these attributes before pushing to entry.flags or
entry.fields, and throw a descriptive error including slug and rowLine when
either is absent; preserve the existing decoding and row-processing behavior for
valid rows.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 613acb95-aa3d-4ba6-859a-69e5a3382ec2
⛔ Files ignored due to path filters (1)
fixtures/cli-reference/sample.mdis excluded by!fixtures/**
📒 Files selected for processing (17)
CHANGELOG.mdDESIGN.mdMANUAL.mdMakefileVALIDATION.mdbriefings/B-0016-cli-reference-overlay-design.mdproject-words.txtsrc/db.tssrc/export.test.tssrc/export.tssrc/extract-cliref.test.tssrc/extract-cliref.tssrc/extract-schema.tssrc/link-cliref.test.tssrc/link-cliref.tssrc/paths.tssrc/schema-roundtrip.test.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (12)
*
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Keep this Copilot instructions file short; put substantive rules in narrow instruction files under
.github/instructions/*.instructions.md.
Files:
project-words.txtCHANGELOG.mdDESIGN.mdMANUAL.mdMakefileVALIDATION.md
**/*.{ts,tsx}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Use Bun and TypeScript, including Bun-native runtime APIs such as
bun:sqlite,Bun.serve, andbunx.Rosetta uses Bun and TypeScript; prefer
bun,bun test, andmake verifywhere applicable, rather than Node/npm-oriented substitutes.
Files:
src/paths.tssrc/link-cliref.test.tssrc/schema-roundtrip.test.tssrc/export.test.tssrc/extract-schema.tssrc/link-cliref.tssrc/export.tssrc/extract-cliref.test.tssrc/db.tssrc/extract-cliref.ts
src/**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Rosetta is read-only documentation/schema context and must not connect to or modify a user's router.
Files:
src/paths.tssrc/link-cliref.test.tssrc/schema-roundtrip.test.tssrc/export.test.tssrc/extract-schema.tssrc/link-cliref.tssrc/export.tssrc/extract-cliref.test.tssrc/db.tssrc/extract-cliref.ts
**/*.{ts,tsx,md}
📄 CodeRabbit inference engine (AGENTS.md)
Keep the attribution boundary visible when community RouterOS skills surface, because they are supplemental rather than official MikroTik documentation.
Files:
src/paths.tssrc/link-cliref.test.tssrc/schema-roundtrip.test.tsCHANGELOG.mdDESIGN.mdsrc/export.test.tsMANUAL.mdVALIDATION.mdsrc/extract-schema.tssrc/link-cliref.tssrc/export.tssrc/extract-cliref.test.tssrc/db.tssrc/extract-cliref.tsbriefings/B-0016-cli-reference-overlay-design.md
**/*.md
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.md: Keep each project documentation file limited to its canonical role; prefer the documented canonical home instead of creating a new top-level Markdown file.
Do not duplicate content from this routing index; move operational detail, schema blocks, or long rule lists to their canonical documentation or instruction files.
Apply the repository's Markdown linting and fenced-code conventions, while excluding LLM instruction files where the repository explicitly requires that exclusion.
Files:
CHANGELOG.mdDESIGN.mdMANUAL.mdVALIDATION.mdbriefings/B-0016-cli-reference-overlay-design.md
CHANGELOG.md
📄 CodeRabbit inference engine (CLAUDE.md)
Record user-visible shipped changes in
CHANGELOG.mdunder[Unreleased]or release sections.
Files:
CHANGELOG.md
DESIGN.md
📄 CodeRabbit inference engine (CLAUDE.md)
Store durable project rationale, data-source provenance, and architecture tradeoffs in
DESIGN.md.Read
DESIGN.mdwhen changing retrieval, MCP/TUI behavior, data sources, extraction, skills, command validation, or Docusaurus migration work.
Files:
DESIGN.md
MANUAL.md
📄 CodeRabbit inference engine (CLAUDE.md)
Store installation, operations, release or re-extraction procedures, and schema reference material in
MANUAL.md.
Files:
MANUAL.md
{README.md,MANUAL.md,src/setup.ts}
📄 CodeRabbit inference engine (AGENTS.md)
Keep public client setup snippets aligned across
README.md,src/setup.ts, andMANUAL.md, includingcodex mcp add rosetta -- bunx@tikoci/rosetta``.
Files:
MANUAL.md
VALIDATION.md
📄 CodeRabbit inference engine (CLAUDE.md)
Document load-bearing invariants and how CI proves them in
VALIDATION.md.
Files:
VALIDATION.md
src/db.ts
📄 CodeRabbit inference engine (CLAUDE.md)
When touching
src/db.ts, follow both the Bun/runtime conventions and the database-specific instructions.
Files:
src/db.ts
briefings/B-*.md
📄 CodeRabbit inference engine (CLAUDE.md)
Store grounded research and decision support in
briefings/B-*.md.
Files:
briefings/B-0016-cli-reference-overlay-design.md
🪛 ast-grep (0.44.1)
src/extract-cliref.ts
[warning] 264-264: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp(\\b${n}="([\\s\\S]*?)")
Note: [CWE-1333] Inefficient Regular Expression Complexity
(regexp-from-variable)
🪛 GitHub Check: CodeQL
src/extract-cliref.ts
[warning] 112-112: Network data written to file
Write to file system depends on Untrusted data.
[warning] 136-136: Network data written to file
Write to file system depends on Untrusted data.
[warning] 160-160: Network data written to file
Write to file system depends on Untrusted data.
🪛 LanguageTool
DESIGN.md
[style] ~213-~213: To elevate your writing, try using more formal phrasing here.
Context: ...h/dir/cmd/argclass whiletype` keeps normalizing, so the crosswalk can reason about the ...
(CONTINUE_TO_VB)
🔇 Additional comments (22)
src/db.ts (4)
52-71: LGTM!
497-497: 🩺 Stability & AvailabilityConfirm the
inspect_typeCHECK is meant to hard-fail on a new inspect class.
inspect_typeis constrained topath|dir|cmd|arg, but the normalizedtypecolumn (extract-schema.ts) is unconstrained.walk()setsinspectType = nodeType(raw_type). If RouterOS ever emits a new class,typestores it silently while this INSERT fails the CHECK, aborting extraction. If that crash-early asymmetry is intended, ignore; otherwise widen or drop the constraint.
519-532: LGTM!
542-637: LGTM!src/extract-schema.ts (1)
53-54: LGTM!Also applies to: 105-105, 378-382, 396-396
src/paths.ts (1)
135-141: LGTM!src/schema-roundtrip.test.ts (1)
34-55: LGTM!Also applies to: 195-206, 284-291
src/link-cliref.ts (2)
87-133: LGTM!
135-188: LGTM!src/link-cliref.test.ts (1)
16-118: LGTM!src/export.ts (2)
448-602: LGTM!
733-748: LGTM!Also applies to: 789-790, 819-823, 837-837, 850-854
src/export.test.ts (1)
552-600: LGTM!DESIGN.md (1)
201-216: LGTM!briefings/B-0016-cli-reference-overlay-design.md (1)
201-374: LGTM!CHANGELOG.md (1)
25-33: LGTM!src/extract-cliref.ts (1)
1-255: LGTM!Also applies to: 296-583
src/extract-cliref.test.ts (1)
1-139: LGTM!VALIDATION.md (1)
56-60: LGTM!Makefile (1)
6-6: LGTM!Also applies to: 136-144, 160-174
project-words.txt (1)
135-135: LGTM!Also applies to: 444-444, 480-481
MANUAL.md (1)
100-102: LGTM!Also applies to: 118-118, 328-329
parseArgTable defaulted a missing arg/typ attribute to "", producing an anonymous field/flag the aggregate count-reconciliation cannot catch — the one spot in the parser that swallowed malformed input instead of throwing like every other structural anomaly. Add requireAttr + a regression test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…tes in SQL Address Copilot re-review on the cli-reference export path: - ExportSummary now carries sourceFiles (the cli-reference/source/*.md written via rawFiles), and `rosetta export` prints them — the CLI previously said "Wrote N datasets" and hid the produced source files. - pages.tsv computes source_bytes with length(CAST(source_markdown AS BLOB)) in SQLite instead of loading the full markdown a second time just to size it (cliRefSourceFiles already reads it to write the md). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
extract-cliref.test.ts and link-cliref.test.ts statically imported modules that reach the db.ts singleton (which opens the DB at module scope). If either file evaluated before query.test.ts set DB_PATH=:memory:, db.ts would open the real on-disk DB and trip query.test.ts's singleton guard — an order-dependent flake (the v0.7.6 empty-DB regression the guard exists to catch). Adopt the documented convention already used by query.test.ts / export.test.ts: set DB_PATH=:memory: before any db.ts-reaching import, then load those symbols via dynamic await import() so the env assignment wins over ESM hoisting. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…order The cli-reference overlay test inserted cliref_* + schema_nodes rows into the shared DB singleton and leaned on "runs LAST" so the exact-file-set assertions above (which expect no cli-reference/* output) wouldn't see them. Add an afterAll that deletes the inserted rows so the block is self-contained and no longer order-dependent. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
- CLIREF_DISCLOSURES: name the objects correctly — field-inspect-links.tsv is the cliref_field_inspect_links VIEW (computed), derived from the stored cliref_entry_schema_links crosswalk; the note had conflated the two. - VALIDATION.md V-cliref-parse-reconcile: clarify that today `bun test` enforces the fixture fail-loud path, and the full-corpus reconcile becomes a CI gate only once extract-cliref is wired into the release build (#127) — the build does not run `make extract-cliref` yet. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Implements the CLI-Reference DB overlay from #124 (design:
briefings/B-0016-cli-reference-overlay-design.md). DB / ETL / export only — no MCP/TUI/query-behavior changes (those stay in #25). Every number below was reproduced against thev0.11.1release DB during development.What's here
cliref_pages/entries/fields/flagssource tables (occurrence identity, byte-exact source Markdown + SHA-256, no path on fields),cliref_entry_schema_linksstored crosswalk,cliref_field_inspect_linksview, andschema_nodes.inspect_type(preserves rawpath/dir/cmd/arg;typestill normalizespath→dir).extract-schema.ts— storesinspect_type; roundtrip test proves thepath→dirdivergence.src/extract-cliref.ts— source-faithful extractor. 228 pages → 1,051 entries → 10,118 fields → 948 flags; asserts parsed == source markers, fails loud on unknown labels, guards fenced-code false headings, keeps verbatim descriptions (no whitespace flattening).src/link-cliref.ts+ fast view — resolves entries exact / single-internal-segment alias / manual-only: 907 exact, 24 alias, 120 manual-only (matches the experiment exactly). View rewritten as a UNION with a(parent_path, name)index: ~200ms (was >14s).rosetta export— sixcli-reference/*.tsv+ byte-exactsource/<slug>.md.fields.tsvusesentry_source_path, neverfield_path; zero-to-many lives infield-inspect-links.tsv.make extract-cliref/link-clireftargets added;extract-fullorders the link pass afterschema_nodespopulation; CHANGELOG, VALIDATION, MANUAL, DESIGN updated.Key modeling decisions (from the second-pass review)
certificate.name→ 7).cliref_fieldshas a name + entry FK. Read-only fields are excluded from the inspect-input view because a same-name input is not proof of an output-field identity.schema_nodessnapshot.match_detailrecords it; unknown or ambiguous shapes → manual-only. Source paths are never rewritten.Verification
parseTsv.Known GAPs (honest debt, in VALIDATION.md, tracked by #127)
V-cliref-link-drift— the linker now allowlists the 19 known internal segments, so a new alias-shaped mismatch stays manual-only; CLI-Reference overlay: CI publish wiring + close V-cliref-link-drift / V-cliref-db-integrity gaps #127 still needs the committed 907/24/120 baseline gate.V-cliref-db-integrity— full-DB FK/integrity/enum/orphan checks validated manually during development, not yet a committed CI gate (CLI-Reference overlay: CI publish wiring + close V-cliref-link-drift / V-cliref-db-integrity gaps #127).extract-fullhas the correct ordering; CLI-Reference overlay: CI publish wiring + close V-cliref-link-drift / V-cliref-db-integrity gaps #127 tracks placingextract-cliref+link-clirefinrelease.yml/qa.yml. Until then, released DBs do not carry the overlay.raw_typestructured parsing; the CLI-Reference argument-type glossary landing page (prose, no command entries) — both noted as follow-ups.Closes #124.
🤖 Generated with Claude Code
Summary by CodeRabbit
cli-reference/subtree and corresponding manifest disclosures when the overlay is present.