docs/specifications/service-layer.md documents the fixed order as permission check → mutate → logAudit → any other required side effect. In practice, nearly every write service function does logAudit last, after its other side effects, not third — consistently, across files:
documents.ts createDocument: mutate (:175-186) → recordCatalogDocumentCreated (:188-196) → access grant (:198-204) → logAudit (:206)
collections.ts createCollection: mutate (:124-130) → recordCatalogCollectionCreated (:132-138) → grant (:140-145) → logAudit (:147)
records.ts deleteRecord: mutate (:751) → releaseRecordLocator (:757-761) → logAudit (:762)
This is internally consistent across the codebase, so it reads as the spec's wording being imprecise rather than N independent implementation bugs — correcting the spec's text to describe actual (working, consistent) practice is far cheaper and lower-risk than reordering every write function for a pure documentation mismatch with no behavior change.
Surfaced during the 2026-09-12 architecture audit (code-level scan of src/lib/services).
Done when: service-layer.md's documented order matches actual, verified practice, with no remaining files found to contradict it.
Priority: P2 — documentation accuracy, no behavior change expected (pending the spot-check confirming no real bug exists). Added to 0.5.0 — Stability, Reliability, and QA as part of this release's service-layer consolidation work.
docs/specifications/service-layer.mddocuments the fixed order as permission check → mutate →logAudit→ any other required side effect. In practice, nearly every write service function doeslogAuditlast, after its other side effects, not third — consistently, across files:documents.tscreateDocument: mutate (:175-186) →recordCatalogDocumentCreated(:188-196) → access grant (:198-204) →logAudit(:206)collections.tscreateCollection: mutate (:124-130) →recordCatalogCollectionCreated(:132-138) → grant (:140-145) →logAudit(:147)records.tsdeleteRecord: mutate (:751) →releaseRecordLocator(:757-761) →logAudit(:762)This is internally consistent across the codebase, so it reads as the spec's wording being imprecise rather than N independent implementation bugs — correcting the spec's text to describe actual (working, consistent) practice is far cheaper and lower-risk than reordering every write function for a pure documentation mismatch with no behavior change.
Surfaced during the 2026-09-12 architecture audit (code-level scan of src/lib/services).
service-layer.md's documented order to: permission check → mutate → other required side effects →logAudit(audit last, capturing the fully-completed operation) — or, if there's a real reason audit should come before side effects that the code is currently violating, flag that as a genuine bug instead and fix the code, not the specDone when:
service-layer.md's documented order matches actual, verified practice, with no remaining files found to contradict it.Priority: P2 — documentation accuracy, no behavior change expected (pending the spot-check confirming no real bug exists). Added to 0.5.0 — Stability, Reliability, and QA as part of this release's service-layer consolidation work.