test(workspace): add 26-case coverage for molecule_audit.hooks (closes #368) #487

Closed
fullstack-engineer wants to merge 1 commits from fix/368-audit-hooks-coverage into staging

1 Commits

Author SHA1 Message Date
ea2e73326f test(workspace): add 26-case coverage for molecule_audit.hooks (closes #368)
Some checks failed
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 2s
sop-tier-check / tier-check (pull_request) Failing after 2s
audit-force-merge / audit (pull_request) Has been skipped
Added TestLedgerHooksExtended with 26 new test cases covering all
previously-uncovered branches in molecule_audit.hooks:

- _to_bytes: None, bytes passthrough, str→utf8, dict→JSON (sort_keys),
  list→JSON
- _DEFAULT_AGENT_ID: env var default, explicit override
- Session lifecycle: lazy open, session reuse, close when None,
  __exit__ releases on exception
- on_task_start: None input, risk_flag=True, oversight override
- on_llm_call: None input+output, risk_flag=True
- on_tool_call: bytes input (hash matches), None i/o, risk_flag=True
- on_task_end: None output, risk_flag=True, oversight override
- _safe_append: exception swallowed and logged as warning

All 69 tests in test_audit_ledger.py pass (was 43, +26).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-11 14:23:55 +00:00