# Preview pass controller report

Branch: `preview/pass`. Base: `7c113ac8`. Design approved by the controller on
2026-11-26 in `2026-11-26-preview-pass.md`.

## Delivered behavior

A device tap mints a 32-byte pass through the device bearer API. A dedicated
non-persistent WKWebView posts it in a bounded form body to the instance. The
single-use exchange issues a separate, hashed, task-bound browser grant and
redirects to the existing preview wrapper. It creates no general sign-in.
The per-task __Host-equipo-preview-{taskID} cookie is host-only, Secure,
HttpOnly and SameSite=Strict with Path=/. Server authority permits only the
bound wrapper's exact GET. Only a well-formed secret under that task's name
selects the restricted lane; junk and other tasks' cookies are ignored. Once
selected, invalid grants never fall through to ordinary browser sign-in.

Pass lifetime is at most 60 seconds; grant lifetime is at most 15 minutes,
capped by the originating credential and preview. Reads never extend it.
The transaction rechecks the roster, device, backing native session, task,
candidate, step attempt and deployment fingerprint. Secret lookup uses an exact
indexed SHA-256 hash. The tested query plan and executed SQL both pin that down.
Issuance and exchange are limited by device and IP; unknown tokens consume the
IP allowance. Cookie values and pass bodies do not enter audit records.

The shared renderer preserves its CSP, sandbox and referrer policy. The native
sheet allows only the fixed POST exchange and exact GET wrapper as main-frame
navigation; no popups, downloads, custom schemes or device bearer enter it.
Each presentation owns a new non-persistent WebKit store. Dismissal, expiry,
changed deployment, sign-out and account replacement dispose it. Foreground
revalidation checks the task and reloads only the same bound wrapper.

No runner protocol change. The additive app-owned tables are in Models and the
migration snapshot. The device endpoint and response are in OpenAPI. Existing
browser sign-in continues when no well-formed grant selects the restricted lane.

## Copy

Luna approved api.preview_changed and api.preview_expired on 2026-11-26.
Both are marked in copy.go and imported byte-identically under native parity.
The wrapper retains evidence.candidate_changed and question.expired; the unused
native copies of those keys are removed. The original import also restored two
already-reviewed stop reasons missing on the base: merge_credential and
amadan_unreachable. No copy questions remain.

## Test-first evidence

Initial store stubs refused all mint requests: `go test ./internal/equipo -run
'^TestPreview' -count=1` failed the new single-use/lifetime and binding tests.
Initial HTTP stubs left the mint route absent and allowed normal-session
fall-through: the HTTP tests failed on 401 mint and 200 invalid-cookie fallback.
Native stubs failed nine assertions across the first four tests. Implementation
then passed those tests. Evidence is retained in `site/build/slice6/validation`.

The real Chromium browser lane posts a pass, follows the 303, loads the wrapper
and its iframe, then proves replay returns 404. The actual iframe request has
no Cookie, Authorization or Referer. Test-only TLS trust is confined to Chromium
for the two local HTTPS test servers; production WebKit has no TLS override.

## Mutations

33 server guards and 19 native guards were broken deliberately, tested, and
restored. All 52 logical mutations were killed by assertions, not compile errors.
The scripts, individual test logs and result JSON are retained in the validation
folder. Each server invocation uses `GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0` and
`go test ./internal/equipo -run <named test/subtest> -count=1`. Native mutations
use `swift test --package-path native/apple --filter 'Preview(Pass|Lifecycle)Tests'`.

Server: pass and grant duration; both indexed hash lookups; task and candidate
binding; pass and grant expiry; hashed storage; revoked device and native
session; instance, attempt, current candidate and deployment fingerprint;
iframe cookie host and canonical trailing-dot host; Preview step candidate;
final task; preview and device expiry caps; device and IP rate limits; Secure,
HttpOnly and Strict cookie flags; no ambient-session fallback; GET-only grant;
bounded exchange body; transactional audit; known refusal audit and device
limit; single-use consumption.

Native: private store; releasing web view, store and browser; session invalidation
and permanent invalidation; exact expiry boundary; observed deployment change;
foreground binding check; late-response generation; busy guard; pass alphabet;
pass expiry and grant maximum; newest Preview selection; HTTPS; exact wrapper
origin; GET-only wrapper; iframe cookie-host refusal.

Initial survivors led to stronger tests: query SQL is checked as well as the
query plan; the device check is tested independently of task authority; the
body-bound test uses valid form padding; permanent model invalidation is tested
with an otherwise usable client (session invalidation also disables its client).
Initial mutation filters/targets were corrected to hit the intended
subtest or occurrence. No surviving mutation is counted as killed.

## Validation

- Pre-merge native gate passed: 359 tests in 48 suites, one existing known issue;
  334 web-parity strings, security scripts, fixtures and both platform builds.
  Recorded in `preview-native-final-gate.log`.
- `GOOS=linux GOARCH=amd64 make build` passed, including the Darwin runner build.
- `GOOS=linux GOARCH=amd64 make vet` passed, including the Make target's Darwin
  runner check. The ordinary Mac all-package build hits the existing Linux-only
  toolproxy `unix.O_PATH` use. Linux hub CI is the authoritative full gate.
- `make fmt-check budget spacing copy-release-check migration-check` passed;
  `PATH="$(GOTOOLCHAIN=go1.26.11 go env GOROOT)/bin:$PATH"` used for gofmt.
  Size records name the new code and measured totals.
- Host-built staticcheck v0.7.0 with `GOOS=linux GOARCH=amd64`, tags
  `browser,perf,testbuild`, passed. Host-built govulncheck v1.8.0 targeting Linux
  found no reachable vulnerabilities. `make gitleaks` found no leaks.
- `make lanes-check` passed: 18 regular and 5 browser lanes cover every test.
- Preview store/HTTP/security tests passed, as did the device/OpenAPI contract
  and migration tests. Final targeted and browser logs are retained.
- The Make perf harness, targeted to `./internal/equipotest` on Mac, passed:
  wrapper median 1.041 ms, worst 1.125 ms against 150 ms; cold boot median
  154 ms against 500 ms. The new GET exchange refusal has an explicit skip record.
- An initial validation attempt lost files from the shared Go cache. On the
  controller's instruction, retried without clearing it. The retry passed.

## Native captures and limitations

`iphone-preview.png` and `mac-preview.png` are captured from the branch's built
apps against the tagged manual Go fixture, using the actual bearer mint,
POST-body exchange, wrapper cookie, shared wrapper and iframe. The external
example page is disposable fixture content. The server is loopback-only behind
a temporary HTTPS tailnet port. The fixture config contains a disposable test
credential, stays private, and is deleted at teardown. It is not committed or
archived. No production account or credential is used. The Mac image is the live
sheet, captured with AppKit. Its header uses the app palette background so
bitmap exports preserve the same readable surface as the window.

The iframe's external service remains responsible for its own availability.
Grant expiry prevents new wrapper reads; it cannot retract HTML already
received by an arbitrary browser. Native disposes the delivered view at expiry.
The pass does not approve an unsafe preview or confer any merge authority.

Final commit and Linux CI verdict are sent to the controller after pushing;
no merge, deployment or release is performed.


## Main integration before publication

Normally merged main `088e5863` after `2469eaa8`, as requested. Kept the
Changed files tab and its explicit detail-only projection. The transactional
`TaskAt` read shares authority and opts out of file facts; `TaskDetail` still
opts in. Retained the new native load result and preview invalidation together.
Moved the preview tables to migration 0109 after main's 0108 change-files field.
Combined budget reasons and remeasured 23204 app source, 34984/9873 chat
source/tests, and 11967 plan contract test lines. Re-ran validation on the merge.

The merged native gate passed: 377 tests in 50 suites, one existing known issue,
334 web-parity strings, and both builds (`preview-native-merged-gate.log`).
Merged preview/visibility contracts, migration, copy, lane coverage and browser
exchange checks passed. Changed-files projection tests passed on the merge.

## CI copy-guard correction

Linux CI at f149ba60 rejected the computed API error code in the mint handler
with TestAPIErrorCopyKeys. Reproduced locally using
`GOMAXPROCS=2 GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/equipo -run '^TestAPIErrorCopyKeys$' -count=1`.
The HTTP error branches now name their codes literally. The scanner is unchanged
from main. The person API uses its ordinary api.<code> lookup. Luna approved
api.preview_changed and api.preview_expired on 2026-11-26; they are marked in
copy.go and imported byte-identically into both native catalogs under parity.
Native errors and lifecycle expiry use these words; the wrapper retains its
reviewed web words.

TestPreviewErrorCopyKeys failed for both old runtime mappings, and the native
staleAndExpiredWordsComeFromReviewedCatalog test failed with the old native keys.
Both pass after switching to the approved API keys. TestAPIErrorCopyKeys failed
without the two catalog entries, then passed. The scanner remains unchanged.

The source budget was remeasured at 23214 lines. The initial Linux run's
TestContractRetryAccountActions, TestTimeouts and TestBrowserCopyContinue
failures each passed its automatic retry. The preview browser lane passed.

Approved-copy validation: TestAPIErrorCopyKeys and all TestPreview tests passed
in the app and person API packages; make copy-release-check, fmt-check and
budget passed. The native gate passed 377 tests in 50 suites (one existing
known issue), 336 parity strings, and both app builds.

CI at 7bd80b29 passed the API copy scanner but identified the missing two review
inventory rows. Added the exact approved text and Luna/date provenance to the
Plan 3 inventory, following its existing explicit key/date acceptance checks.
`go test ./internal/plan3test -run '^TestPlan3ReleaseBoundaries$' -count=1` passed
after reproducing the missing-row failure. Test size is 11969 lines. No runtime
or native code changed in this inventory correction.

## Security review delta

The server returns expires_in and grant_expires_in, rounded down from its mint
clock and bounded to 1–60 and 1–900 seconds. Native ignores absolute timestamps
for enforcement. It subtracts the full monotonic request elapsed time before
starting its local timer; tests use device clocks five minutes ahead and behind,
7.25 seconds of travel, and a pass that expires before receipt. No deadline
slides or gains transit time.

Host-prefixed per-task cookies prevent sibling-domain planting. Junk and another
task's cookie do not select the restricted lane. Well-formed unknown, expired,
duplicate or refused capabilities cannot fall through to ambient browser auth.
Terminal passes are consumed and grants deleted atomically with one refusal
audit. Replays add no refusal audit. Exchange and read prune expired rows too.
Migration 0110 adds the two composite credential/task indexes without changing
0109. Audit-failure tests prove token retirement rolls back with its audit.

The child-frame policy permits only about:blank, about:srcdoc, blob: and data:
in addition to the existing HTTPS child policy; main-frame rules are unchanged.
Link previews are disabled. The real browser test now checks nested srcdoc and
blob contents. The iPhone screenshot iphone-preview-frames.png uses the actual
mint/exchange/wrapper and a local HTTPS child fixture. Only the disposable
simulator trusts the local test certificate; production TLS handling is intact.
The fixture initially checked before WebKit's dynamic blob finished; its bounded
five-second content wait now reports ok=true, with all four frame types visible.

Test-first: preview-delta-go-red.log and preview-delta-native-red.log show the
original implementations failing the new behavior. All 25 delta mutations were
killed by named assertions: relative pass/grant mapping and floor; Host cookie
prefix/root path; junk/other-task lane selection; replay audit; terminal pass
consumption and grant deletion; exchange/read pruning and cutoff; both composite
indexes; device-clock comparison; transit extension and expiry; lifetime bounds
and ordering; child-only schemes, blocked child schemes and unknown about pages;
link previews. Individual logs and results are in the review mutation folders.
One Swift run omitted per-assertion details, but the named child-scheme test
failed with four issues; the result classifier was corrected, not the test.

Fable's supplied attacks are retained in preview_pass_attack_test.go. Adaptation
is limited to the per-task Host cookie, relative-lifetime checks and making the
log-only duplicate-cookie check assert refusal for two well-formed values.
All five groups passed: 29 path/method tricks; 13 changes between wrapper reads;
secret-at-rest scanning across every database table; 13 exchange-header cases;
grant replacement and bearer/cookie separation. No intended-behavior failure
was found. Command: GOMAXPROCS=2 GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test -p 1
./internal/equipo -run '^TestReview' -count=1 -v (25.692s).

The preceding published head ffa46f5a passed Linux CI including TestPerfScreens
and TestPerfBoot. The review delta requires a new exact-head green verdict,
including that same perf lane, before handoff.

Final local review checks: native/scripts/check-native.sh passed 379 tests in
50 suites (one existing known issue), 334 parity strings and both app builds.
The first attempt hit the existing markdown stream test's three-second wait
under heavy shared-machine load; the unchanged test passed on the full retry.
The final combined preview, Fable attack, browser exchange, API copy and Plan 3
contract run passed in all three packages. Build, Linux-target vet, staticcheck
v0.7.0 with GOOS=linux GOARCH=amd64, fmt-check, size budgets, migration-model
check, copy-release-check and lane coverage passed. Staticcheck and perf used a
private cloned GOCACHE, without modifying or clearing the shared cache.

The full macOS make perf invocation reached both performance tests, which passed,
but exited for the existing Linux-only toolproxy unix.O_PATH build error in
three unrelated packages. The focused equipotest performance budget invocation
uses the same required screen/boot tests; the full Linux CI perf lane remains
the final gate.

## Migration snapshot correction

Fable identified that migration 0110's indexes were missing from schema.sql.
The narrow TestConversationMigrationSnapshot reproduced both missing-index
errors. Appended 0110 to the snapshot's existing additive SQL, then the same
unchanged test passed (1.530s). Command: GOMAXPROCS=2 GOTOOLCHAIN=go1.26.11
CGO_ENABLED=0 go test -p 1 ./internal/equipo
-run '^TestConversationMigrationSnapshot$' -count=1. No full local suite or
simulator was started while the machine was critically loaded.

The focused performance budget check on b3adc1bf passed TestPerfScreens and
TestPerfBoot with zero failures. Evidence is archived with the review logs.
