fix(auth,memory): audit logging, tier transitions, tests (#1723)#1797
Merged
corvid-agent merged 11 commits intomainfrom Apr 2, 2026
Merged
fix(auth,memory): audit logging, tier transitions, tests (#1723)#1797corvid-agent merged 11 commits intomainfrom
corvid-agent merged 11 commits intomainfrom
Conversation
When recording a failed auth attempt to the audit database fails, the catch block was silently swallowing the error with only a comment. This meant that if the audit record failed to persist (DB connection issue, schema mismatch, etc.), there was zero visibility — no log line, no metric, nothing. Security forensics could be blind to audit failures. Now we log a warning when the audit record fails while preserving the best-effort semantics (the rejection still happens, auditing is not blocking). Fixes silent error in server/middleware/auth.ts:247. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Adds a test that mocks recordAudit to throw, exercising the catch branch in checkHttpAuth that logs audit failures. Fixes codecov/patch check on PR #1781. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove unused spyOn import (TS6133) and fix mock.module restore in auth-middleware test. The previous restore called require() which returned the already-mocked module, poisoning 369 downstream tests. Now saves a reference to the real module before mocking. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The 'still rejects when audit logging throws' test used mock.module to replace ../db/audit with a throwing stub. Bun's mock.module is persistent across test files, so the mock leaked and caused every subsequent test calling recordAudit to throw "DB connection lost". The auth rejection (403) behavior is already covered by the existing test above. The catch path is a trivial log.warn that cannot alter the response, so removing this test loses no meaningful coverage. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds a test that mocks recordAudit to throw, exercising the catch block that logs a warning when audit recording fails. Fixes codecov/patch. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…variants Part of issue #1723 step 5 & 6 (non-governed files only): - graduation-service.ts: add `from: 'short_term', to: 'long_term'` fields to the 'Observation graduated to long-term memory' log for audit consistency - specs/memory/memory.spec.md: add invariants 26 (tier label accuracy) and 27 (tier transition audit log) to document the correct labeling and audit requirements Note: memory.ts (Layer 1) changes are documented in PR description only. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…1723 steps 5 & 6) - Fix chainTag labels in handleRecallMemory to show correct tier names: short-term, long-term, permanent instead of generic on-chain/sync-failed - Fix search and list tag logic to use same tier labels - Add Memory tier transition audit log.info calls in handlePromoteMemory (ARC-69 path and plain-txn path) and handleDeleteMemory (soft/hard modes) - Resolves the governed file changes described in PR #1783 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add handleDeleteMemory tests (soft/hard delete, error cases) - Add tier label tests for recall by key: short-term, long-term, pending - Add tier label tests for search: [short-term], [long-term, ASA: X] - Add tier label tests for list: [short-term], [long-term, ASA: X], [permanent] - Import handleDeleteMemory and updateMemoryStatus in test file Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Resolve conflicts in auth-middleware and tool-handlers tests; drop duplicate handleDeleteMemory block. Made-with: Cursor
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…for work tasks - resumeExpiredThreadSession: resolve project from thread projectName before agent default - handleCreateWorkTask: use session.projectId when project_id/name omitted - Specs + test coverage Made-with: Cursor
Collaborator
Author
Follow-up: project context on Discord resume / work tasksCommit
Specs + unit test updated. Pushed to |
Collaborator
Author
|
Squash-merged to |
This was referenced Apr 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
memory.ts; tests for tier labels, delete, and audit log paths.mock.moduleleak that broke the suite; Biome lint fixes in test files.Related: issue #1723 (memory tier / audit work).
Verification
bun run lintbun x tsc --noEmit --skipLibCheckbun testbun run spec:checkMade with Cursor