fix(#4488): report state update as successful when the value is already correct (#4581)

* fix(#4488): report state update as successful when the value is already correct

`cmdStateUpdate` unconditionally overwrote `updateCore`'s own `updated:true`
signal with `reconcileReportedFields`'s disk-diff result. That diff reports
`[]` -- by design -- whenever `readModifyWriteStateMd`'s #948 no-op guard
fires because the transform's output was byte-identical to the input, which
happens precisely when the requested value already equals what's on disk.
The field genuinely was found and matched; there was simply nothing left to
change. Collapsing that into the same `false`/"not found" response as a
genuine miss produced an actively wrong diagnostic message and a silent
same-day no-op in gsd-ship + gsd-extract-learnings, which both write
`Last Activity` to today's date.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* docs(#4488): backfill changeset pr number to 4581

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

* fix(#4488): untrack tdd-red-evidence.cjs, completing its ADR-457 gitignore migration

Bundled discovery from this PR's own CI run: tests/lint-compiled-artifact-
sync.test.cjs's full tsc compile (which runs whenever ANY compiled artifact
remains tracked) SIGTERM'd under shard contention. gsd-core/bin/lib/tdd-red-
evidence.cjs (introduced by #3770/PR #4279) was the sole remaining tracked
artifact -- a tenth, later, separate instance of the #2657/#2653
migration-gap defect class this test file's closed nine-item list doesn't
cover. Untracked it and added the .gitignore entry, same fix shape as the
original nine. This eliminates the slow tsc-compile path entirely (verified:
0.1s vs ~7s locally) rather than papering over a timeout. Added a generic
regression test asserting the tracked set is fully empty.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

---------

Co-authored-by: sim <sim@local>
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-09-09 18:32:54 -04:00
committed by GitHub
parent 615b74ff45
commit 7fe440a838
6 changed files with 221 additions and 142 deletions

View File

@@ -186,17 +186,50 @@ describe('fix-2657: compiled .cjs artifacts are gitignored, not tracked (ADR-457
// #4093 CI: this spawn is NOT the PROBE class the shared default below
// describes. The script's "nothing left to check" path still runs a FULL
// `tsc -p tsconfig.build.json` compile to a throwaway outDir whenever any
// compiled artifact remains tracked (ten are, deliberately — ADR-457's
// staged end state), and under CI shard load that compile can exceed the
// 15s probe budget, dying to a SIGTERM with empty piped stdout (observed
// twice on ubuntu shard 1/3). Per helpers/timeouts.cjs's own rule, a call
// site that genuinely differs from its class — "a real `tsc` compile" —
// keeps its own local constant with its own justifying comment; see
// tests/ensure-runtime-build.test.cjs's BUILD_TIMEOUT_MS for the other
// instance. 60s is that same class, sized for the cold-cache CI case.
// compiled artifact remains tracked, and under CI shard load that compile
// can exceed even a generous budget, dying to a SIGTERM with empty piped
// stdout (observed on ubuntu shard 1/3 both pre- and post-#4488). Per
// helpers/timeouts.cjs's own rule, a call site that genuinely differs from
// its class — "a real `tsc` compile" — keeps its own local constant with
// its own justifying comment; see tests/ensure-runtime-build.test.cjs's
// BUILD_TIMEOUT_MS for the other instance. 60s is that same class, sized
// for the cold-cache CI case.
//
// #4488: as of this fix the tracked set is fully empty (see the
// "fully-empty ADR-457 end state" test above) — trackedCompiledArtifacts()
// returning [] means main() short-circuits at its own line ~98 BEFORE ever
// invoking `compileToTemp()`, so this spawn no longer runs a real tsc
// compile at all. The 60s budget above stays as a guard for whenever a
// future module reintroduces a tracked artifact (re-widening the migration
// gap this whole file exists to catch), not because this run needs it now.
const TSC_COMPILE_TIMEOUT_MS = 60000;
const args = [path.join(REPO_ROOT, 'scripts', 'lint-compiled-artifact-sync.cjs')];
const result = run(process.execPath, args, { timeoutMs: TSC_COMPILE_TIMEOUT_MS });
assert.equal(result.status, 0, describeFailure(process.execPath, args, result));
});
test('trackedCompiledArtifacts() reports the fully-empty ADR-457 end state (#4488)', () => {
// #4488 CI: tdd-red-evidence.cjs (introduced by #3770/PR #4279, AFTER the
// original "nine" this file's other tests pin) was never gitignored —
// a tenth, later instance of the exact #2657/#2653 migration-gap defect
// class, incidentally surfaced by a #4488 CI run timing out on the real
// tsc compile this test's sibling above must run while ANY artifact stays
// tracked. Generic (not tied to the closed NINE_ARTIFACTS list above) so
// it also catches any future module that lands compiled-but-tracked.
let pairs;
try {
pairs = trackedCompiledArtifacts();
} catch (err) {
assert.fail(
`trackedCompiledArtifacts() threw instead of returning a result:\n` +
`${err && err.stack ? err.stack : err}`,
);
}
assert.deepEqual(
pairs,
[],
`expected zero tracked compiled artifacts (ADR-457 end state); still tracked: ` +
`${pairs.map((p) => p.artifact).join(', ') || '(none)'}`,
);
});
});