gunk-dev/the-valley
the-valley:oc-547a848outcomein-progress

valley checks --build asks the worker for HEAD's checks and waits for the result

State
in progress
Created
2026-11-13 by contributor
Progress
3 of 4 done
Children
Changes
  • valley:the-valley/tysqpkqsmomtvrvxyzpqmmzxlqtoxwxx

Body

`valley checks --build` asks the host's worker for HEAD's required checks and waits: it returns at once when the set is empty or already covered, otherwise pushes a request, follows the worker's telemetry, prints each check passed or failed, deletes its request on exit (interrupt included) and exits non-zero on failure. Passes come from notes; a failed build or batch from the worker's report (oc-c0ba95b). When the worker's status cannot be read it says so and fails without calling any check failed. Needs the host side first.

Comments

  1. contributor2026-11-14 16:27 UTC
    Independent review of the command at 8f827a09 (second model, static): five blockers and four should-fixes. A fix round is under way, client-only. The review:
    
    A fixed policy snapshot can define the requested check set, with origin’s verified coverage providing the completion criterion. Leased request refs and bounded telemetry follows can isolate invocations without a separate client polling loop.
    
    Blocker 1 — status/checkbuild.go:543, 551, 691: remembered passes can produce a false exit 0. The passed map only grows; later coverage reads cannot invalidate it. For example, fast initially verifies under signer A, A’s authorization is revoked while slow builds, and the next coverage read covers only slow. The command retains fast, adds slow, and reports both passed despite its latest verification rejecting fast. The smallest fix is to rebuild current coverage from each evidence response, keeping printing history separate, and require one complete coverage judgment for success.
    
    Blocker 2 — status/checkbuild.go:488, 590, 625: completed or abandoned work can leave an unattended caller waiting forever. Derive fast and slow, then remove slow from policy before the worker scans: the worker publishes fast and ends its pass, but the client keeps renewing follows for slow. A ready-class batch for this tree that repeatedly fails is also ignored as an outcome; its backoff need never produce a request-class batch. Deleting the request during execution can produce a cancelled batch, which is likewise ignored. Global pass.end records are discarded by the project filter before their type is considered.
    
    Limit 2 is not acceptable as shipped. The least client-only correction is to reread coverage at pass completion and exit 1 with an explicit incomplete/unknown outcome when coverage remains insufficient, without calling an unobserved check failed. Because a global pass ending cannot prove this request was assessed, that wording matters. A documented, configurable finite overall wait is also needed when no terminal event arrives. Checking only the project’s main would miss changes to the owning instance’s policy floor; status/worker.go:1986 reads that separately.
    
    Blocker 3 — status/checkbuild.go:589 and 910: producer-side telemetry loss is silently ignored. telemetry/emit.go:149 records lost emissions in data.dropped_before; this is different from the collector’s kind=gap. Suppose the worker fails this request, loses batch.end and its ref-specific backoff emission, and saves the request marker in failures.json. A later pass.end can report dropped_before, but the client ignores it; subsequent worker passes skip the marked request at status/worker.go:1256 and emit no replacement refusal event. The wait never ends. Check dropped_before before project filtering and return unknown after a final coverage read. Retain the finite escape from blocker 2 because the last emissions can all disappear.
    
    Blocker 4 — status/checkbuild.go:629 and 509: another attempt’s failure terminates the new retry. Kill a client while its request batch is running, then invoke the command again at the same HEAD. The new invocation takes its cursor and replaces the old request. Before the worker notices that replacement, the old batch fails; its request-class batch.end matches the tree, so the new invocation exits and deletes its fresh request. The cursor excludes old records, not later records from old attempts.
    
    Limit 1 therefore breaks retry semantics. The smallest client-side restriction is to stop treating an uncorrelated batch failure as this attempt’s terminal outcome; the existing backoff naming this exact request can establish refusal. Reliable per-check attribution needs the request ref and commit in batch records.
    
    Blocker 5 — status/checkbuild.go:473 and 435: interruption during push can leave a request behind after cleanup reports success. CommandContext kills the git process, while Setpgid alone does not arrange cancellation of its SSH and other descendants. Pause receive processing before ref installation, interrupt the client, and let withdrawal list the still-absent ref. Withdrawal returns nil; the surviving transport/server operation can subsequently install the request.
    
    Setting a.ref before pushing is necessary but insufficient. Give an in-flight mutation bounded orderly completion before withdrawal, and cancel its process group when abandoning it. If remote completion remains indeterminate, report cleanup as unknown; one absent listing cannot establish that the interrupted push will never install its ref. Add a test that interrupts while the push is blocked before installation, not after filing.
    
    Should-fix 6 — status/checkbuild.go:234, 268, 282: early exits bypass stale-request recovery. Kill an invocation after filing, let the worker publish all evidence, then run again. The second invocation exits 0 before acquiring the lock or listing the worktree’s old requests, leaving the killed invocation’s request indefinitely. The no-checks and pre-existing-failure paths have the same problem. Under the worktree lock, reconcile requests belonging to an existing worktree token before these early exits, deleting only with their observed leases.
    
    Should-fix 7 — status/checkbuild.go:409: replacement fails at the request bound. With 32 requests already held by the principal, including this worktree’s stale request, the atomic delete-and-create push is rejected: valleyhook/checkrequest.go:67 counts existing requests plus creates without subtracting deletions. Repeated invocations cannot recover automatically. This returns 1 before following telemetry; it is not a hanging path. The smallest client fix is a leased deletion of its stale requests before retrying creation when capacity prevents atomic replacement.
    
    Should-fix 8 — status/checkbuild.go:214: the recovery command discards the deletion lease. If another writer moves the request from HEAD to a different commit, automatic withdrawal correctly refuses. The printed git push origin :ref then instructs the operator to delete that changed request unconditionally. Include the expected-HEAD lease in the suggested command, or direct the operator to inspect the changed ref.
    
    Should-fix 9 — status/checkbuild_test.go:286, 344, 420: several claimed protections are not tested at their boundary. By inspection, removing the check.result tree guard still satisfies TestCheckBuildPasses: the foreign failure arrives before the run is classified as ours and is overwritten by the later passing result. Use a foreign request batch whose failure would otherwise terminate this invocation.
    
    The gap test injects an error from fakeStream; it never exercises sshStream.answer. Removing its actual gap handling would leave that test passing. Add decoder cases for collector gaps, dropped_before, abrupt EOF, and a size-truncated response followed from its returned cursor. The lock test exercises lockWorktree directly; removing its call from asking also leaves that test passing. Exercise overlapping invocations instead. Replacement and withdrawal tests need a ref changed between listing and mutation to demonstrate that their leases matter. The VM subtest does not cover these races or terminal-without-evidence cases.
    
    For the remaining requested checks: the implementation’s project/tree guards reject ordinary other-tree results, and successful ready-class publications trigger coverage rereads. Normal bounded follows and properly terminated size-truncated responses renew from the returned cursor. A stale lock file does not retain flock ownership after process death. This client constructs valid request names, and the current hook rejects malformed names; an existing malformed ref is skipped by the worker without a structured terminal record, so it cannot supply the client’s missing completion signal. The command’s one-second ticker only redraws terminal elapsed time; it does not poll worker state.
    
    A nit at status/checkbuild.go:670: took claims to select the newest passing duration but iterates an unordered map. Two passing runs can therefore display either duration. Track the latest result explicitly or omit the duration when attribution is ambiguous.
    
    This was a static review of the supplied diff against the specified snapshot; I did not execute the added tests.
    
    Blockers: 1–5, with regression tests for those paths. Should-fix: 6–9. Nits: duration selection. The single change that most improves the design is a durable outcome keyed by request ref and commit, with telemetry used to announce when that outcome should be reread.
  2. contributor2026-11-14 17:52 UTC
    Second independent review of the fix round (head 505018cc, run 20261114-1627-590f8fab, 75 min, $17.86). Verdict NOT READY: five blockers again. Change stays a draft; no third client round until the scope is decided.
    
    NOT READY
    
    Blocker 1 — A timed-out final read can still produce passed. At status/checkbuild.go:759, an expired deadline takes precedence over a completed read and calls lastRead. At :782, lastRead discards errInterrupted without invalidating the existing coverage; verdict at :961 then accepts that coverage. Concrete sequence: a publication triggers a complete coverage read just before the deadline; the deadline expires while the cancelled follow finishes; the final read hangs in attest and times out. The command exits 0 using the earlier map, despite its final read establishing nothing. Original blocker 1 remains open. A failed final read must force unknown, regardless of earlier coverage.
    
    Blocker 2 — Real evidence reads still escape cancellation. The context assigned at status/checkbuild.go:254 does not reach every subprocess beneath coverageOf. In the snapshot, status/coverage.go:138 calls listOrigin, and :189 calls fetch; status/changes.go:53 and :74 invoke the rebase engine with context.Background(). Concrete sequence: file the request, begin the next coverage read, and stall its ls-remote or fetch. Neither --wait expiry nor SIGTERM sent to the valley process ends that operation; evidence at status/checkbuild.go:837 waits synchronously, so withdrawal is never reached. The independently bounded final read has the same hole. TestCheckBuildWaitBoundsAHungRead exercises g.program directly and misses these production paths.
    
    The deadline also starts only at status/checkbuild.go:706: the initial evidence read at :328, stale-request reconciliation, preparation, and filing can hang before it exists. Original blocker 2 remains open. Propagate cancellation through the actual coverage helpers and establish a finite bound before the first remote operation.
    
    Blocker 3 — Passing evidence can be reported as a failed check. At status/checkbuild.go:809, every entry in evidence.failed becomes a recorded failure, printed at :341 or :823. However, snapshot status/coverage.go:214 populates that map for any mismatch; mismatch at :403 includes the predicate type, runner, and attribute, not just predicate.result. Concrete sequence: origin holds a verified passing note for fast at attribute old; the owning policy changes fast to attribute new while HEAD remains unchanged. This command prints “fast failed · origin’s evidence records it” before filing anything, although the note records passed and the requested computation has never failed. Preserve the distinction between incompatible evidence and an actual failed result.
    
    Blocker 4 — Attribution checks the request ref but not its commit. At status/checkbuild.go:927, a matching ref is sufficient; workerRecord at :1146 discards the telemetry’s Head field. Concrete sequence: this invocation files R→H; another writer under the same principal changes R→H2, which valleyhook/checkrequest.go:42 permits; the worker builds H2 and fails. Its batch.end has another tree, but its ref-specific backoff still reaches :940 and becomes a refusal of this invocation’s checks. The command reports failed for H, which the worker never assessed. Match the recorded head to the filed commit before accepting either failure or refusal.
    
    The original distinct-ref retry race is closed: the worker serially emits batch.end and the request-specific backoff, and intervening attest records have another Run. The remaining problem is that a ref is mutable.
    
    Blocker 5 — Local push termination is still mistaken for remote settlement. At status/checkbuild.go:577, any push that returns before context cancellation sets pushEnded=true, including a transport failure. Withdrawal at :631 then treats an absent listing as conclusive. Concrete sequence: origin has received the update but is paused before installing it; the transport fails and git exits nonzero during the grace period; withdrawal lists no ref; origin subsequently installs it. The command says the request was not filed and prints no cleanup uncertainty or leased delete. Original blocker 5 remains open for this path. A transport error must remain indeterminate unless receive status establishes the remote outcome. The local pre-receive test cannot establish that guarantee because its receiver belongs to the killed local process group.
    
    Should-fix — The post-filing pass argument has a race. At status/checkbuild.go:392 and :872, a later pass.end is treated as sufficient. In the snapshot, the worker can observe no mark at status/worker.go:894, leave its loop, and pause before saving, acknowledging, and emitting pass.end at status/workertelemetry.go:329. The request can be pushed and the post-push cursor read during that interval. The delayed pass.end then causes unknown and withdrawal without that pass ever seeing the request. This is an avoidable unknown, not independently a false pass or failure. Require an observed post-filing pass start for this early termination, or retain the deadline fallback. The diagnostic at :983 also incorrectly says the pass started after filing.
    
    Should-fix — First-use recovery still races with token creation. At status/checkbuild.go:439, token absence is read before taking the lock; :358 later creates a token without rereading. Concrete sequence: invocation A sees no token and pauses during preparation; B creates token B, files a request, and is killed; A acquires the released lock and replaces token B with token A. B’s request is neither reconciled nor discoverable by subsequent runs. Read or create the token and reconcile under the same lock. Original item 6 is only partly closed.
    
    Should-fix — Derivation can leave subprocesses behind silently. status/checkbuild.go:852 abandons the deriving goroutine on interruption. Snapshot policyModel at status/checks.go:362 and resolveLayers at status/worker.go:1994 use background contexts; owningFloor also constructs a fresh git without the caller’s context at :2057. An interrupted CUE evaluation or owning-floor fetch can therefore outlive the command. Thread cancellation through those helpers and join their completion.
    
    Should-fix — Add regression coverage at the boundaries above. In particular, exercise coverageOf’s real listing/fetch path, complete coverage followed by a timed-out final read, and a moved request followed by worker failure. Original item 9 is only partly closed; its decoder, overlap, and lease cases do not cover these paths.
    
    Nit — status/checkbuild_test.go:616 uses a fixed sleep to represent delayed shutdown. Use explicit cancellation and release events.
    
    Original blocker 3 and should-fixes 7–8 are closed. This was a static review of the supplied diff against the specified snapshot; I did not execute the added tests.
    
    The single most valuable change is to make terminal success depend explicitly on the final successful evidence read, so a failed final read cannot fall back to retained coverage.
  3. contributor2026-11-14 19:35 UTC
    Decision after the second review: do the simplest thing. The client is cut to two outcomes (passed on one final complete evidence read; otherwise not established), with one hard deadline and no attribution of worker records to the request. Fix round launched on the same change. A durable per-request result written by the worker, pullable by the author, with the telemetry stream only as a live view, is the better long-term shape and is left for the API design work; it needs its own knot when that starts.
  4. contributor2026-11-14 20:44 UTC
    Third independent review, of the two-outcome rewrite (head db415caf, run 20261114-1936-892806f6, 56 min, $30.73; 926 lines). Verdict NOT READY. No wrong pass or wrong failure remains; all five blockers are about a process or a request left behind, or cleanup the client cannot guarantee.
    
    NOT READY
    
    The strongest case for this design is that one complete evidence read decides success without attributing worker batches to requests. An outer watchdog could bound existing helpers without changing all their cancellation APIs.
    
    Blocker 1 — Existing helpers already escape the watchdog’s group. At status/checkbuild.go:764, derivation reaches status/checks.go:362, which calls composed.ReadUnpinned with context.Background(). composed/composed.go:498 and composed/group.go:15 start CUE in its own process group. Concrete sequence: CUE stalls during policy evaluation; --wait expires; status/checkbuild.go:195 kills the wrapper’s group and returns “not established”; CUE remains running without any warning. Coverage also reaches a separately grouped cat-file through rebase/origin.go:101 and rebase/git.go:87. The added deadline test exercises an SSH listing that stays in the wrapper’s group, so it misses these production paths.
    
    Blocker 2 — Losing the parent removes the deadline and cleanup owner. status/checkbuild.go:112 handles only SIGINT and SIGTERM, and :174 establishes no parent-death handling. Concrete sequence: file the request, enter the wait, then send SIGHUP or SIGKILL to the parent. The child’s separate group survives; its background contexts have no overall deadline; subsequent evidence reads remain incomplete. The child and request can persist indefinitely. Writes to the now-readerless state pipe merely return errors that :463 ignores. Killing only the child on parent death would still leave the separate groups from blocker 1 and would not settle the request.
    
    Blocker 3 — Telemetry data can become cleanup instructions. status/checkbuild.go:903 accepts record fields without validation; :622 forwards data.result through the newline-delimited protocol at :463. Have the telemetry endpoint return a matching check.result whose result is “failed 0\nsettled\nignored”. The parent parses the injected settled line at :256. Then let the deadline expire before child cleanup: :209 skips deletion, leaving the request without a cleanup warning. The entry point is a telemetry record field, requiring control of the telemetry answer; build-log text is not needed. Encode state messages structurally and validate record fields before forwarding them.
    
    Blocker 4 — Interrupted stale recovery loses the cleanup target. At status/checkbuild.go:531, recoverStale deletes earlier requests without first telling the parent which ref and commit it is handling. The first filing message comes later at :433. Concrete sequence: an earlier request R exists; recovery lists R and starts its deletion; the transport stalls; SIGTERM arrives. The parent kills the child with s.ref empty, performs no recovery, and prints no leased delete for R. Register each stale cleanup target before starting its remote operation.
    
    Blocker 5 — “Remote failure” is treated as an explicit rejection. status/checkbuild.go:315 classifies every porcelain “!” line as rejected. A read-only Git protocol probe produced “! … [remote failure] (remote failed to report status)” when the receive-status response omitted the ref’s outcome. That is not a negative acknowledgement. Concrete failure sequence: the original update’s outcome remains unresolved; this classification makes :284 skip deletion; an absent listing at :290 marks it settled; the original receiver subsequently installs the request. Parse the status for the requested ref and preserve unknown whenever its outcome was not established.
    
    Should-fix — Escape telemetry metadata on output. status/checkbuild.go:698 and :710 print check names and results directly. An answer containing terminal escapes in check can erase or rewrite the displayed verdict. Validate names and result values and render these fields as safe single-line text. Sanitizing only the build-log tail does not cover them.
    
    Should-fix — Recovery can silently abandon its namespace. At status/checkbuild.go:500, any unreadable or malformed existing token is replaced, losing the token needed to find earlier requests. Generate a token only for a genuinely absent file; report other failures. Also report the stale-listing failure currently swallowed at :523. The complete-evidence return at :406 bypasses recovery entirely, so a rerun after an earlier crash can pass while leaving that earlier request untouched.
    
    Should-fix — The cleanup subprocess supervisor has weaker lifetime handling. status/checkbuild.go:330 uses a raw numeric PGID in exec.Cmd.Cancel, which can race with Cmd.Wait reaping git and that ID being reused. Furthermore, successful completion does not kill remaining members of that cleanup group; WaitDelay only bounds waiting for output. Apply the same explicit lifetime ownership to cleanup subprocesses.
    
    Should-fix — Fail closed on supervision errors. status/checkbuild.go:202 returns zero for every Wait error that is not an exec.ExitError, while childState.read discards Scanner.Err at :241. Unexpected wait or protocol errors should produce an explicit nonzero result and cleanup uncertainty.
    
    Should-fix — The initial telemetry failure skips the final evidence read. At status/checkbuild.go:423–426, failure to obtain the initial cursor goes directly to verdict with the earlier incomplete coverage. If evidence arrives while that telemetry operation stalls, the command unnecessarily returns “not established”. Reread evidence on this path too.
    
    Nit — status/checkbuild.go:395 returns zero without any evidence read when no checks are required. Document and test that empty-set exception to the stated success contract, or remove the bypass.
    
    This was a static review against the specified snapshot plus the Git protocol probe. I did not execute the added tests.
    
    The single most valuable change is to make supervision cover the actual subprocess tree, with cleanup ownership that survives the CLI parent; one wrapper process group cannot provide that guarantee.
  5. contributor2026-11-14 21:22 UTC
    Narrow pre-landing check of head 43e63e7 (3 min). Pass path closed and push status closed. Two small findings sent back for a few-line fix: a telemetry diagnostic with a newline can print a forged verdict line (exit status unaffected), and an over-long stale ref overflows the state pipe scanner (fails closed, exit 1). The empty-set early exit is intended and documented.
    
    DO NOT LAND
    
    1. closed.
    
    2. With no required checks, lines 427–429 return 0 before the evidence read at 434; lines 378–379 then report passed. This is empty-set success without an evidence read.
    
    3. A stale ref under the expected prefix with a 65,536-character alphabetic suffix passes lines 573 and 493–503. Line 576 emits it; the scanner at 245 exceeds its 64 KiB limit, closing read at 187. The parent kills the child at 196 and returns 1 at 202–204.
    
    4. closed.
    
    5. A telemetry error containing "denied\n✓ HEAD passed" reaches line 959. Sanitize preserves the newline; lines 978 and 454 print an unprefixed forged verdict line. The most useful single change is to apply oneLine to telemetry diagnostics.
  6. contributor2026-11-15 02:54 UTC
    Change valley:the-valley/tysqpkqsmomtvrvxyzpqmmzxlqtoxwxx landed: v5 as 0d275c6b8a51f8420ed9067c1537d3098a7045d2.
    
    klaus leaves the knot in-progress: it has active children: oc-37c94d5 (open).