[PR #66·#67] Built Admin Customer Access Paths and Filled in the Decision Log
- What changed: Built eight server paths the admin web uses. They set which units a customer can use, add people to a unit, and set a planned date. In the follow-up PR #67, two decisions the owner made were copied into the decision log document.
- Decision: When an assignment is removed, its row is kept and only the cancel time is recorded. Claude chose this approach while implementing.
- Still unknown: How the result value in the audit log should be spelled (
successorok) is not decided yet, so it was left as it is.
What we did and why
Claude built eight server paths for the admin web. Every path sits behind an admin login check and an Origin check. The Origin check blocks requests sent from other sites.
A request that changes a customer’s access replaces the whole list of units that customer can use. A removed assignment is not deleted. Only its cancel time (revoked_at) is filled in. Access is read from the database on every request, so a cancelled unit is blocked right away (403 response).
Every write runs in one transaction (a group of changes that either all happen or all fail together). The same transaction writes one line to the change history (audit_logs). If the history write fails, the change is rolled back too.
Planned dates accept only real calendar dates. For example, 2027-02-30 is rejected.
PR #67 changed documents only, not code. It copied two decisions into the decision log table, one line each. One records a one-time allowance for editing a test file during the work. The other records that a change to the audit log’s spelling is postponed.
Approaches chosen and rejected
- Two requests changing the same customer and unit at once: The customer row and the unit row are locked (
FOR UPDATE, a lock that makes other requests wait until it ends), so they run one after another. A duplicate-assignment violation (23505) is also turned into an “already assigned” answer. We rejected relying only on database constraints without a lock. - Listing: Three queries (units, planned dates, accounts) are fetched separately and merged in memory. One combined join would repeat accounts across many rows.
- Write style: Query builder statements (
UPDATE,INSERT). Raw queries that return values were not used. - Malformed lookup values: Answered with a 400 (
invalid_request) instead of an empty list. The spec does not cover this, so Claude guessed it, and that guess needs confirmation.
How we checked
- Ran the full check (
npm run verify). The Docker daemon was off, so it was started first. - The first implementation commit had three failing tests. The cause was in the tests. They sent a second assignment for the same customer and unit and expected success (204), but the spec says that case should return 409 “already assigned.”
- The owner said that if a test is wrong, fix it and explain why. Claude changed only those three tests so the two calls use different units, and left the implementation code as it was. After that, all 316 tests passed.
- However, the implementer editing a test file directly broke this work’s rules. The owner allowed that exception once, and the exception is recorded in the decision log.
Lessons
- When the one who implements also edits the tests, the check stops really checking the implementation. If a test looks wrong, the rule is to raise it as a question instead of changing it.
- When the same rule is written in more than one place, a test run exposes the contradiction.
- Decisions belong in the decision log document, not only in a working status note, so they survive after the work ends.