Skip to content

v7.78.7

Choose a tag to compare

@github-actions github-actions released this 17 Jun 12:00
e0f448e

PR #1245 follow-up — /clear alias and dark-matter-wiring _internals seam

What changed

/clear alias added to CC_COMMAND_MAP (root cause: PR #1245 lost the alias)

PR #1245 introduced CC_COMMAND_MAP in src/commands/conflict-registry.ts as a Map
keyed by the bare CC command name (e.g. plan for /plan, reset for /reset).
The PR removed the hand-maintained 'clear' → 'reset' mapping that the previous
hard-block branch in cc-command-intercept.ts relied on. As a result, /clear
fell through to a warning-only native-command log path instead of being
hard-blocked like /reset.

This follow-up registers clear as an explicit alias key in CC_COMMAND_MAP
during the existing initialization loop, pointing to the same CommandConflict
entry as reset. The misleading comment in cc-command-intercept.ts:138
("CC_COMMAND_MAP handles both direct commands and aliases like /clear → /reset")
has been corrected to reflect what the map actually does.

_internals DI seam in system-enhancer.ts (root cause: PR #1245's test refactor didn't take effect)

PR #1245 migrated tests/integration/dark-matter-wiring.test.ts from
mock.module() to _internals DI seam mutation. The migration didn't work:
10 of 14 tests failed because system-enhancer.ts imported the named
functions (detectDarkMatter, formatDarkMatterOutput, etc.) which are bound
at module load time. Mutating _internals.detectDarkMatter only changes the
seam object's property, not the named export reference, so the production
code kept calling the original implementation.

This follow-up refactors system-enhancer.ts to import _internals as coChangeInternals and _internals as knowledgeStoreInternals and call them at
call time (coChangeInternals.detectDarkMatter(...) instead of
detectDarkMatter(...)). The named-export-to-seam indirection was the missing
piece of the active-seam pattern that the migration intended. This eliminates
the cross-test pollution that mock.module() would have caused without
regressing the test's mock-via-seam intent.

The dark-matter-wiring.test.ts file also had a broken test design: mocks
were applied at module load but the afterEach restored the originals,
leaving only the first test in the file with the mocks. This follow-up
removes the per-test restoration and uses process.on('exit') for file-exit
teardown so the seam mocks persist for the file's tests but don't leak
into other test files.

Adversarial tests for /clear interception

Added 4 new adversarial tests in
tests/adversarial/cc-command-intercept.adversarial.test.ts to guard against
the /clear regression:

  • /clear is hard-blocked as alias for /reset
  • /CLEAR (uppercase) is hard-blocked
  • /clear with leading whitespace is hard-blocked
  • Triple-backtick block containing /clear is NOT detected (preserves the
    code-fence escape behavior)

Why

PR #1245 was a Copilot bot PR that intended to:

  1. Wire CC_COMMAND_MAP for case-insensitive and whitespace-padded detection
  2. Replace hardcoded tool count assertions
  3. Eliminate mock.module() cross-test contamination

Items 1 and 3 had regressions introduced by the change:

  • Item 1 lost the /clear alias handling
  • Item 3's test refactor didn't actually take effect because the production
    code didn't use active seams

This follow-up preserves the PR's stated intent (per the writing-tests skill
Invariant 7 — DI seam over mock.module) while fixing the regressions that
the local /swarm-pr-review identified.

Migration

No user-facing migration needed. All changes are internal.

Invariant audit

  • 1 (plugin init): not touched — system-enhancer.ts refactor changes only
    how functions are read (static import of _internals vs named exports);
    no new I/O, no new computation at init time. Plugin loads in bounded
    time: node --input-type=module -e "await import('./dist/index.js')"
    returns PLUGIN LOADS OK (exit 0).
  • 2 (runtime portability): not touched — no new bun: imports, no changes
    to default export shape, no new top-level awaits.
  • 3 (subprocesses): not touched — no spawn/exec/subprocess changes.
  • 4 (.swarm containment): not touched — no new .swarm/ paths written.
  • 5 (plan durability): not touched — no plan schema or status-shape
    changes.
  • 6 (test_runner safety): not touched — focused test files used for
    validation, no broad test_runner scopes.
  • 7 (test writing): touched — tests/integration/dark-matter-wiring.test.ts
    uses _internals DI seam per the writing-tests skill Invariant 7.
    tests/adversarial/cc-command-intercept.adversarial.test.ts uses
    bun:test. No mock.module introduced. Confirmed by direct
    file reads and test execution.
  • 8 (session state): not touched.
  • 9 (guardrails/retry): touched — cc-command-intercept.ts hard-block
    branch for bareCmd === 'clear' is now reachable (was dead code
    before this fix). Verified by adversarial test
    "ADVERSARIAL: cc-command-intercept hook evasion tests > ATTACK VECTOR:
    /clear alias for /reset (PR #1245 regression guard) > /clear is
    hard-blocked as alias for /reset".
  • 10 (chat/system msg): not touched.
  • 11 (tool registration): not touched — no new tools registered; only
    the CC_COMMAND_MAP initialization loop (which builds a lookup
    table for the existing cc-command-intercept hook) was extended.
  • 12 (release/cache): touched — release fragment created (this file).
    dist/ not committed. No version files hand-edited.

Test plan

  • bun test tests/integration/dark-matter-wiring.test.ts — 14 pass / 0
    fail (was 10 pass / 4 fail before this fix)
  • bun test tests/adversarial/cc-command-intercept.adversarial.test.ts
    — 28 pass / 0 fail (was 24 pass / 0 fail before this fix; 4 new
    /clear tests added)
  • bun test tests/adversarial/architect-check-gate-status-whitelist.adversarial.test.ts
    — 39 pass / 0 fail (PR #1245 Category 2 test, unchanged)
  • bun test tests/unit/commands/dark-matter.test.ts + dark-matter.adversarial.test.ts + dark-matter.knowledge-persistence.test.ts
    — 46 pass / 0 fail (system-enhancer consumers, unchanged)
  • bun test tests/adversarial/handoff-security-adversarial.test.ts
    (system-enhancer consumer) all pass
  • bun test tests/integration/retrospective-gate.test.ts
    (system-enhancer consumer) all pass
  • bun run typecheck — exit 0 (tsc --noEmit clean)
  • bunx biome check . — 0 errors (2 pre-existing warnings in
    tests/unit/turbo/lean/runner-parenting.test.ts unrelated to
    this change)
  • node --input-type=module -e "await import('./dist/index.js')"
    PLUGIN LOADS OK (exit 0)
  • bun run build — exit 0 (5.0 MB index.js, 2.26 MB CLI index.js,
    20 grammar files copied to dist/lang/grammars/)

Pre-existing failures (unrelated, in scope for separate fix)

  • tests/unit/commands/simulate.test.ts: pre-existing
    SyntaxError: Export named '_internals' not found in module 'src/tools/co-change-analyzer.ts'.
    This is because src/commands/simulate.ts:1 imports _internals but
    the test's mock.module(...) factory only provides detectDarkMatter.
    The same _internals DI seam pattern that this PR applies to
    dark-matter-wiring.test.ts would also fix this — add
    _internals: { detectDarkMatter: mockDetectDarkMatter } to the
    mock factory. Out of scope for this PR which targets the specific
    regressions the local /swarm-pr-review identified.
  • tests/integration/pre-check-batch.test.ts: 2 pre-existing failures
    related to lint/sast_scan tools not being installed in the local
    environment (consistent with the pre-flight advisory about missing
    ruff/cargo/etc. binaries). Unrelated to this change.
  • tests/unit/commands/ and other directories: ~158 pre-existing
    failures verified to exist on the PR's HEAD before this change via
    git stash baseline comparison. Unrelated to this change.

7.78.7 (2026-06-17)

Bug Fixes

  • resolve 106 pre-existing test failures across three categories (#1245) (5a6cee1)

This PR was generated with Release Please. See documentation.