Skip to content

Slice 11: test-vs-real provenance on a witnessed Run - #664

Merged
xmap merged 3 commits into
mainfrom
worktree-slice11-testing-provenance
Aug 16, 2026
Merged

Slice 11: test-vs-real provenance on a witnessed Run#664
xmap merged 3 commits into
mainfrom
worktree-slice11-testing-provenance

Conversation

@xmap

@xmap xmap commented Aug 16, 2026

Copy link
Copy Markdown
Owner

Summary

Answers cora#657 (Francesco De Carlo). Reads 2-BM's 2bmb:TomoScan:Testing
role (a DBR_ENUM, same record type as AbortScan) and carries a tri-state
reading onto the witnessed genesis: whether tomoscan was bypassing its own
beam preconditions when the capture began.

  • Deliberately NOT Manifest.is_simulated: that field answers whether the
    recorded numbers were synthetic; this answers whether the facility had
    beam. The two disagree at 2-BM right now (real detector/motors/file,
    no beam, during the commissioning shutdown).
  • Three states, not two: True (bypassed), False (a positive claim of a
    real acquisition), None (unresolved/absent) — never collapsed.
  • Dual clock: RunWitnessRecorder retains the latest testing reading per
    capture code with its own observed_at, independent of any one capture
    (never evicted, unlike progress), and stamps both onto the next genesis.
  • Reuses binary_code() from _capture_observer.py — no second decoder.
  • Ships to the exported record (keep:number), unlike SafetyEnvelopeVerdict's
    redacted live-PSS/interlock bools: this is a receipt-facing provenance
    claim the issue itself asked to be visible, not a security-perimeter
    reading. Documented explicitly in gen_record_dispositions.py so a future
    maintainer doesn't "fix" it to match the wrong precedent.
  • Code capability only: nothing reaches the record at 2-BM until that
    deployment declares the testing role in its own CAPTURE_WATCH_PVS
    and RUN_WITNESS_RECORDING_ENABLED is turned on.

Rides along: a small, independent correction to capture_watch_preflight.py's
module docstring, which overclaimed that all three prior wire-shape defects
"would have shown up in one run" of the preflight command (NumAngles is
read from the HDF5 file, never a PV, so no CA preflight can reach it) and
that kind alone flags array-vs-scalar (a one-element array reports as
Scalar, indistinguishable from a real scalar). Docstring only, no behavior
change; separate commit.

Test plan

  • make test-noio (unit + architecture + contract): 47817 passed, 630 skipped
  • make test-db (integration + e2e): 1196 passed, 1 skipped
  • make lint (ruff check + format --check): clean
  • make typecheck (pyright): clean
  • Naming reviewer run on all new identifiers (R1-R6); renamed the
    domain vocabulary to beam_preconditions_bypassed /
    CapturePreconditionBypassObservation / CapturePreconditionBypassSnapshot
    to stay substrate-neutral, keeping only the config-facing role key (testing)
    mirroring the PV name
  • code-review gate review at high effort: fixed a docstring
    correctness bug, documented the disposition-policy decision, and
    closed four test-coverage gaps it surfaced (unresolved-with-timestamp
    round-trip, decoded-with-no-timestamp round-trip, a non-tautological
    shadow-mode noop test, per-capture-code isolation, and Hypothesis
    fuzzing of the new field through the decider)
  • Not run: capture_watch_preflight.py against the live 2-BM host
    (arcturus unreachable, per the design memo)

🤖 Generated with Claude Code

xmap and others added 3 commits August 15, 2026 20:06
Two sentences in capture_watch_preflight.py's module docstring
overclaimed what the preflight command actually catches: it cannot
reach NumAngles at all (read from the HDF5 file, never a PV), and
Measurement.kind cannot distinguish a genuine scalar from a 1-element
array, since _kind_for only flags an array at element_count > 1.
Docstring only; no behavior change.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Reads the optional testing role (2-BM's TomoScan:Testing, DBR_ENUM)
alongside status/abort/images_saved/images_collected and carries the
witnessed genesis's tri-state reading onto RunStarted, answering
whether the substrate was bypassing its own beam preconditions for
this capture. Tri-state throughout (asserted / clear / unresolved):
an unresolved reading is never coerced to "real", and a clear reading
is a positive claim of a real acquisition, never mere absence.

Deliberately NOT Manifest.is_simulated: that field answers whether the
recorded numbers were synthetic, an orthogonal question from whether
the facility had beam. The new field ships to the exported record
(keep:number), unlike SafetyEnvelopeVerdict's live-PSS/interlock bools,
because it is a receipt-facing scientific-provenance claim the issue
itself asked to be visible, not a security-perimeter reading.

RunWitnessRecorder retains the latest testing-role reading per capture
code with its own dual-clock observed_at, independent of any one
capture (unlike progress, this is never evicted at promote/truncate/
outcome), and stamps it onto the next genesis via
record_witnessed_run's now-optional capture_precondition_bypass_snapshot.

Code capability only: ships nothing to a live record until a
deployment declares the testing role in its own capture_watch_pvs and
run_witness_recording_enabled is turned on.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The manual commit-splitting step for the F2 docstring fix (isolating it
from the slice-11 diff by reconstructing an intermediate file) copied
the pre-slice-11 version of capture_watch_preflight.py back into place
for that commit, then never restored the full slice-11 version before
the second commit. The ROLE_TESTING import and its _decode_verdict
branch were silently dropped from what got committed and pushed,
caught by CI (fast shard 1) failing three preflight tests that assert
the testing role actually decodes, rather than by local review.

Confirmed via diff that this was the ONLY file affected (the other 19
files went through the safer patch-apply recovery path after the
earlier pre-commit timeout). Full test-noio rerun clean (47817 passed)
before pushing this fix.

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

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  apps/api/src/cora/api
  _capture_observer.py
  _run_witness.py
  capture_watch_preflight.py
  apps/api/src/cora/infrastructure
  config.py
  apps/api/src/cora/run/aggregates/run
  events.py
  state.py
  apps/api/src/cora/run/features/record_witnessed_run
  command.py
  apps/api/src/cora/run/ports
  capture_observer.py
Project Total  

This report was generated by python-coverage-comment-action

@xmap
xmap merged commit 072b2e2 into main Aug 16, 2026
19 checks passed
@xmap
xmap deleted the worktree-slice11-testing-provenance branch August 16, 2026 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant