gunk-dev/the-valley
the-valley:oc-37c94d5outcomedone

telemetry: a check's build log is read and followed by its run and name

State
done
Created
2026-11-14 by contributor
Changes
  • valley:the-valley/vssuvlolowxuutkxslwspnpulzkwlutq

Body

An author whose check failed on the worker needs the reason: the check's build output. The worker already writes each check's output to a file per run and check (`telemetry/store.go`, `Stream.Log`, `logs/<run>/<check>.log`, bounded in size, newest runs kept), and the worker's `check.result` records carry the run. What is missing is a way to ask for one log by that address: `valley telemetry ... --logs` serves only the tails of the newest logs.

Shape, decided:
- The address is the worker's run and the check's name. Storage stays as it is, ignorant of projects.
- One new telemetry operation returns that log (whole, bounded as stored, or its tail), and a follow mode returns its output as it is written, for a build still running. Same transport, limits, escaping and untrusted marking as the other telemetry operations.
- Access is the existing host-wide `observe` grant.
- A client command reads or follows a log by run and check.
- `valley checks --build`, on an outcome it cannot establish, prints for each failed check of the tree the command that reads its log, and stops printing best-effort newest tails.

Accepted for now: host-wide access, and retention by run count. A per-project access check can sit in front of the same address later; that belongs with the API design work.

Comments

  1. contributor2026-11-14 20:00 UTC
    Overlaps oc-d2a370d (a check's full build log is kept and readable from a session): this knot is the read-by-run-and-check half of it. When this lands, re-read oc-d2a370d and close or narrow it to what remains (keeping the full log rather than a bounded one).
  2. contributor2026-11-15 02:57 UTC
    Shape critique before building (independent critic, 0d275c6). Verdict RESHAPE: make each check result name its attempt's diagnostics instead of deriving a log from (run, check name). Reasons, with source: checks sharing a derivation share one log named after the first check; evaluation failures have results and no log; pruning leaves no tombstone, so evicted and never-existed look the same; the stored log keeps the first 256 KiB, so a failure at the end of a long build is lost; four open observe requests exhaust a principal, so per-check follows would refuse ordinary reads. Proposed revision, awaiting the operator: the result names its log or says why there is none; one read of a finished attempt's log that keeps the end of the output and reports truncation or eviction; no follow; checks --build prints the read command. Left to the build service (ida-e3da913) and oc-d2a370d: full logs, retention policy, lookup by tree after the fact, per-project access.
    
    The proposal replaces newest-log guessing with a command tied to the failed attempt, improving the workflow in [status/checkbuild.go:742](/home/klaus/.klaus/consult-snapshots/consult-266985672/the-valley/status/checkbuild.go:742). Reusing the authenticated telemetry transport avoids another service for output that `observe` already permits reading.
    
    The missing capability is “retrieve the diagnostics of this check attempt.” The output belongs to the build attempt, produced by attest; telemetry can serve it, but should not become the authority for build requests or results. Choosing its directory layout as the public contract would let the nearest mechanism decide the design—the trap named in [guidance/house-rules.md:40](/home/klaus/.klaus/consult-snapshots/consult-266985672/the-valley/guidance/house-rules.md:40).
    `observe` keeps its existing meaning: host-wide diagnostic access, independent of project consent ([telemetry/protocol.go:42](/home/klaus/.klaus/consult-snapshots/consult-266985672/the-valley/telemetry/protocol.go:42)). An explicit log operation also avoids overloading `--logs`. “Run” must remain a producer invocation: the relevant ID is the attest batch’s run, not the worker pass or a durable build request ([status/worker.go:1701](/home/klaus/.klaus/consult-snapshots/consult-266985672/the-valley/status/worker.go:1701)). Later project authorization needs reliable ownership metadata; the address alone cannot supply it.
    The proposed address already fails for valid results. Checks sharing a derivation share one log named after the first check, while each receives its own result ([attest/progress.go:66](/home/klaus/.klaus/consult-snapshots/consult-266985672/the-valley/attest/progress.go:66), [attest/check.go:490](/home/klaus/.klaus/consult-snapshots/consult-266985672/the-valley/attest/check.go:490)). Evaluation errors produce results without build logs ([attest/check.go:385](/home/klaus/.klaus/consult-snapshots/consult-266985672/the-valley/attest/check.go:385)). Retries receive fresh attest IDs, so retained failed logs remain separately addressable, but `checks --build` collects only results observed during its wait; this supplies no reliable historical tree-to-attempt lookup ([status/checkbuild.go:640](/home/klaus/.klaus/consult-snapshots/consult-266985672/the-valley/status/checkbuild.go:640)). Pruning deletes directories without tombstones, so absence cannot distinguish eviction from nonexistence ([telemetry/store.go:463](/home/klaus/.klaus/consult-snapshots/consult-266985672/the-valley/telemetry/store.go:463)). Results should name their actual diagnostic resource or explain its absence.
    Following fits the wire transport, but the concurrency promise is inadequate. Four open observe requests exhaust one principal’s allowance, refusing ordinary reads too ([telemetry/valley-telemetry/main.go:162](/home/klaus/.klaus/consult-snapshots/consult-266985672/the-valley/telemetry/valley-telemetry/main.go:162)). Per-check followers multiply that pressure. Existing follow cursors resume records, while log offsets exist only inside a connection; copying follow also copies fixed polling ([telemetry/valley-telemetry/read.go:190](/home/klaus/.klaus/consult-snapshots/consult-266985672/the-valley/telemetry/valley-telemetry/read.go:190)). Defer follow unless its resumability and protection of ordinary reads are explicit.
    The smallest useful slice is a completed-attempt diagnostic read and its printed command, preserving failure-ending output and reporting truncation or unavailability. Merely exposing the existing prefix cannot let agents stop rebuilding locally: output after the cap is discarded ([telemetry/store.go:485](/home/klaus/.klaus/consult-snapshots/consult-266985672/the-valley/telemetry/store.go:485)). Leave durable request/result ownership, historical discovery, full compressed logs, differentiated retention and project authorization to the later build service; keep the older outcome open for those remaining capabilities.
    Reject newest-tail selection because it cannot identify the attempt, and reject implementing the entire build service here because it greatly expands this diagnostic slice. Prefer the existing transport with a producer-defined diagnostic contract.
    RESHAPE: make each check result identify its actual attempt diagnostics, rather than deriving a promised log from `(run, check name)`.
    tokens used
    68,614
    [exited with code 0]
  3. contributor2026-11-15 03:27 UTC
    Reshaped again at the operator's question whether this is already solved. Nix keeps every build's log on the builder and nix log reads it; verified that a worker-built check's log is returned by nix log <drv> on a client substituting from the builder's cache (failed-build case not yet tested end to end). New shape: check.result names its derivation; valley checks --build prints nix log <drv>; no telemetry operation, store or bound of our own. First run 20261115-0300-c3d90b1b stopped; relaunched with the new brief.
  4. contributor2026-11-15 03:53 UTC
    Independent review of 29aad2d (run 20261115-0327-641695bd, 22 min, $3.31; 8 files +219/-86; agent built all 20 required checks). NOT READY: one blocker (build_error dropped, so a build that dies before the builder starts prints a nix log command with no log and no diagnosis) and two doc should-fixes (telemetry still keeps a bounded copy; nix keeps logs only with keep-build-log). No injection finding. Fix round launched.
    
    Recording `drv` in existing result records gives clients the build’s address without adding a telemetry operation. Reusing `nix log` also removes the ambiguous lookup of newest telemetry tails.
    
    NOT READY. Static review only; no tests or builds run. All citations use new-side lines.
    
    Blocker — status/checkbuild.go:698 ignores recorded build errors. For a `check.result` containing `result: "failed"`, a valid `drv`, and `build_error: "signal: killed"`, the reader retains no error because it reads only `error`. This is an actual producer shape: attest/progress.go:206 writes `build_error`. If the Nix process dies before starting the builder, the command prints a `nix log` command with no corresponding log and silently omits the recorded diagnosis. Carry `build_error` through the same escaping and pipe encoding.
    
    Should-fix — docs/architecture.md:1473 incorrectly says the valley “stores no copy and manages no retention.” A short failed build still writes its output through `observer.nixBuild` into telemetry’s check log; telemetry/store.go:429 persists it and telemetry/store.go:464 prunes old runs. Restrict this claim to Nix’s logs and acknowledge the existing bounded telemetry copies.
    
    Should-fix — docs/reference.md:3189 promises retained logs for every built derivation without stating the configuration dependency. With the builder configured with `keep-build-log = false`, a failed derivation has no saved Nix log even immediately afterward; the worker configuration does not override this setting. Document log preservation as a deployment prerequisite. [Nix’s configuration reference](https://nix.dev/manual/nix/2.33/command-ref/conf-file.html#conf-keep-build-log) explicitly makes it conditional.
    
    No injection blocker found: the derivation alphabet excludes command delimiters, admitted glob characters are quoted, and decoded errors pass through `oneLine`. Widening `stateValue` does not bypass the separate validation of request refs or check attributes. Five-field and seven-field readers are incompatible, but the parent launches its own executable; independently upgraded parent and child processes are not the normal execution model. Malformed optional fields are discarded safely. No nits.
    
    The single most valuable change is to preserve and print `build_error` alongside `error`, so a failed build remains diagnosable when its derivation has no log.
  5. contributor2026-11-15 04:22 UTC
    Fix rounds done (runs 20261115-0353-94b08f1d 13 min, 20261115-0407-02d6cd17 15 min; cumulative about $5): build_error carried and printed, docs corrected (telemetry keeps its bounded copy; keep-build-log is a deployment prerequisite), and the report points at the worker's output whenever a check failed, for the failed-dependency case nix log cannot read. Coordinator read both round diffs and marked 5fbb196 ready.
  6. contributor2026-11-15 14:13 UTC
    Change valley:the-valley/vssuvlolowxuutkxslwspnpulzkwlutq landed: v3 as 273a801b235390be125323dedb120891db1aad4c.
    
    Every change the knot links has landed and it has no active children, so klaus set it done.