Repository navigation
fix(explain): warn on an unknown or ambiguous command inside [ … ] (#572) - #680
mobileskyfi wants to merge 2 commits into
Conversation
) `:put [/ip/address/nosuchverb]` and `:local v [nosuchcmd where name=x]` passed silently while the same text at the top level warned. The unresolved/ambiguous warnings were emitted per statement only. A bracket the verb reader read now gets the same abstention warning, spanned on the substitution. A bracket with no command head ([$f], [(…)]) stays silent: the device accepts those (corrected-anchors rows trailing-selector*). Corpus (948 scripts, pinned): 14 move pass -> warn; 3 are rejected by every recorded RouterOS version, 11 accepted and unreadable offline at the top level too (recorded as two matrix nits). Session: 4f3a1170-9bf0-4eac-97bd-7c9c9d0e6bbd Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration:
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. |
mobileskyfi
left a comment
There was a problem hiding this comment.
Reviewer: codex/gpt-6.2-sol · head 2eb8da7 · session 01a21a6c-1619-7f52-b36e-70d0c2b35d5c
I found four issues, detailed inline. The GitHub Corpus census job fails at this head, and bun run explain:conformance:check reproduces the failure locally.
Against pinned snapshot e12d5d4e58a4, I compared 0cc371c and 2eb8da7. In the 948-script population, only 14 verdicts change, all pass → warn. All four recorded versions accept 11 of those scripts and reject 3. Removing the eligibility filter reproduces the wider variant's 123 changes, with 114 accepted and 9 rejected by all four versions. The accepted colon-less builtins also include [toarray "$2"].
bun test test/unit passed (5,559 passed, 9 skipped), and bun run lint:ci passed. The #572 controls, nested brackets and do={…} produced the expected warnings on exact ASCII spans, including after Unicode on a preceding line and with CRLF. Each new diagnostic cited the published e5 entry. The execute offline gate accepts these warnings as abstentions and proceeds to device validation. Live explain still probes and recomputes the verdict over the combined diagnostics. Offline exit codes for error, warning and never were 0, 2 and 0 for the warning control.
…xt (#572) Review on #680: - A bracket Q3 refused but that still has a command head (a variable path segment, a relative command under a lost context) warns like its statement form. Only a bracket with no command in it ([$f], [(…)], a pasted prompt) stays silent. Corpus verdict moves are unchanged (14). - scanInterpolations skipped no escapes, so `:put "\$[x]"` produced a phantom substitution and now a warning. An escaped character is skipped. - Re-adopt the conformance fixture: 3 of 875 cases move pass -> warn. - Matrix nit for the non-ASCII bracket-span widening. Session: 4f3a1170-9bf0-4eac-97bd-7c9c9d0e6bbd Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🔵 Needs a closer look
Approval should wait for human confirmation of the claimed four-version CHR behavior and corpus census, which static review cannot independently verify for these parser and diagnostic changes.
No open issues 🎉
What changed in this PR
This PR updates offline explain analysis so command-bearing bracket substitutions emit the same unknown or ambiguous-command warnings as equivalent top-level statements, while preserving silent handling for expressions, function calls, and escaped interpolation text.
Changes:
- Adds span-aware warnings for unresolved or ambiguous bracketed commands.
- Skips escaped
\$[…]sequences during interpolation scanning and keeps command-less brackets silent. - Updates regression tests, conformance expectations, corpus documentation, glossary entries, and the changelog.
| File | Description |
|---|---|
| test/unit/explain-structure.test.ts | Adds regression coverage for bracket warnings, spans, nested and variable-path cases, escaped interpolations, and silent expressions. |
| test/unit/explain-corrected-anchors.test.ts | Updates the corrected-anchor expectation for the unknown bracket command from pass to warn. |
| test/fixtures/explain/conformance.json | Records the updated conformance verdict and census expectations. |
| src/explain/pathresolve.ts | Distinguishes command-less brackets and skips escaped characters while scanning interpolations. |
| src/explain.ts | Classifies bracket readings and emits substitution-scoped diagnostics for command-bearing brackets. |
| GLOSSARY.txt | Adds the RouterOS inkey vocabulary term. |
| docs/MATRIX.md | Documents known offline-reader limitations identified by the corpus census. |
| CHANGELOG.md | Documents the new bracketed-command warning behavior and its corpus impact. |
Review effort: Lite
Fixes #572.
Change
:put [/ip/address/nosuchverb],:put [nosuchcmd]and:local varID [nosuchcmd where name=x]returnedpasswith no diagnostics. The same text at the top level warned, because theunresolved-statementandambiguous-statementwarnings were only emitted per statement. Now a[…]subcommand that the verb reader read gets the same warning, spanned on the substitution. It is still a warning and never an error; offline still abstains.Scope (revised after review): a bracket warns unless it has no command in it. The silent brackets are those where Q3 finds no command head (
path === nulland no tokens): a[$f]call, a[($a . $b)]expression, or a pasted CLI prompt. The device accepts these, and the corrected-anchor rowstrailing-selector*pinpass. A bracket Q3 refuses that still has a command head now warns like its statement form. That covers a variable path segment ([/ip/$menu/x]) and a relative command whose context was lost. An escaped\$[…]in a string is now read as text (scanInterpolationsskips escaped characters). Before this, it produced a phantom substitution.Corpus census
The run covered the pinned 948-script corpus (
lsp-routeros-ts/test-data/corpus.sqlite, sibling copy matching the pin). The device oracle isparseObservationsover the four recorded sessions: long-term 7.23.8, stable 7.24.5, testing 7.25rc2 and development 7.26beta1.No other verdict changes. The variable-path and lost-context warnings that C adds land only in scripts that already warned. In the 875-case
wiresage-conformanceset, 3 cases move frompasstowarn, andtest/fixtures/explain/conformance.jsonis re-adopted for them:parameters-and-flags/r20(all four versions reject[nope]), andcolon-prefix/p3andcolon-prefix/p12(accepted; colon-less builtins).[../find disabled=no], a broken…fd print as-value]], and a bare[fetch url=…].[typeof $b],[tostr $1],[pick …],[len …],[toip6 …](5 scripts)[/terminal/inkey](4)[/system/script/run staticUrl](1)[monitor $ups once as-value](1)I added three matrix nits: one for the non-ASCII bracket spans that widen to the whole statement (see the review thread), and two for the verb-reader gaps behind these: colon-less builtins, and the operand after
runbeing read as a path. Fixing them would lower the warning count at both levels.Tests
test/unit/explain-structure.test.ts:[$f],[$f arg=1]and[($a . $b)]control-unknown-commandis updated deliberately frompasstowarn. The device answer is unchanged (validation/syntaxon 7.25 and 7.23.8).bun run lint:ci,bun test test/unit(5559 pass) andbun run buildall pass.test/integration/explain-*.test.tson CHR 7.25.2 gives 20/20. Two of those files (explain-values,explain-structure) only pass with a clean HOME, because they callexecuteEnvelopewith the default env and read my real encrypted CDB. That is CHR integration tests read the developer's real CDB and centrs.env (fail with an encrypted CDB) #654, fixed separately in test: give the integration tier a hermetic HOME (#654) #679, not this change: with a throwaway HOME they give 6/6.🤖 Generated with Claude Code