Repository navigation
Description
Two merged phases now contradict each other on main. Latent today because no spawn thread factory is registered, and a guaranteed false positive the moment phase 9 registers one.
The contradiction
Phase 5, servers/thread-registry.ts:128-130, treats a non-empty cmd as evidence that an architect row is terminal-backed:
if (row.thread_id !== null && (
row.terminal_id !== null || row.pid !== 0 || row.port !== 0 || row.cmd !== ''
)) {
signals.push({ code: 'IDENTITY_SHAPE_CONFLICT', ... });Phase 8, db/thread-identity.ts, writes a real cmd for thread-backed architects:
if (architect.threadId) {
return { pid: 0, port: 0, cmd: architect.cmd, terminalId: null, threadId: architect.threadId };
}So every thread-backed architect satisfies the conflict condition and is reported as carrying both shapes, forever, on every read.
How it got here, plainly
This is mine. Reviewing PR #166 I flagged that architectWriteValues discarded the caller cmd for no schema reason, since cmd is NOT NULL and the caller value satisfies it, and status.ts:457 prints cmd=${a.cmd} so a thread-backed architect rendered as cmd=. That reasoning was right about the display and I did not check the detector before asking for the change. The instruction created the contradiction.
It was found from the other end: the phase 5 review lanes flagged that the architect branch of IDENTITY_SHAPE_CONFLICT had no test at all, only the builder branch. The untested branch turned out to be the one that phase 8 had just made unreachable-by-correctness.
Which side should move
The detector, not the writer. pid, port and terminal_id are genuinely PTY-specific — a thread-backed architect has none of them, and 0/0/null are honest sentinels. cmd is not PTY-specific: it is the command the architect was launched with, and that is meaningful for a thread-backed architect too. Treating it as evidence of terminal-backing conflates "how it was started" with "what is holding it".
Fix: drop row.cmd !== '' from the condition, leaving terminal_id, pid and port as the shape test. Then add the architect-branch test that was missing, and verify it fails when the branch is disabled. The builder-branch condition is narrower and is unaffected.
Also worth pinning
Once the condition is corrected, the "half-migrated row" case it exists to catch should get a test with a row that really is half-migrated (thread_id set and terminal_id or a non-zero pid/port), so the narrowed condition is proven to still fire on the case that matters rather than merely stopping the false positive.
Activity
[Spec 146][Phase: phase_5] fix: #170 cmd is not terminal-backed state…
[Spec 146][Phase: phase_5] docs: name the drift pattern, and protect …
[Spec 146][Phase: phase_8] fix: drop the cmd sentinel per #170 and ad…
[Spec 146][Phase: phase_8] test: cover the backup-reuse branch of the…