Skip to content

test(node): make AuditLogger 'log() writes valid JSONL' test hermetic (sable-883t) - #211

Merged
Rome-1 merged 1 commit into
mainfrom
fix/audit-logger-test-hermetic-883t
Jul 28, 2026
Merged

test(node): make AuditLogger 'log() writes valid JSONL' test hermetic (sable-883t)#211
Rome-1 merged 1 commit into
mainfrom
fix/audit-logger-test-hermetic-883t

Conversation

@Rome-1

@Rome-1 Rome-1 commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Problem

The AuditLogger — Error Paths block in node/tests/error-handling-gauntlet.test.ts never mocked ConfigManager. AuditLogger.log() loads the machine-global ~/.rafter/config.json and silently no-ops unless agent.audit.logAllActions is set there. So log() writes valid JSONL entry passes or fails depending on the box's global config — non-hermetic. On this dev box (~/.rafter/config.json exists but omits the flag) it was failing.

Fix

  • Mock ConfigManager.prototype.load to return logAllActions: true in the block's beforeEach, and vi.restoreAllMocks() in afterEach. This mirrors the existing pattern in node/tests/audit-logger.test.ts and brings Node to parity with the already-hermetic Python test_log_writes_valid_jsonl.
  • Annotate the pre-existing implicit-any .mock.calls callbacks in the same file (surfaced by the language server while editing).

Verification

  • npx vitest run tests/error-handling-gauntlet.test.ts58/58 pass.
  • npx tsc --noEmit -p tsconfig.json0 errors.
  • Confirmed this box's ~/.rafter/config.json lacks logAllActions, so the target test was genuinely failing here before the change and passes after.

Parity

Python side already mocks config in its mirror test — no Python change needed.

Fixes sable-883t. Test-only; no runtime behavior change.

The gauntlet's 'AuditLogger — Error Paths' block never mocked ConfigManager,
so AuditLogger.log() read the machine-global ~/.rafter/config.json and
silently no-opped unless agent.audit.logAllActions happened to be set there.
On a box whose global config omits the flag, 'log() writes valid JSONL entry'
failed; on one that has it, it passed — a non-hermetic, machine-dependent test.

Mock ConfigManager.prototype.load to return logAllActions: true in the block's
beforeEach (mirroring node/tests/audit-logger.test.ts and the already-hermetic
Python test_log_writes_valid_jsonl), and restore mocks in afterEach. Also
annotate the pre-existing implicit-any .mock.calls callbacks surfaced while here.

Fixes sable-883t.
@Rome-1
Rome-1 merged commit e15f0c7 into main Jul 28, 2026
@Rome-1
Rome-1 deleted the fix/audit-logger-test-hermetic-883t branch July 28, 2026 21:26
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.

1 participant