Enforce static db.ts-import guard + control-char scan (#98); point MANUAL schema rows at Docusaurus - #117
Conversation
…chema rows at Docusaurus Closes #98. Adds src/source-hygiene.test.ts, two DB-less structural scans that make two "passes every other check but silently breaks" hazards enforced instead of remembered: - V-test-db-import-static-guard: no *.test.ts that sets process.env.DB_PATH may statically (value-)import a module transitively reaching db.ts — the hoisting hazard that opens the real ros-help.db before :memory: and trips V-db-wipe-guard only on unlucky bun file order. import type is erased and stays allowed. - V-source-no-control-chars: no source .ts may carry a NUL or other disallowed C0/DEL control byte (the #97 stray-NUL class that makes file report data and grep match nothing while tests/typecheck/biome pass). The live occurrences were fixed in PR #97; this closes the enforcement gap so they can't silently return. Updates extractor-import-side-effects.instructions.md and VALIDATION.md accordingly. Docs: refreshes the MANUAL.md schema-reference pages/callouts row descriptions to name the live manual.mikrotik.com Docusaurus source (counts stay flagged frozen). README/DESIGN already point at Docusaurus with Confluence framed as frozen/legacy (issue #77). 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:
📝 WalkthroughWalkthroughAdds repo-wide tests that detect DB-reaching static imports in ChangesSource hygiene enforcement
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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
Adds structural “source hygiene” checks to prevent a known Bun test-order hazard from silently opening the on-disk DB, and documents the new validation rules while refreshing MANUAL schema-row wording to reflect the live Docusaurus corpus.
Changes:
- Add
src/source-hygiene.test.tswith two DB-less structural scans: a static db.ts-reaching import guard forDB_PATHtests, and a control-character (NUL/C0/DEL) source scan. - Document the new validation IDs (
V-test-db-import-static-guard,V-source-no-control-chars) and reinforce the dynamic-import discipline in the extractor side-effects instruction. - Update MANUAL schema table descriptions to point to
manual.mikrotik.com(Docusaurus) while keeping legacy Confluence rows acknowledged; addnulto the spelling dictionary; add a changelog entry.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/source-hygiene.test.ts |
New structural tests: db.ts-reaching static import guard for DB_PATH-setting tests, plus control-character scan. |
VALIDATION.md |
Adds two new V-* rows describing the new structural guards and where CI runs them. |
.github/instructions/extractor-import-side-effects.instructions.md |
Updates the documented rule to note the new structural enforcement test. |
MANUAL.md |
Updates schema-row descriptions to reference the live Docusaurus corpus and manual.mikrotik.com. |
CHANGELOG.md |
Adds an Unreleased “Fixed” bullet describing the new enforcement and control-char scan. |
project-words.txt |
Adds nul to the project dictionary to keep spellcheck clean. |
The header comment, VALIDATION row, and CHANGELOG all said 'source .ts' but the scan only walked src/. Broaden it to cover all source .ts (src/ + scripts/, via SOURCE_DIRS) so the wording matches what CI enforces; diagnostics now print repo-relative paths. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…rt-guard # Conflicts: # CHANGELOG.md # MANUAL.md
Update — Copilot review + main merge resolved
|
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/source-hygiene.test.ts`:
- Around line 81-83: Update the fromRe regular expression in
source-hygiene.test.ts to match both import declarations and re-export
declarations by replacing the import-only prefix with an import-or-export
alternative. Preserve the existing multiline specifier and module-source capture
behavior so export * from and export { ... } from contribute to the transitive
dependency closure.
🪄 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: e77a6e49-8fcf-4673-9cc1-39c6a065f125
📒 Files selected for processing (5)
.github/instructions/extractor-import-side-effects.instructions.mdCHANGELOG.mdVALIDATION.mdproject-words.txtsrc/source-hygiene.test.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (3)
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (actions)
- GitHub Check: Analyze (javascript-typescript)
🧰 Additional context used
📓 Path-based instructions (8)
*
📄 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.md
.github/instructions/*.instructions.md
📄 CodeRabbit inference engine (AGENTS.md)
Manually read matching
.github/instructions/*.instructions.mdfiles because Codex does not automatically apply CopilotapplyToselection.
Files:
.github/instructions/extractor-import-side-effects.instructions.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:
VALIDATION.mdCHANGELOG.md
VALIDATION.md
📄 CodeRabbit inference engine (CLAUDE.md)
Document load-bearing invariants and how CI proves them in
VALIDATION.md.
Files:
VALIDATION.md
**/*.{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:
VALIDATION.mdCHANGELOG.mdsrc/source-hygiene.test.ts
CHANGELOG.md
📄 CodeRabbit inference engine (CLAUDE.md)
Record user-visible shipped changes in
CHANGELOG.mdunder[Unreleased]or release sections.
Files:
CHANGELOG.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/source-hygiene.test.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/source-hygiene.test.ts
🪛 LanguageTool
VALIDATION.md
[uncategorized] ~29-~29: The official name of this software platform is spelled with a capital “H”.
Context: ...db.ts import guard) via bun test in .github/workflows/test.yml | blocking | #98 | ...
(GITHUB)
[uncategorized] ~30-~30: The official name of this software platform is spelled with a capital “H”.
Context: ...haracters in source) via bun testin.github/workflows/test.yml| blocking |#98` | ...
(GITHUB)
A barrel re-export (`export * from` / `export { db } from`) evaluates the
target module at runtime just like an import, so it can carry a test file's
static reach to db.ts. The import scanner only matched `^import`; widen it to
`(?:import|export)` so re-exports are included in the transitive closure.
`export type … from` stays erased/allowed via the same type-group skip.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Closes #98.
Two 0.11.0 cleanups, per the triage split on #98: the cheap durable guard (suggested-work item 1 + the "Related" NUL-byte note), plus the requested MANUAL/README docs pass toward
manual.mikrotik.com.#98 — make the rule enforced, not remembered
The live bug (a hoisted static
db.ts-reaching import inextract-docusaurus.test.ts, and a stray NUL byte) was already fixed in PR #97; what was left was enforcement so it can't silently come back. Newsrc/source-hygiene.test.ts— two DB-less structural scans, no runtime cost:V-test-db-import-static-guard— scans every*.test.tsthat setsprocess.env.DB_PATHand fails if any statically **value-**imports a module transitively reachingdb.ts. That's the hoisting hazard: the static import runsdb.ts's module-scopenew sqlite(DB_PATH)before:memory:is assigned, opening the realros-help.db.query.test.ts'sV-db-wipe-guardonly trips on it when the offending file loadsdb.tsfirst, and bun's file order isn't stable — so it presents as a flake. This blocks it at author time regardless of order. Statement-levelimport type … fromis erased and stays allowed (e.g.extract-hardware-catalog.test.ts).V-source-no-control-chars— no source.tsmay carry a NUL or other disallowed C0/DEL control byte (tab/newline/CR allowed). The class where a stray NUL makesfilereport the source asdataand grep silently match nothing while tests/typecheck/biome all pass.Both verified to fire on a planted violation (a static
./query.tsimport in aDB_PATHtest; a NUL byte in a temp source file) with a one-read diagnostic, then pass on the real tree.extractor-import-side-effects.instructions.mdandVALIDATION.mdupdated.Deferred per the triage split (not in this PR): item 2 (name the offender in
V-db-wipe-guard) and item 3 (bun test --isolateinvestigation).Docs — point at Docusaurus, not Confluence
README and DESIGN already frame the live
manual.mikrotik.comDocusaurus corpus as current with Confluence as frozen/legacy (issue #77); a full sweep found nothing still presenting Confluence as the live source. The one honest touch-up: MANUAL's schema-referencepages/calloutsrow descriptions still described the Confluence source shape under the frozen-counts caveat — refreshed to name the current Docusaurus source (manual.mikrotik.comURL;:::admonitions), counts still flagged frozen.Validation
bun test— 985 pass / 0 fail (32 files);source-hygiene.test.ts87 pass.bunx @biomejs/biome checkclean;bun run lint:md/lint:spellclean (nuladded toproject-words.txt).🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests
Documentation