service-layer.md documents permission → mutate → audit → side effects, but actual code consistently does audit last

Open Beginner friendly
#267 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript
Domain
documentation

Research direction

Start with docs/specifications/service-layer.md and compare its ordering statement with the cited functions in src/lib/services/documents.ts, collections.ts, and records.ts. Spot-check additional write services to verify the audit-last pattern, then update the specification and confirm no reviewed service contradicts it.

Written by the indexing model from the issue text.

Description

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).

  • Update 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 spec
  • Spot-check a few more service functions beyond the three cited here to confirm the "audit last" pattern holds broadly before finalizing the spec wording

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.

Dominant language
TypeScript
Stars
1
Forks
1
Avg merge
3h 53m
Merged PRs (30d)
124

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from brylie/compendium

All issues in brylie/compendium

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.