Repository navigation
feat(state): tolerate unknown observed-state fields on rollback - #185
Merged
Merged
Conversation
observed.json is controller-authored and, after a rollback, is read by an older release than the one that wrote it — the documented rollback order drains before restoring the prior pair, so the file on disk carries whatever the newer release added. With DisallowUnknownFields on that path, every additive field was a rollback break: quarantine, a forced capacity-zero recovery pass, and a restarted drain clock. The observed-state reader now ignores unknown keys, top-level and nested, within schemaVersion 1. schemaVersion stays the deliberate compatibility gate for shapes an older release must not trust, the single-JSON-value trailer check still rejects concatenated writes, and operator-authored desired.json keeps strict decoding so a typo fails loudly. Co-Authored-By: Claude Fable 5 <[email protected]>
kyle-sexton
added a commit
that referenced
this pull request
Jul 31, 2026
Beyond the textual conflicts, #185 (merged on main) made observed-state decoding forward-tolerant, which retires the rollback cost this branch documented and pinned. Resolution: TestObservedRejectsATopLevelKeyItDoesNotKnow is removed as superseded by main's TestObservedToleratesFieldsFromANewerRelease; the "Rollback cost of this field" doc subsection now points at the guarantee instead of stating a cost; and the wire test's comment no longer claims the observed reader rejects unknown fields. Co-Authored-By: Claude Fable 5 <[email protected]>
kyle-sexton
added a commit
that referenced
this pull request
Jul 31, 2026
> The rollback-readability tradeoff this PR was deliberately parked on has been > resolved: option 2 of the recorded decision > (<#176 (comment)>) > was chosen, and #185 landed observed-state forward tolerance on `main` first. > This branch now rides that guarantee, so marking it ready no longer accepts > any tradeoff. ## Summary Implements #170. A controller wedged in `phase: draining` recorded only `drainStartedAt` — when the drain began, never why — so diagnosing the incident behind #102 meant source-diving `plan.go`'s quiesce path. `observed.json` now carries `quiesceReason` beside `drainStartedAt`, and omits the key entirely when the controller is not draining. The reason **replaces** the plan's internal `quiescing` boolean rather than sitting beside it, so phase selection reads the same value operators do. That is what keeps the reported reason from ever disagreeing with the decision that produced it. A degraded plan still reports the reason it computed — a controller that is both wedged and degraded is exactly when the reason is wanted. Values name **the branch the plan took**, not the intent behind it: operator-disabled, gaming-mode with active work, gaming-mode host teardown, excess workers that cannot be advertised as burst capacity, and an exhausted advertisement budget. This resolves an objection raised on the issue: an operator setting `temporaryCapacityOverride: 0` converges through the same downscale branch as an automatic downscale (`TestCapacityOverrideZeroIsDataOnlyPause` pins that), so a value implying "operator versus convergence" would misreport it. Naming the mechanism keeps that test true while still letting a reader separate an operator drain from a convergence quiesce, which is what the issue asked for. ## The rollback decision, resolved Adding a top-level key to `observed.json` was originally **not** add-only with respect to rollback readability: the observed reader set `DisallowUnknownFields`, so a controller rolled back to a release predating this field would have quarantined the file, taken a forced capacity-zero recovery pass, and restarted the drain clock #102's watchdog would time against. That was an owner decision, recorded on this PR and kept out of the autonomous merge lane by the draft state. #185 resolved it the durable way: observed-state decoding is now forward-tolerant within `schemaVersion` 1, so an older controller reading an `observed.json` that carries `quiesceReason` simply does not display it — the drain clock and the CLI surfaces are unaffected, and the rollback-readability guarantees in `docs/observability.md` stay true. This PR is genuinely add-only on top of that. Its `TestObservedRejectsATopLevelKeyItDoesNotKnow` — written so that flipping to forward-tolerant decoding is what changes its expectation — was superseded by main's `TestObservedToleratesFieldsFromANewerRelease` and removed in the merge from main. ## Provenance The plan-side implementation originated on `feat/170-quiesce-reason`, pushed by an earlier lane that wound down before review. This branch is that work rebased onto current `main`, independently reviewed in a fresh context, with the compatibility analysis and the documentation of the (since-resolved) tradeoff added here. ## Test plan Full suite green on Windows after merging current `main` (post-#185): `go build ./...`, `go vet ./...`, `gofmt -l ./internal/` (clean), `golangci-lint run --config .golangci.yml` (0 issues), `go test ./...` (all packages ok, 0 failures), markdownlint clean on the touched doc. Reverting the observed-state carry-through in `poll_cadence.go` and `reconciler.go` fails exactly three tests, so the wiring is pinned rather than incidentally covered: - `TestObservedStateRecordsWhyTheControllerDrainsAndClearsItOnRecovery` - `TestObservedStateSeparatesAnOperatorDrainFromAConvergenceQuiesce` - `TestPollCheckpointCarriesTheQuiesceReason` On the wire: `TestObservedQuiesceReasonIsOnTheWireOnlyWhileDraining` asserts the key is present under exactly that name while draining and absent — not empty, not `"none"` — when not, with a round trip proving the persisted key matches the struct tag. Compatibility: covered on `main` by `TestObservedToleratesFieldsFromANewerRelease` and `TestObservedStillRejectsIncompatibleFiles` (#185). Not run locally: the race detector (`-race` requires cgo, unavailable on this host). CI's `go-quality` lane covers it. ## Related Fixes #170. - #185 — the forward-tolerance change this PR merges on top of; it retired the rollback exposure this PR was parked on. - #102 — the parent incident. Its drain-stall watchdog and every policy question inside it stay out of scope; the drain-clock interaction that coupled this field's rollback behavior to that watchdog is defused by #185 for additive fields. - `feat/170-quiesce-reason` — the earlier lane's unreviewed snapshot this supersedes; safe to delete once this merges. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <https://claude.ai/code/session_01RhS3T7ShwJgKTrvk2Mvd3C> Co-authored-by: Claude Fable 5 <[email protected]>
kyle-sexton
added a commit
that referenced
this pull request
Sep 25, 2026
Repo-wide /code-tidying:dissolve-comments pass (strict posture, 2-line budget for kept comments). Every edited file is proven comment-only: Go files by a go/scanner token-stream comparison, shell and PowerShell by the skill's change-shape proof. No code, no renames, directive counts unchanged. Exported GoDoc, build tags, nolint and spellchecker markers untouched. Net -1265 comment lines (~-20k tokens). Rationale removed from comments (recoverable from the cited PRs): - Step watchdog is a coarse backstop behind HTTP/2 pings and TCP keepalive; an abandoned Step forces exit because Go cannot kill a goroutine, and the Scheduled Task restart policy reclaims stepMu. - Retirement and registration-check budgets hold because reconciler.go caps those loops at MaximumConcurrentWorkers; each call spends a full RetryValue budget; rotation stops head-of-line starvation. - Budget basis exists because host AvailablePhysical falls as workers run (vmmem); advertised capacity follows ARC. - Strict observed.json reads turned added fields into quarantine after rollback; schemaVersion is the compatibility gate (#185). - jobs.json loads accept 4x the save cap so over-cap files self-heal (#70); completed records fill the cap before retention (#107). - CreateMutexW ERROR_ALREADY_EXISTS is success; the opened mutex keeps its creator's DACL. - Worker hook writes to /proc/1/fd/1 so the marker lands as one atomic write in Docker's log pipe (#134); worker scripts avoid forks (#345). - A held repository pin needs a reviewed drift-review entry (#223). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KAK3bULeJAvdzAb4mL5j7k
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes observed-state decoding forward-tolerant, engineering away the
rollback-compatibility hazard #176 was deliberately parked on (recorded as
option 2 of the decision in
#176 (comment)).
observed.jsonis controller-authored and, after a rollback, is read by anolder release than the one that wrote it — the documented rollback order
drains before restoring the prior pair, so the file on disk at that moment
carries whatever the newer release added. With
DisallowUnknownFieldson thatpath, every additive observed-state field was a rollback break: the reconciler
quarantined the file, took a forced capacity-zero recovery pass, and — because
quarantine zeroes
previous— restarted the drain clock #102's watchdog wouldtime against. The four CLI load sites in
internal/app/app.gothat share theloader failed or read zero values until the controller rewrote the file.
The observed-state reader now ignores JSON keys it does not know, top-level and
nested, within
schemaVersion1. Scope and what deliberately does notchange:
desired.jsonstays strict. It is operator-intent, the one state file ahuman may hand-edit during an incident; a typo there should fail loudly, not
silently drop a field.
TestStoreRejectsUnknownFieldsAndMultipleValuescontinues to pin that.
schemaVersionstays the compatibility gate. Additive fields keepversion 1 and are tolerated; a shape an older release genuinely cannot be
trusted to read bumps the version, and an unsupported version is still
rejected — there, quarantine is the intended outcome.
still rejected, so tolerance does not weaken corruption detection for
concatenated writes.
restart-completed.jsonstays strict. It is controller-authored too, butit is a short-lived receipt consumed across a single restart, has never
gained a field, and widening its decode posture deserves its own analysis if
it ever does.
docs/observability.mdgains an "Observed-state rollback readability" sectionstating the guarantee, which holds for rollbacks to any release carrying this
change. The existing "rollback-readable observed-state shape" language in that
document stays true.
Test plan
Full suite green on Windows:
go build ./...,go vet ./...,gofmt -l ./internal/(clean),golangci-lint run --config .golangci.yml(0 issues),
go test ./...(all packages ok). markdownlint clean on thetouched doc. Not run locally: the race detector (
-racerequires cgo,unavailable on this host); CI's go-quality lane covers it.
New pins:
TestObservedToleratesFieldsFromANewerRelease— saves a draining observedstate, injects an unknown top-level key and an unknown nested pool key, and
asserts the load succeeds with phase,
drainStartedAt, and the pool entryintact — the drain clock surviving unknown keys is the point.
TestObservedStillRejectsIncompatibleFiles— asserts aschemaVersionbumpand a trailing JSON value are still rejected, naming the failure.
Related
No linked issue — this implements option 2 of the decision recorded on #176;
per repo process this lane does not file issues.
change, and its
TestObservedRejectsATopLevelKeyItDoesNotKnowis the strictpin this PR's tolerance pin supersedes.
drain clock consequential.
🤖 Generated with Claude Code