Commit Graph

371 Commits

Author SHA1 Message Date
15e90820d2 feat(core-eslint): no-undeclared-audit rule
AST-aware ESLint rule that catches auditLog.record({ type: "X" }) calls
in use-case files where X is not declared in the matching
manifest.useCases[name].audits array.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-12 23:51:42 +02:00
3e2b096c3c feat(core-eslint): no-undeclared-event-publish rule
AST-aware ESLint rule that catches bus.publish("X") calls in use-case
files where X is not declared in the matching manifest.useCases[name].publishes array.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-12 23:51:06 +02:00
21a6822d55 feat(core-eslint): use-case name helper (file slug → manifest key) 2026-05-12 23:49:32 +02:00
7cfb78b99e feat(core-eslint): manifest AST parser for per-use-case attributes 2026-05-12 23:49:12 +02:00
b9ac64b36b feat(core-eslint): register conformance plugin + structural rules in base config 2026-05-12 23:24:01 +02:00
8a2c8db955 feat(core-eslint): conformance plugin module + ./plugin export 2026-05-12 23:23:20 +02:00
3117df1c14 feat(core-eslint): required-cores-installed rule 2026-05-12 23:22:43 +02:00
d585b59590 feat(core-eslint): usecase-must-have-test-file rule 2026-05-12 23:21:38 +02:00
b7bb37023f feat(core-eslint): feature-must-have-manifest rule
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-12 23:20:37 +02:00
6f8e75accb feat(core-eslint): workspace helper for conformance rules 2026-05-12 23:19:11 +02:00
41ffe9f787 feat(core-eslint): manifest source helper for conformance rules
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-12 23:18:02 +02:00
83f135b5e1 fix(conformance): withCapture propagates inner brands + chain test + docstring fixes 2026-05-12 23:00:50 +02:00
3a6115924b feat(auth): bindProductionAuth self-asserts conformance at tail
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-12 22:53:06 +02:00
5e32074c2e feat(core-shared/conformance): assertFeatureConformance helper
Adds boot-time check that every manifest-declared use case is bound
through withSpan (__instrumented) + withCapture (__captured), with
withAudit (__audited) enforced when audits[] is non-empty. Propagates
inner brands through withSpan so the outermost container-resolved
binding carries all brand markers.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-12 22:49:18 +02:00
bbd9c1e856 feat(core-shared/conformance): re-export ConformanceError 2026-05-12 22:43:57 +02:00
49bd7e0782 feat(core-shared/conformance): ConformanceError class 2026-05-12 22:43:15 +02:00
1d8b30045a feat(core-audit): withAudit wraps and attaches runtime __audited marker 2026-05-12 22:42:16 +02:00
77fddcde78 feat(core-shared/instrumentation): withCapture attaches runtime __captured marker 2026-05-12 22:40:44 +02:00
9e21baf5fb feat(core-shared/instrumentation): withSpan attaches runtime __instrumented marker 2026-05-12 22:39:13 +02:00
a593962b3d feat(core-shared/conformance): runtime brand markers + isX predicates 2026-05-12 22:37:43 +02:00
925f4e4e5b docs(core-audit): TODO breadcrumb for future audit recording automation 2026-05-12 22:35:23 +02:00
8054c125d9 feat(auth): re-export authManifest + AuthManifest from package root 2026-05-12 22:34:38 +02:00
bf3abea776 fix(core-audit): rename unused withAudit test param to _input 2026-05-12 21:52:06 +02:00
17bf9fd0c1 test(auth): assert unwrapped factory rejected at branded slot 2026-05-12 21:49:57 +02:00
db646c22e4 feat(auth): bind signIn through ProductionUseCase<I, O, M> branded slot
Adds explicit ProductionUseCase<SignInInput, SignInOutput, AuthManifest["useCases"]["signIn"]>
type annotation to wrappedSignIn in bind-production.ts. To satisfy the Instrumented & Captured
intersection requirement, withSpan gains a brand-preserving overload so composing
withSpan ∘ withCapture returns Instrumented<F> & Captured<F>.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-12 21:46:33 +02:00
5141314a9d feat(auth): declare authManifest with signIn/signUp/signOut 2026-05-12 21:42:55 +02:00
103e06d20a feat(core-audit): withAudit wrapper + Audited<F> brand 2026-05-12 21:41:40 +02:00
c7bd9a2f8a feat(core-shared/conformance): barrel + ./conformance subpath export 2026-05-12 21:37:18 +02:00
82cfde9c93 feat(core-shared/conformance): ProductionUseCase<I, O, M> branded slot type 2026-05-12 21:35:59 +02:00
b3784ce255 feat(core-shared/conformance): defineFeature helper + manifest types 2026-05-12 21:34:19 +02:00
a1fbd16d83 feat(core-shared/instrumentation): withCapture returns Captured<F> 2026-05-12 21:32:42 +02:00
5ac668497f feat(core-shared/instrumentation): withSpan returns Instrumented<F> 2026-05-12 21:29:43 +02:00
5f5db546ae feat(core-shared/conformance): Instrumented<F> and Captured<F> brand types 2026-05-12 21:27:05 +02:00
c06f47b81e feat(core-audit): createAuditAfterReadHook factory for opt-in VIEW capture
Adds the afterRead hook factory for per-collection opt-in automatic VIEW
audit entry emission. Fire-and-forget design ensures failing sinks never
propagate to the user-facing read. Includes sentinel IP/UA fallbacks,
truncateIp /24 integration, shouldSkip predicate, and system actor
resolution. All 6 TDD test cases pass; both barrels updated.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 16:33:59 +02:00
55993a2c93 feat(core-audit): wrap bound auditLog with TraceIdEnrichingAuditLog
bindAudit now wraps the inner sink/fan-out with TraceIdEnrichingAuditLog so
all sinks receive AuditEntry.correlationId auto-populated from the active
OTel span. bind-audit.test.ts assertions updated to check instanceof
TraceIdEnrichingAuditLog first, then .inner for the concrete sink type.
TraceIdEnrichingAuditLog exported from the package barrel.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 16:31:19 +02:00
07548c4620 feat(core-audit): TraceIdEnrichingAuditLog decorator for OTel correlation
Decorator implementing IAuditLog that auto-populates AuditEntry.correlationId
from the active OTel span via currentTraceId(). Caller-supplied correlationId
always wins (explicit > implicit). eraseSubject passes through unmodified.
Adds @opentelemetry/{api,sdk-trace-base,context-async-hooks} as devDeps for
test infrastructure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 16:29:15 +02:00
098fcd0d51 feat(core-shared): currentTraceId helper for OTel-audit correlation bridge
Reads the active OTel span context via trace.getActiveSpan(); returns the
32-char hex traceId or undefined when no span is active or traceId is the
all-zeros invalid value. Re-exported from both instrumentation/otel/index
and instrumentation/index barrels.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 16:27:36 +02:00
131efd5d2f feat(core-audit): admin tRPC procedure for eraseSubject
Adds auditProcedure (adminOnly middleware + defineErrorMiddleware([])) in
core-audit/src/integrations/api/procedures.ts. Adds createAuditRouter that
captures an IAuditLog and exposes a single eraseSubject mutation with zod
input validation. Non-admins receive FORBIDDEN. Barrel re-exports
pseudonymize, createAuditErasureHook, createAuditRouter, auditRouter,
AuditRouter, auditProcedure, AdminTrpcUser. Adds AUDIT_PSEUDONYM_SALT to
turbo.json globalEnv to clear lint warnings.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 16:25:09 +02:00
270897c550 feat(core-audit): createAuditErasureHook Payload afterDelete factory
Adds createAuditErasureHook in core-audit/src/hooks/. The factory returns
a CollectionAfterDeleteHook that calls auditLog.eraseSubject() when a
document is deleted. Defaults to "pseudonymize" mode; coerces numeric ids
to string; skips undefined/null/object ids. Barrel at hooks/index.ts.
6 unit tests cover all guard branches.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 16:23:08 +02:00
18fddcc45f feat(core-audit): PayloadAuditLog.eraseSubject (pseudonymize + delete via overrideAccess)
Replaces the Phase-2 stub with a real impl. Mode "delete" issues a bulk
payload.delete with overrideAccess:true to bypass the append-only rule.
Mode "pseudonymize" fetches up to 10_000 matching docs and patches each
actorId to the token produced by pseudonymize(). Adds 3 eraseSubject unit
tests to the existing payload-audit-log test file.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 16:22:35 +02:00
846b4c2511 feat(core-audit): pseudonymize helper (sha256 + AUDIT_PSEUDONYM_SALT)
Adds `pseudonymize(actorId)` in core-audit — SHA-256 of salt+":"+actorId
truncated to 16 hex chars, prefixed "erased-". Salt from
AUDIT_PSEUDONYM_SALT env (fallback dev label). 6 unit tests: deterministic,
salt-change-differs, fallback-no-throw.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 16:22:30 +02:00
2e5097c457 fix(core-testing): RecordingAuditLog uses inline type alias (boundary: tooling cannot depend on core)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 16:19:15 +02:00
cbde74b7ee feat(core-audit): package barrel exports
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 16:16:44 +02:00
cb285cbd1c feat(core-testing): RecordingAuditLog test double
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 16:15:42 +02:00
683dab691f feat(core-audit): bindAudit binder with sink selection + prod salt validation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 16:14:47 +02:00
7f75f3d56a feat(core-audit): MultiSinkAuditLog fan-out with settle-all + stderr fallback
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 16:13:48 +02:00
fc4e4a1392 feat(core-audit): PayloadAuditLog.record impl (eraseSubject lands in Phase 3)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 16:13:18 +02:00
04c99346c6 feat(core-audit): append-only auditLogs Payload collection
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 16:12:48 +02:00
03e3ef39cd feat(core-audit): StdoutJsonAuditLog impl with audit + audit-erasure markers
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 16:12:18 +02:00
17996e9347 feat(core-audit): NoopAuditLog impl
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 16:11:52 +02:00