DUNIN7 · LOOMWORKS · RECORD
record.dunin7.com
Status Current
Path change-requests/cr-2026-171-loomworks-small-work-sweep-engine-v0_1.md

DUNIN7-M4 — INFRASTRUCTURE CHANGE REQUEST

CR-2026-171 — Small-work sweep: engine cluster (v0.1)

Version. 0.1 Date. 2026-08-06 Author. Claude.ai (drafting) / Marvin Percival (approving). Target. /Users/dunin7/loomworks-engine, branch main. Baseline reference. main HEAD 1706248b626255c09673e9165e8e82030bb7b767 (2026-08-05T20:33:41-04:00), confirmed clean tree at Step 0 inspection. Priority. Standard. Confidential. Internal DUNIN7. Companion to. inspection-briefs/loomworks-small-work-sweep-step-0-inspection-brief-v0_1.md; inspection-briefs/loomworks-small-work-sweep-step-0-findings-v0_1.md (the evidence baseline for every item below — file/line citations are not repeated here); current-status/dunin7-status-brief-v0_36; standing-notes/dunin7-build-list-v0_29. Charter. standing-notes/dunin7-standing-authorization-charter-v0_1. Autonomous regime in effect — this CR does not require a pre-execution Operator halt beyond the checkpoint named in §4. Status. Ready for CC execution. CR number. 171 is a best-guess next slot — the highest confirmed number visible from here is CR-2026-170 (B-8 slice one). Claude.ai cannot read the record's CR ledger directly; CC should confirm no collision before filing and renumber if one exists. Supersedes. None — first CR drawn from the sweep.


1. Executive summary

Four small, engine-only fixes, each diagnosed to one file (B-54 is one migration, gated on a self-contained safety check). No new mechanism, no design decision — every fix reuses a pattern that already exists and is already proven elsewhere in the codebase.


2. Scope — four items

2.1 B-53 — render list never returns its own sequence number

Fix. Add display_number to the SELECT at render_events_view_query.py:109-122.

Test. Extend tests/test_list_loading_renders.py — assert display_number is present and correct in the list response body, for both a backfilled row and a freshly-produced row.

2.2 B-54 — nothing requires the number to exist

Fix. Migration tightening display_number to NOT NULL on both the render and shape views, gated on Step 1's safety check below.

Step 1 — production safety check (read-only). COUNT(*) WHERE display_number IS NULL against playground_dev. If this build session holds query authority under the charter, run it directly; if not, the Operator runs this one query and reports the count back before Step 2 proceeds. If the count is nonzero for either table, halt — the row(s) need backfilling first, which is a new sub-step, not a design change, and does not block the rest of this CR.

Test. Migration test asserting an insert with a null display_number now fails at the database level.

2.3 B-35 — a missing key reports a crash instead of "service unavailable"

Fix. Change the NoCredentialError exception handler at api/errors.py:164-166 from HTTP 500 to HTTP 503, matching the pattern already used at deps.py:252-266 and every other "no key reachable" path in the engine.

Test. A new test that exercises the unconfigured-system-key path through the actual router — not through the dependency override conftest.py:660 / test_auth_dev.py:99 currently force — asserting 503, not 500.

2.4 B-44 — shapes read back untitled almost always

Fix. Swap get_shape_event_titleresolve_shape_event_titles in get_shape_event_route (shape_events.py:493), and swap get_shape_event_titles_for_engagementresolve_shape_event_titles in list_shape_events_route (shape_events.py:441). No new function — resolve_shape_event_titles already exists and is already proven via the render path.

Test. A shape with no operator-set title but with markdown-heading content in its confirmed version now returns a derived title (not None) from both the single-read and the list route.


3. Explicitly out of scope

Per the findings document's §6, these are confirmed engine-touching but not small, and do not belong in this CR:

None of the three is absorbed here. Each needs its own scoping note before a CR.

Also deliberately excluded, by the findings document's own discipline. The Step 0 inspection found that the Shape-list SELECT has the identical display_number omission as B-53 (shape_events_view_query.py:109-133), read via row.get("display_number") at shape_events.py:150. This is not a named build-list item, so it is not folded into B-53's scope here — absorbing unscoped work into a CR drawn from an inspection is exactly what the charter's fence is for. Recommend adding this as its own build-list item (call it, e.g., B-59) before it is built.


4. Build steps

| Step | What | Mode | |---|---|---| | 0 | Pre-flight — confirm main matches baseline HEAD above; confirm tree clean. | Auto | | 1 | B-54's safety check (read-only count query; §2.2). Halt-and-report if either count is nonzero. | Auto, conditional halt | | 2 | B-53 fix + test. | Auto | | 3 | B-54 migration + test (only if Step 1 cleared). | Auto | | 4 | B-35 fix + test. | Auto | | 5 | B-44 fix + test. | Auto | | 6 | Full engine test sweep. No regressions. | Auto | | A | Checkpoint — Operator confirms before tag. | Checkpoint | | 7 | Tag cr-2026-171-small-work-sweep-engine. Push. | Auto (post-checkpoint) |


5. Acceptance gate

  1. All four items' new/extended tests pass.
  2. Full existing suite green, no regressions.
  3. display_number present in every render-list response body.
  4. NoCredentialError path returns 503 with the standard message shape, matching sibling paths.
  5. Shape single-read and list routes return derived titles when no stored title exists.
  6. B-54's NOT NULL lands only if the safety check cleared; otherwise Step 3 is skipped and reported as a residue for a follow-on migration, not silently dropped.

6. Post-CR state

Four defects closed. One migration (conditional), three code fixes, four to six new/extended tests. No frontend change — the surface cluster is CR-2026-172, filed separately. Alembic head advances by one only if B-54's Step 3 ran.


7. Kickoff prompt for the Claude Code session


Read the Change Request at the path I supply below. This is CR-2026-171
v0.1, the small-work sweep's engine cluster. You are the executing agent.
Confirm the CR number against the record's ledger before filing; renumber
if 171 collides with something already filed.

CR path: ~/Downloads/cr-2026-171-loomworks-small-work-sweep-engine-v0_1.md

Four small engine fixes: B-53 (render list missing display_number),
B-54 (NOT NULL on display_number, gated on a safety check), B-35
(NoCredentialError returns 500 instead of 503), B-44 (shape titles
never derive when unset).

Baseline: engine main at 1706248b626255c09673e9165e8e82030bb7b767,
confirmed clean.

Run Step 0 pre-flight, then Step 1's safety check before touching
B-54. If the safety check finds any NULL display_number row, halt
and report — do not proceed with the NOT NULL migration; note it as
a residue instead.

Steps 2, 4, 5 have no design decisions open; implement per the CR's
§2. Each reuses a pattern already proven elsewhere in the codebase.

Full test sweep at Step 6. Checkpoint before tagging.

Also note in your report back: the Shape-list SELECT has the same
display_number omission as B-53 (shape_events_view_query.py:109-133)
but is deliberately out of scope here per §3 — flag it for the
Operator to add to the build list, do not fix it in this CR.

DUNIN7 — Done In Seven LLC — Miami, Florida CR-2026-171 — Small-work sweep: engine cluster — v0.1 — 2026-08-06