Skip to content

CLI-Reference DB overlay: lossless ETL, inspect crosswalks, export (#124)#126

Merged
mobileskyfi merged 17 commits into
mainfrom
feat/cliref-overlay-124
Jul 21, 2026
Merged

CLI-Reference DB overlay: lossless ETL, inspect crosswalks, export (#124)#126
mobileskyfi merged 17 commits into
mainfrom
feat/cliref-overlay-124

Conversation

@mobileskyfi

@mobileskyfi mobileskyfi commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

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 the v0.11.1 release DB during development.

What's here

  1. DB schema (v11)cliref_pages/entries/fields/flags source tables (occurrence identity, byte-exact source Markdown + SHA-256, no path on fields), cliref_entry_schema_links stored crosswalk, cliref_field_inspect_links view, and schema_nodes.inspect_type (preserves raw path/dir/cmd/arg; type still normalizes pathdir).
  2. extract-schema.ts — stores inspect_type; roundtrip test proves the pathdir divergence.
  3. 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).
  4. 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).
  5. rosetta export — six cli-reference/*.tsv + byte-exact source/<slug>.md. fields.tsv uses entry_source_path, never field_path; zero-to-many lives in field-inspect-links.tsv.
  6. Tests + fixture + build wiring + docsmake extract-cliref/link-cliref targets added; extract-full orders the link pass after schema_nodes population; CHANGELOG, VALIDATION, MANUAL, DESIGN updated.

Key modeling decisions (from the second-pass review)

  • Entries have paths; fields don't. A settable field maps to zero-to-many inspect coordinates (5,124 of 6,171 settable fields link in the audited 7.23.2 tree; certificate.name → 7). cliref_fields has 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.
  • Store the entry link, compute the field links. The entry link carries the non-derivable exact/alias decision; field links are a view so the version-less overlay never pins to a versioned schema_nodes snapshot.
  • Auditable aliasing. Only one of the 19 documented internal module segments may be dropped (never root/leaf); match_detail records it; unknown or ambiguous shapes → manual-only. Source paths are never rewritten.

Verification

  • Review pass: 1032 tests passed; the stdio integration also passes when pointed at the current schema-v11 test DB. Biome, tsc, markdownlint, and cspell are clean.
  • Export validated on a full build: 228/1051/10118/948 rows, entry-links 931 (907+24), field-links 13,036 for settable fields and 0 for read-only fields, all 228 source md sha256-exact, every TSV round-trips through parseTsv.

Known GAPs (honest debt, in VALIDATION.md, tracked by #127)

Closes #124.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a CLI Reference overlay with parsed pages, entries, fields, flags, and byte-exact source markdown for deterministic exports.
    • Exports can now include a new cli-reference/ subtree and corresponding manifest disclosures when the overlay is present.
    • Added build steps to extract and link CLI Reference overlay data.
    • Preserves original CLI classification alongside normalized schema typing for lossless matching.
  • Documentation
    • Updated guides for overlay parsing, identity rules, and export/link semantics.
  • Validation / Tests
    • Added CLI Reference validation invariants and export/link integration tests.

mobileskyfi and others added 7 commits July 20, 2026 19:22
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>
Copilot AI review requested due to automatic review settings July 21, 2026 03:07
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 51a7a7cd-9449-49fe-b310-ecdb53ecb705

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Changes

The 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

Layer / File(s) Summary
Schema and inspect-type contracts
src/db.ts, src/extract-schema.ts, src/paths.ts, src/schema-roundtrip.test.ts, DESIGN.md, briefings/...
Adds overlay tables, a field-link view, schema version 11, and schema_nodes.inspect_type preservation alongside normalized types.
CLI-Reference extraction and parsing
src/extract-cliref.ts, src/extract-cliref.test.ts, Makefile, MANUAL.md, VALIDATION.md, project-words.txt
Discovers or loads cached Markdown, parses and stores entries, fields, flags, metadata, ancestry, and source hashes with reconciliation checks.
Entry and field inspect linking
src/link-cliref.ts, src/link-cliref.test.ts, src/db.ts, VALIDATION.md
Resolves exact or unambiguous aliases into stored entry links and computes field-to-inspect mappings through the SQLite view.
Overlay export and pipeline wiring
src/export.ts, src/export.test.ts, Makefile, MANUAL.md, CHANGELOG.md
Adds conditional CLI-Reference TSV and byte-exact Markdown exports, manifest disclosures, pruning ownership, and extraction pipeline prerequisites.

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
Loading

Possibly related issues

Possibly related PRs

  • tikoci/rosetta#103 — Provides the DB-only export pipeline extended here with CLI-Reference datasets.
  • tikoci/rosetta#110 — Shares the export manifest ownership and pruning logic extended for overlay artifacts.

Suggested labels: area:docusaurus

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 72.73% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main CLI-Reference overlay, lossless ETL, and export work.
Linked Issues check ✅ Passed The changes cover the overlay schema, inspect_type preservation, crosswalks, computed field links, export, validation, and docs required by #124.
Out of Scope Changes check ✅ Passed No out-of-scope MCP, TUI, or query changes are present; the added dictionary terms support the new CLI-Reference content.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/cliref-overlay-124

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread src/extract-cliref.ts Fixed
Comment thread src/extract-cliref.ts
Comment thread src/extract-cliref.ts

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, stored cliref_entry_schema_links, computed cliref_field_inspect_links view, and new schema_nodes.inspect_type.
  • Adds new extract/link pipelines (src/extract-cliref.ts, src/link-cliref.ts) plus fixtures/tests proving source fidelity, link policy, and inspect_type roundtrip behavior.
  • Extends rosetta export to emit cli-reference/*.tsv plus byte-exact cli-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).

Comment thread src/extract-cliref.ts Outdated
Comment thread src/link-cliref.test.ts Outdated
Comment thread src/link-cliref.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between ce97791 and 7c72eab.

⛔ Files ignored due to path filters (1)
  • fixtures/cli-reference/sample.md is excluded by !fixtures/**
📒 Files selected for processing (17)
  • CHANGELOG.md
  • DESIGN.md
  • MANUAL.md
  • Makefile
  • VALIDATION.md
  • briefings/B-0016-cli-reference-overlay-design.md
  • project-words.txt
  • src/db.ts
  • src/export.test.ts
  • src/export.ts
  • src/extract-cliref.test.ts
  • src/extract-cliref.ts
  • src/extract-schema.ts
  • src/link-cliref.test.ts
  • src/link-cliref.ts
  • src/paths.ts
  • src/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, and bunx.

Rosetta uses Bun and TypeScript; prefer bun, bun test, and make verify where applicable, rather than Node/npm-oriented substitutes.

Files:

  • src/link-cliref.test.ts
  • src/paths.ts
  • src/extract-cliref.test.ts
  • src/export.test.ts
  • src/link-cliref.ts
  • src/extract-schema.ts
  • src/db.ts
  • src/schema-roundtrip.test.ts
  • src/extract-cliref.ts
  • src/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.ts
  • src/paths.ts
  • src/extract-cliref.test.ts
  • src/export.test.ts
  • src/link-cliref.ts
  • src/extract-schema.ts
  • src/db.ts
  • src/schema-roundtrip.test.ts
  • src/extract-cliref.ts
  • src/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.ts
  • src/paths.ts
  • VALIDATION.md
  • src/extract-cliref.test.ts
  • src/export.test.ts
  • CHANGELOG.md
  • DESIGN.md
  • MANUAL.md
  • src/link-cliref.ts
  • src/extract-schema.ts
  • src/db.ts
  • briefings/B-0016-cli-reference-overlay-design.md
  • src/schema-roundtrip.test.ts
  • src/extract-cliref.ts
  • src/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.txt
  • VALIDATION.md
  • CHANGELOG.md
  • DESIGN.md
  • MANUAL.md
  • Makefile
**/*.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.md
  • CHANGELOG.md
  • DESIGN.md
  • MANUAL.md
  • briefings/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.md under [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.md when 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, and MANUAL.md, including codex 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 win

Figure 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 win

Numeric 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.md line 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 win

Stale "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.ts ingest it.


328-329: LGTM!

VALIDATION.md (1)

56-60: LGTM!

Comment thread Makefile Outdated
Comment thread src/extract-cliref.ts
Comment thread src/extract-cliref.ts
Comment thread src/link-cliref.test.ts
Comment thread src/link-cliref.ts Outdated
mobileskyfi and others added 3 commits July 20, 2026 20:39
- 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>
V-cliref-link-drift and V-cliref-db-integrity are tracked by the follow-on
issue #127 (CI publish wiring + closing both gaps), not #124 itself.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@mobileskyfi mobileskyfi left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Argument rows merely because their names collided with inspect inputs. It now only maps settable Argument rows: 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 Type could 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_detail consistency. 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.

Comment thread src/extract-cliref.ts
Comment thread src/extract-cliref.ts Fixed
@mobileskyfi

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between ce97791 and 5704fcf.

⛔ Files ignored due to path filters (1)
  • fixtures/cli-reference/sample.md is excluded by !fixtures/**
📒 Files selected for processing (17)
  • CHANGELOG.md
  • DESIGN.md
  • MANUAL.md
  • Makefile
  • VALIDATION.md
  • briefings/B-0016-cli-reference-overlay-design.md
  • project-words.txt
  • src/db.ts
  • src/export.test.ts
  • src/export.ts
  • src/extract-cliref.test.ts
  • src/extract-cliref.ts
  • src/extract-schema.ts
  • src/link-cliref.test.ts
  • src/link-cliref.ts
  • src/paths.ts
  • src/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.txt
  • CHANGELOG.md
  • DESIGN.md
  • MANUAL.md
  • Makefile
  • VALIDATION.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, and bunx.

Rosetta uses Bun and TypeScript; prefer bun, bun test, and make verify where applicable, rather than Node/npm-oriented substitutes.

Files:

  • src/paths.ts
  • src/link-cliref.test.ts
  • src/schema-roundtrip.test.ts
  • src/export.test.ts
  • src/extract-schema.ts
  • src/link-cliref.ts
  • src/export.ts
  • src/extract-cliref.test.ts
  • src/db.ts
  • src/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.ts
  • src/link-cliref.test.ts
  • src/schema-roundtrip.test.ts
  • src/export.test.ts
  • src/extract-schema.ts
  • src/link-cliref.ts
  • src/export.ts
  • src/extract-cliref.test.ts
  • src/db.ts
  • src/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.ts
  • src/link-cliref.test.ts
  • src/schema-roundtrip.test.ts
  • CHANGELOG.md
  • DESIGN.md
  • src/export.test.ts
  • MANUAL.md
  • VALIDATION.md
  • src/extract-schema.ts
  • src/link-cliref.ts
  • src/export.ts
  • src/extract-cliref.test.ts
  • src/db.ts
  • src/extract-cliref.ts
  • briefings/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.md
  • DESIGN.md
  • MANUAL.md
  • VALIDATION.md
  • briefings/B-0016-cli-reference-overlay-design.md
CHANGELOG.md

📄 CodeRabbit inference engine (CLAUDE.md)

Record user-visible shipped changes in CHANGELOG.md under [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.md when 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, and MANUAL.md, including codex 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 & Availability

Confirm the inspect_type CHECK is meant to hard-fail on a new inspect class.

inspect_type is constrained to path|dir|cmd|arg, but the normalized type column (extract-schema.ts) is unconstrained. walk() sets inspectType = nodeType (raw _type). If RouterOS ever emits a new class, type stores 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

Comment thread src/extract-cliref.ts
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>
Copilot AI review requested due to automatic review settings July 21, 2026 17:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.

Comment thread src/export.ts Outdated
Comment thread src/export.ts Outdated
Comment thread src/db.ts
…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>
Copilot AI review requested due to automatic review settings July 21, 2026 18:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.

Comment thread src/extract-cliref.test.ts Outdated
Comment thread src/link-cliref.test.ts Outdated
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>
Copilot AI review requested due to automatic review settings July 21, 2026 18:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.

Comment thread src/export.test.ts
…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>
Copilot AI review requested due to automatic review settings July 21, 2026 18:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.

Comment thread src/extract-cliref.ts Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 21, 2026 18:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.

Comment thread src/export.ts Outdated
Comment thread VALIDATION.md Outdated
- 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>
Copilot AI review requested due to automatic review settings July 21, 2026 18:49
@mobileskyfi
mobileskyfi removed the request for review from Copilot July 21, 2026 18:50
@mobileskyfi
mobileskyfi merged commit 363a87a into main Jul 21, 2026
11 of 13 checks passed
@mobileskyfi
mobileskyfi deleted the feat/cliref-overlay-124 branch July 21, 2026 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI-Reference DB overlay: lossless ETL, inspect crosswalks, and export

3 participants