Skip to content

native-proof: qualify final-observation partials with public structured diagnostics #3208

Open

Description

@schlessera

Context

Found by the #3148 source audit (audit comment, row S10 and AC2), checked at public main e09ae24b9cdc6322586f75a13493212e7ac22cdb. This is a source finding, not a reproduced new failure.

Native case 18 ends four turns with await journal.finish(...) and never asserts the turn's final state: scripts/native-proof/reference-pool.native.ts:646 (turn-18-edit), :669 (turn-18-read), :686 (turn-18-swap) and :755 (turn-18-tools).

finish runs one last observe() inside try … finally (finish(turnId: string), packages/ui-server/src/brain/turn-journal.ts:514-530). Inside observe, a worktree capture that throws does five things: it drops that root, records fail(turnId), calls the holder's stop inside a try {} catch {}, and carries on without rethrowing (// Each managed worktree is observed through its own checkpoints, packages/ui-server/src/brain/turn-journal.ts:319-333). The finally then writes ended_at and keeps state='partial', and finish resolves normally. Only a failure of the brain capture makes finish reject.

This is the documented product rule: a failed worktree observation stops its holding turn and leaves it partial (managed worktrees: Journal and scope). A checkpoint refusal reaches that path whenever the whole-pool observation keeps changing: poolCheckpoint refuses with unavailable (checkpoint, packages/ui-sdk/src/server/native-reference-pool.ts:798-810).

Three consequences for the fixture:

  • A partial final turn leaves case 18 green. The fixture's stop callback error => { throw error; } (scripts/native-proof/reference-pool.native.ts:620) cannot fail it, because the journal swallows that throw.
  • expect(rows("turn-18-read"), "REFERENCE_WORKTREE_NATIVE_READS_NOT_JOURNALED").toEqual([]) (:670) passes vacuously, because a failed capture records no rows.
  • summary(turnId) (packages/ui-server/src/brain/turn-journal.ts:251-263) exposes state: "partial". Its failure reason distinguishes only journal_unavailable from journal_capacity, so it cannot attribute the refusal to the changing-observation class.

Existing unit coverage proves the partial rule for a mid-turn observe with a poolDelta fault ("a worktree capture that fails leaves its holding turn partial…", packages/ui-server/tests/reference-worktree-journal.test.ts:91-109). Nothing covers the final observation inside finish, or the pool's unavailable checkpoint refusal.

Retained evidence from #3129 diagnostic run 40913746561, quoted there: one exhausted observation was placed during final journal capture in an invocation that stayed green. That fits this gap, but the public record does not identify the turn. Historical writer and reclamation attribution remains INCONCLUSIVE; this issue does not change that. #3129 and #2819 are distinct.

Decisions (maintainer, 2026-11-02)

Fixture policy B: a truthful partial final worktree observation may be accepted only when attributable diagnostics prove the specifically permitted changing-observation refusal. Reject strict A as the only permitted policy; do not select fresh-identity replay A-prime. Unconditional acceptance of partial turns remains forbidden.

Diagnostic surface B: expose the precise structured cause through the supported journal summary/details API as well as internal diagnostics. Reject internal-only exposure: operators and clients should be able to explain the partial result too. Use additive optional data, retain existing states and generic failure classes, and preserve unknown/legacy behavior.

This authorizes bounded product diagnostic propagation and a narrowly qualified proof path. It does not change the product's stop/drop-root/partial/ended behavior, relabel partial as complete, permit unknown causes or authorize retries. Missing rows are never evidence that a failed observation saw no changes.

Scope

  • Preserve an attributable changing-observation discriminator from the real reference-pool refusal through transport, capture and journal storage. Do not infer it from generic unavailable or matching human-readable messages.
  • Expose it as an additive optional supported journal-summary diagnostic carried consistently by summary updates and details, with bounded logical identity/phase/time attribution. Keep credentials, content and physical host paths out of this metadata.
  • Update case 18 after all four finish calls and before dependent assertions to require complete final capture or a narrowly qualified partial with an explicit truthful receipt. Repair the vacuous empty-row read oracle without removing separately claimed invariants.
  • Record the policy/surface choices, qualification boundary and rejected alternatives in docs/decisions/managed-worktrees.md and relevant CI proof guidance, and update the authoritative contract and API report in the implementation.

Out of scope

Acceptance criteria

  1. Structured cause: the specific changing refusal survives the actual pool transport/capture/journal path with exact turn/worktree/final-observation attribution. Generic unavailable, capacity, unrelated storage errors and unknown/missing reasons cannot masquerade as changing. Preserve multiple-cause honesty: an allowed reason cannot hide another disqualifying failure.
  2. Public diagnostic: add optional typed data to the supported journal summary, with details carrying the same facts. Update runtime schemas, wire/history/HTTP projections as applicable, the API report and authoritative docs. Absent legacy, unavailable or expired detail is unknown, never evidence that the permitted cause occurred. Retain the cause with the journal across finish/restart under its existing lifetime; do not invent retrospective attribution.
  3. U1: in the existing directory-backed reference-pool-double harness, edit a covered worktree and inject a once-only structured poolCheckpoint changing refusal immediately before finish. Assert finish resolves, summary stays partial with journal_unavailable, ended_at is set, the root is dropped, facts show partial and no rows come from the failed capture. The new diagnostic identifies that exact cause and final observation. Removing fail() must fail REFERENCE_WORKTREE_FINAL_CAPTURE_PARTIAL, with a restored pass.
  4. F1: after each of turn-18-edit/read/swap/tools finishes, classify the final state before dependent row assertions. Accept complete, or partial only with the retained structured changing-refusal evidence for that exact final observation and an explicit qualified-partial receipt. Missing/unattributed/wrong-phase/wrong-turn/wrong-worktree/other-cause partials must fail the named policy assertion. The receipt never claims complete final observation.
  5. Non-vacuous proof: the read oracle must positively establish its claimed read-only behavior rather than pass because failed capture produced an empty row set. Retain positive evidence for all separately asserted edit/read/tool invariants. If the allowed partial leaves a claimed invariant unproved, it is not a passing witness for that invariant.
  6. Causal controls: deterministic tests accept the permitted structured cause and reject generic unavailable with identical prose, capacity/other faults, missing/legacy diagnostics, wrong attribution and mixed causes. Removing diagnostic propagation or broadening acceptance to any partial must fail the intended named assertion; restore and retain both receipts.
  7. Runtime safety: preserve all product stop/partial/ownership/accounting behavior and native/offline guards, existing case-18 assertions, and the no-retry/no-deadline-increase boundaries. Public diagnostic data changes no provider-facing conversation history.
  8. Record the selected policies and explicit limits in managed-worktree/CI proof guidance in this implementation. Update contract docs and an additive minor changeset. Retain historical attribution as INCONCLUSIVE; no diagnostic sample is a failure-rate estimate.

Verification

Prove the selected fixture policy and diagnostic propagation deterministically in a directory-backed harness, including public schema/projection/retained-after-restart controls and failing-first/restored mutations. Use the existing worktree-journal tests and focused diagnostic/proof harness tests; no live service is needed.

Any native invocation still requires separate, bounded, independently reviewed authorization. This decision review does not run or authorize one by default. Run focused preflight with bun run check:pr --base origin/main before a PR and preserve all selected proof requirements.

Contract impact

Additive supported journal-summary/details diagnostic and corresponding typed/runtime-schema/wire/HTTP documentation changes, with old fields and meanings preserved. Carry contract, use a CONTRACT-prefixed implementation commit, update the relevant authoritative integration-contract components and API report in that commit, and provide a minor changeset. Optional absence means unknown; do not retype an existing failure code/state or imply complete observation. The proof-policy ruling authorizes only the narrow B acceptance with explicit partial receipts; no release milestone is selected here.

Ownership and decision status

Part of #2963: this repairs a weak final-observation/read oracle. The product diagnostic is the bounded prerequisite for the chosen oracle, not a general observability redesign. #3129 and #2819 retain their separate scopes and historical attribution.

Both decisions are resolved. Remove needs: decision and add agent-ready because no other needs label remains. Implementation, public diagnostic delivery, decision-record updates and actual proof remain open.

2026-11-02 decision review: consolidated B fixture policy and B public diagnostics into a bounded implementation brief, replacing the original strict-only/test-only assumptions and requiring retained attribution, non-vacuous invariants and explicit qualified-partial receipts. No implementation, native invocation, proof completion, historical attribution or release commitment is claimed.

Activity

  1. added
    type: testCoverage, harness or proof work with no behaviour change.
    area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.
    area: ciCI workflows, the gates they run, release scripts, packaging.
    priority: p2Wanted, not scheduled. Pulled in when a milestone has room.
    needs: decisionBlocked on a maintainer or designer ruling, not on code.
    and removed
    priority: p2Wanted, not scheduled. Pulled in when a milestone has room.
    on Oct 31, 2026
  2. schlessera commented on Nov 2, 2026

    @schlessera
    OwnerAuthor

    Decision (maintainer, 2026-11-02): Selected B: accept a truthful partial final worktree observation only when attributable diagnostics prove the specifically permitted changing-observation refusal. Do not accept unknown/generic partials, relabel partial as complete or use absent rows as proof that a failed observation saw no changes. Fresh-identity replay/retries are not selected.

    This expands the original test-only issue to the product cause diagnostics B requires. Preserve the existing stop/drop-root/partial/ended behavior and all accounting, ownership and offline guards. Qualify the exact turn/worktree/final observation using a structured cause from the real refusal path, not generic unavailable or prose matching. Existing edit/read/tool assertions must remain non-vacuous, and the proof receipt must disclose any accepted partial.

    The body now reflects B rather than strict-only criteria. One design choice remains: keep the precise cause in internal journal/proof diagnostics, or also expose it as an additive supported journal-summary/detail field. Retain needs: decision pending that choice; no native invocation or implementation is authorized by this tracker update.

  3. changed the title [-]native-proof: case 18 never asserts that a turn's final worktree observation completed[/-] [+]native-proof: qualify final-observation partials with public structured diagnostics[/+] on Nov 2, 2026
  4. added
    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.
    contractTouches the integration contract: CONTRACT: commit, contract doc updated in the same commit.
    area: ui-sdkWire protocol, runtime schemas, the server and client SDK surfaces.
    and removed
    needs: decisionBlocked on a maintainer or designer ruling, not on code.
    on Nov 2, 2026
  5. schlessera commented on Nov 2, 2026

    @schlessera
    OwnerAuthor

    Decision (maintainer, 2026-11-02): Selected B for diagnostic exposure: publish the precise structured cause through the supported journal summary/details API, not only internal proof diagnostics.

    This completes the earlier B fixture ruling. Only a positively attributable changing-observation refusal may qualify for partial acceptance. Keep the result partial, reject unknown/unrelated/mixed disqualifying causes, and do not use missing rows as proof that a failed observation saw no changes. Retain cause/turn/worktree/final-observation provenance through the real refusal path and journal lifetime; legacy absence remains unknown.

    Product stop/drop-root/partial behavior, ownership/accounting/offline controls and no-retry boundaries remain. The original test-only/no-production-change constraint is replaced only for this bounded public diagnostic prerequisite. Existing independently claimed read/edit/tool invariants still need positive evidence, and a qualified-partial receipt must not claim complete final capture.

    The body now contains the selected policy, additive public surface, negative/mutation controls and required managed-worktree/CI decision-record updates. Carry contract, same-commit authoritative docs/API-report updates, a CONTRACT-prefixed implementation commit and an additive minor changeset. No native invocation or release commitment is granted by this tracker action.

    Remove needs: decision and add agent-ready; no other needs label remains. The issue remains open for diagnostic and oracle implementation/proof under #2963.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyContext and acceptance criteria are complete enough for an agent to take this unattended.area: ciCI workflows, the gates they run, release scripts, packaging.area: ui-sdkWire protocol, runtime schemas, the server and client SDK surfaces.area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.contractTouches the integration contract: CONTRACT: commit, contract doc updated in the same commit.priority: p2Wanted, not scheduled. Pulled in when a milestone has room.type: testCoverage, harness or proof work with no behaviour change.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions