✨ Add --no-secret-detection to xmd run and xmd test - #330
Conversation
`xmd` inherited default-on detection from `execute()` but had no way to turn it off and said nothing when it was off. Both commands now carry `--no-secret-detection`, the resolved value reaches every document each form runs, and a disabled invocation says so once. The option is an ordinary boolean field, because that is what configliere negates: `--no-secret-detection` resolves a `secretDetection` field to false with no argv reading of our own. It deliberately takes no aliases — declaring the negative spelling as one makes the parser read it as the positive switch, and the opt-out silently stops working. `--secret-detection=false` is refused rather than obeyed or ignored. The parser resolves an `=` form on either spelling back to the default, so it would read as *enabled* — the opposite of what the caller asked for, in silence, on the option that decides whether credentials may be persisted. The error names the one spelling that turns detection off. The warning is written at the command boundary rather than in runDocument, so testing a directory of fifty documents warns once for the invocation instead of once per document. Help and version requests execute nothing and warn not at all.
PR #330: ✨ Add --no-secret-detection to xmd run and xmd test4 files, +371 / -1 Scope✅ PR scope looks good. Structural✅ No structural bloat detected. Slop✅ Slop indicators look low. Static Analysis✅ Oxlint found no issues. CorrectnessFILE: packages/cli/src/node.ts FILE: packages/cli/src/node.ts FILE: packages/cli/tests/secret-detection-cli.test.ts |
|
Checked all three findings against the code at All three name The code being described lives in 1. "Duplicate field declaration" — two commands, not a duplicateThe two occurrences are one line each, in two different configliere command configs, and both reference the same constant:
I applied the suggested removal to see what it does. Removing the
Worth noting: SD7 still passed under that mutation, because with the field gone 2. "Redundant constant declaration" — four uses across two contextsThey keep the help text, the parser rejection, and the error message agreeing on the exact spelling — which is the subject of this PR, since configliere renders only the positive switch in help while the negative spelling is what a caller writes. 3. "Superfluous test helper" — used by 11 of 12 tests
The two extra The working tree is unchanged and the suite is green (12/12). Given the file attribution is wrong on all three, this review may have run against a different or stale diff — worth re-running against |
Why
#329 made secret detection the default policy of
execute()with a host-only opt-out.xmdinherited the default because it callsexecute(), but had no way to turn it offand said nothing when it was off. This is #199's CLI slice. #199 stays open for
cross-backend/runtime certification and website documentation.
What changes
Before:
xmdalways scanned, and no flag could change it.After:
--no-secret-detectiondisables detection for the whole invocation, onxmd run,the default form that omits
run, inline-e, andxmd testagainst a file or adirectory. Detection stays on when the option is absent. A disabled invocation writes one
line to stderr before the first document runs:
How it works
The option is an ordinary boolean field. Configliere negates boolean switches natively —
its README documents
--debug/--no-debug— so asecretDetectionfield makes--no-secret-detectionresolve tofalsewith no argv reading of our own.DocumentConfiggains the field;TestConfigalready extendsOmit<DocumentConfig, "root">and both command cases already spread...config, so thevalue reaches every document without new plumbing.
The warning is emitted at the command boundary — in
runXmd'sruncase and once insidetest()— never inrunDocument. That is what makes a directory of fifty documents warnonce rather than fifty times, and what keeps
--helpand--versionsilent, since bothreturn before either call site.
What I verified about the parser first
Probed
configliere@0.4.0in the workspace rather than assuming, and two results shapedthe implementation:
true--no-secret-detectionfalse--secret-detectiontrue--secret-detection=falsetrue--no-secret-detection=truetruealiases: ["--no-secret-detection"], that flagresolves to
true— an opt-out that silently does nothing. The field takes noaliases, and this is one of the mutations.
=form resolves back to the default, i.e. to enabled — the opposite ofwhat the caller asked, in silence, on the option that decides whether credentials may
be persisted. It is now refused with an error naming the spelling that works. Making
it work instead would have added a second spelling to a surface that deliberately has
one.
so the description carries
--no-secret-detectiononto both help pages.What must stay true
DocumentConfigto the singleexecute()call; checked by SD2–SD6 and SD11, and bythe
drop-from-executemutation.field.default(true); checked by SD1, SD3–SD6,SD10, and the
default-disabledmutation.by SD7 over a two-document directory and the
warn-per-documentmutation.warn-on-stdoutmutation.accept-value-formandalias-negationmutations.How to verify it
Canaries are assembled at run time, so no usable-looking literal enters the repository,
and no test reads an environment variable, Git credential, or user configuration. Tests
shell out through
runCli, so exit status and the two streams are observed separatelyand TTY-independently.
packages/cli/tests/secret-detection-cli.test.ts— SD1 to SD12:xmd runrefuses a credential-shaped document by default, and runs it underthe opt-out.
-eforms honour the option in both directions.xmd teston a file and on a directory, both directions.documents proven to have run.
--no-secret-detection.on,
--journalis written and the offending event is absent from the file; with theopt-out, the same document writes that event. The option changed what persisted, not
merely whether an error was printed.
--secret-detection=falseand--no-secret-detection=trueare refused.Mutation evidence
Applied to a file copy of the implementation, focused suite run, reddening tests
recorded, then restored. All six killed:
secretDetectionfrom theexecute()callrunDocument, per document--no-secret-detectionas an alias--secret-detection=falseCompiled-binary coverage
A new step in the
smokejob runs./dist/xmdfor all three behaviours — default-onrefusal, the opt-out with the warning counted exactly once, and the refused value form —
with the canary assembled in the step. Run locally against a real
deno task buildbinary as well; all three pass.
Local gates
deno task fmt/lint— 0 errors (1097 pre-existing warnings, unchanged)deno task check— cleandeno task test— 351 passed, 0 faileddeno task check:jsr—Success Dry run completepnpm exec tsc --project tsconfig.node.json --noEmit— cleandeno task build+ the compiled opt-out smoke — passgit diff --check— clean;packages/cli/src/node.tsstill 755 in tree and indexScope
Included
--no-secret-detectiononrunandtest, threaded toexecute().=value form.Intentionally unchanged
durable-stream guard, and snapshot behaviour — all from 💥 Reject secrets before the journal by default #329.
slice.
Risks and limitations
for. It is host-only: no document, prop, or frontmatter can reach it.
--secret-detection=falseis a new error for a form that previouslyparsed silently. It never worked as written — it resolved to enabled — so nothing that
relied on it was getting what it asked for.
Scope confirmation