# Changed files facts

Branch changes/facts starts at origin/main 18fb5be4 in its own physical TMPDIR
worktree. Slice 5b is excluded: no diff endpoint, contents, or native diff view.
No new GET route or performance exemption is needed.

## Report and device contract

The controller approved ProtocolChangeFiles = 31 on 2026-11-26. The separate
optional change_files field carries Engineering presentation facts on
StepReport and the device Step. Existing wire.ChangeFacts, Review measurement,
acceptFacts and merge authority are unchanged.

Facts bind the accepted step's base and candidate. Entries contain only path,
status (added/modified/deleted/renamed), old path for a rename, additions,
deletions and a binary flag. MaxChangeEntries is 200; encoded facts are also
bounded to 96 KiB. Totals cover the complete scan, including omitted entries;
truncated means entries were omitted. Each raw/numstat listing is bounded to
1 MiB. A failed, malformed, mismatched or clipped scan supplies no facts,
rather than invented totals. Paths retain spaces and Unicode; invalid/control
paths are refused. No file contents, tokens, or new network calls are added.

Engineering measures its local candidate/base pair during publication, including
republish. It reuses Review's NUL-safe raw and numstat parsers. A first commit
with no base is measured only after proving it is a root commit; a missing base
on a later commit remains unknown. Review retains its existing handling.

The additive chat_steps.change_files column stores only accepted Engineering
facts. Attempt and runner authority use the existing report path; acceptance
also checks protocol, role, specialist, exact base/candidate and bounds. The
device projection validates stored facts again and hides them while the step
is no longer done. Task-read visibility is inherited unchanged. Encode removes
change_files below protocol 31. Older runners remain usable; native links out.

The OpenAPI schema includes the optional field, entry statuses, nonnegative
counts and the 200-entry limit. The full native task fixture round-trips the
new nested field. A runner-to-device contract covers protocol 31 and protocol
30, exact mapping, and the absence of merge-authority/private fields.

## Native presentation and copy

Changed files selects the last Engineering step for the task's current
candidate, with matching facts SHA/base. Missing, invalid or older facts keep
the existing web link. The bounded list shows per-file counts and status,
renames with the old path, and non-text files. Lists longer than ten entries
group by folder. Empty totals remain real zeroes only when the scan completed.

File taps build the known Amadan repository page with fixed host and ref/path
query parameters, then use the existing allowlisted opener. Amadan's actual
route was verified in its local internal/hub/browse_render.go. Candidate SHA
pins ordinary files; deleted files use the base. Spaces, Unicode, plus signs,
query delimiters and fragments are encoded as path data. Non-Amadan repository
identifiers and traversal paths cannot construct a file URL. iPhone uses the
existing Safari sheet; Mac uses the default browser.

Luna approved native.changes.* on 2026-11-26:
- added: Added
- modified: Changed
- deleted: Deleted
- renamed: Renamed
- binary: Non-text file
- renamed_from: Renamed from %@
- truncated: Showing the first %lld files. Open on Amadan for the full list.
- total: %lld files, %lld lines added, %lld removed

Both generated catalogs carry the review comment. Catalog substitutions
pluralize files and lines independently. The checker verifies that the ordinary
plural forms still match the reviewed English source. Native tests pin
"1 file, 1 line added, 0 removed" and all singular/plural combinations. Compact
row counts stay numeric; their accessibility label uses the reviewed plural
phrases.

## Test-first and authority proof

Initial commands, with GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0:
- go test ./internal/runner/thin -run
  'TestEngineeringChangeFiles|TestChangeFilesBounds' -count=1:
  red for missing API, then green. Real git tests cover spaces, Unicode,
  rename, deletion, non-text data and 203 files bounded to 200.
- go test ./internal/wire -run 'TestProtocol31|TestChangeFilesValidation':
  red for missing protocol/field, then green. A frozen main StepReport key set
  strictly rejects the new field in every downgraded protocol 1 through 30.
- go test ./internal/equipo/chat -run
  '^TestEngineeringChangeFilesAcceptance':
  red for missing acceptance/storage/projection, then green.
- go test ./internal/runner/thin -run '^TestChangeFilesInitialCommit$' -count=1:
  red (nil facts) before the proven-root path, then green.
- swift test --package-path native/apple --filter ChangeFilesTests:
  red for missing decoding/presentation APIs, then green.

A detached worktree of clean main 18fb5be4 captured sixty Review gate decisions:
fifteen input cases at protocols 27, 28, 30 and 31. Cases cover approval,
checks, hold, size, binary/special/signing changes, gate files, shortened review,
missing/incomplete evidence, ask policy and a person's decision. The frozen
testdata/presentation-gate.json is compared byte for byte by
TestPresentationFactsLeaveReviewGateUnchanged on this branch. It passes.
A separate real-git test also compares Review facts and its decision before
and after collecting display facts. The detached worktree was removed.

Additional focused commands pass:
- go test ./internal/thintest -run '^TestContractEngineeringChangeFiles$' -count=1
- go test ./internal/equipo/mergegate ./internal/runner/thin ./internal/wire
  ./internal/plan3test -run
  'TestPresentationFactsLeaveReviewGateUnchanged|TestSandboxMasksPublish|TestProtocol31|TestPersonAPIDeviceContract'
  -count=1
- go test ./internal/equipo -run
  'TestMigrationModels|TestConversationMigrationSnapshot' -count=1
- swift test --package-path native/apple --filter
  'ChangeFilesTests|TaskDetailTests.fullWire'

## Mutations

Scripts changes-facts-mutate-go.py and changes-facts-mutate-native.py run one
mutation at a time, require an actual test assertion failure (not a compile
error), and restore the source in finally. All 43 are killed.

Server/runner (23): downgrade boundary; wire entry bound; wire byte bound;
wire exact totals; truncation consistency; runner entry bound; runner byte
bound; clipped scan; ancestor requirement; proven root requirement; matching
raw/numstat paths; additions; binary flag; rename old path; publication mapping;
acceptance protocol; role; specialist; base; candidate; device step state;
device mapping; persistent storage.

Native (20): current candidate; latest matching step; Engineering specialist;
done state; facts SHA; facts base; valid facts; folder grouping; repository
shape; file path; deleted-file base ref; plus encoding; count argument order;
entry bound; byte bound; truncation consistency; binary counts; duplicate paths;
server slash escaping; server HTML escaping.

The first current-candidate mutation survived because the old step fixture
still carried the new candidate's facts. The fixture now binds that old
measurement to its own candidate. The mutation then fails, as do all others.
The clipped-scan fixture ends the bounded prefix exactly on a valid raw record,
so ignoring clipping cannot pass merely because a parser rejects a partial row.

## Validation and evidence

Go build, vet, staticcheck v0.7.0, govulncheck, copy release, references, lanes,
formatting, spacing, gitleaks and migration checks pass. Vet and staticcheck
target linux/amd64, as instructed for macOS toolproxy compatibility. The size
gate first reported the expected added lines; existing package exemptions now
record the exact measured source/test sizes and the scope that added them.
The corrected budget gate passes. No timing budget was increased.

native/scripts/check-native.sh passes: 325 tests in 42 suites, one existing
known issue, 327 byte-identical web strings, references, Mac and iOS Simulator
builds. The eight new native entries retain Luna's approved wording.

Two TaskViewUI tests pass on an iPhone 18 Pro / iOS 27 simulator: the list and
old-runner fallback, and accessibility extra-large text. Screenshots from this
branch are in polish-audit/equipo-daily-driver/site/build/slice5/:
- iphone-changed-files.png
- iphone-changed-files-large.png
- iphone-changed-files-old-runner.png
- mac-changed-files.png

The Mac capture uses the built debug app and the same offline fixture transport.
Both platforms retain the existing pinned decision. The screenshots were
inspected; paths wrap at large text sizes. The fixture app and simulator were
closed and the temporary simulator removed.

Main c74fd0ac (landed Needs you) was merged normally before publishing. String
conflicts keep both reviewed catalogs; existing size exemptions include the
merged done_at mapping and tests. Final results are recorded below; the exact-head
Linux verdict is saved in the screenshot validation directory.

Final self-review added a test-first JSON byte-bound regression: Swift normally
escapes slashes, whereas Go leaves them literal and escapes HTML characters.
Native now measures the server's snake-case JSON representation with the same
escaping. A valid 200-entry nested-path listing is accepted, while a shorter
HTML-character listing over the server's byte bound is rejected. The test
failed both assertions before the fix; removing either encoding rule is killed
by changes-facts-mutate-json.py. The seven focused ChangeFiles tests pass.

Final native gate after the main merge and byte-bound fix passes: 350 tests in
46 suites, one existing known issue, 330 web-parity strings, Mac and Simulator
builds. Post-merge budget, formatting and focused device/runner contract tests
also pass. Post-commit runner-dead-references passes.

The full local macOS `make test` is not green: toolproxy requires unix.O_PATH,
browser tests have no Chromium, and existing runner/provider checks fail.
Representative TestOnboardingClaudeHeadlessBrowserLogin and
TestPublishCoreAuthorizationContract failures were reproduced unchanged on
clean origin/main c74fd0ac in a detached worktree, then that worktree was removed.
No platform bypass or test weakening was added. Linux hub CI is the final gate;
its full result is archived beside the screenshots in validation/ci-final.json.

Local `make perf` runs TestPerfScreens and TestPerfBoot, but the target fails
while building the same Linux-only toolproxy dependency (`unix.O_PATH`). The
Linux CI performance target must pass; no performance exemption was added.
The validation directory preserves both local failure logs and all passing
focused, mutation, native and screenshot-test logs for review.

The first final-head Linux run (4d654482) exposed three wire contract omissions:
TestInjectionProtocolDowngrade still expected 30 when negotiating 99;
TestEnumsAreTheWireConstants needed the ChangedFile status constant family;
and TestConnectionTypesCarryNoSecrets needed exact exceptions for
ChangedFile.path and ChangedFile.old_path. These are validated repository-relative
names; the audit still rejects every other secret-shaped field. The status
values now use shared wire constants. All `go test ./internal/wire/...` tests
pass after the fixes. The failed CI log is retained as ci-4d654482-failed.json;
the subsequent exact-head verdict is in ci-final.json.

## Fable review follow-up, 2026-11-26

The device detail read now opts into file facts when building the view.
Ordinary task and step projections omit them, including the Coordinator tool,
lists, snapshots, events and action responses. GET /tasks/{id} uses TaskDetail,
with the same current-member and task-read authorization as Task. The OpenAPI
field description and schema generator explicitly say detail only.

The new 45-file, three-round fixture first failed on every ordinary projection
and on the Coordinator's clipped JSON. After the change, the complete tool
answer decodes and retains both verdict=approve and needs_you=merge. The
runner-to-device contract also checks that /tasks and /snapshot omit facts,
while detail retains them for protocol 31 and omits them for older runners.

Go and native share internal/wire/testdata/change-paths.json. Both reject Cc,
U+200E/F, U+202A–202E and U+2066–2069, and accept other format characters,
including a ZWJ emoji filename. Invalid facts are rejected by the existing
acceptance validation before storage. Native validates the optional field at
decode or assignment and discards invalid facts without losing the task;
rendering no longer repeats the validation and JSON byte measurement. Legacy
payloads and valid facts still round-trip.

Test-first commands and results:

- GOTOOLCHAIN=go1.26.11 CGO_ENABLED=0 go test ./internal/wire ./internal/equipo/chat ./internal/runner/thin -run 'TestChangeFiles|TestChangePath' -count=1
  failed before implementation: bidi paths accepted, invalid facts accepted
  for storage, ordinary projections leaked facts, Coordinator JSON truncated.
  Runner guard regression cases passed before mutation.
- swift test --package-path native/apple --filter ChangeFilesTests
  failed before implementation: ZWJ rejected, bidi accepted, invalid
  decoded/assigned facts retained. All 10 tests passed after implementation.
- The focused final Go run includes wire, chat, runner/thin, thintest and
  plan3test, matching ChangeFiles, ChangePath, EngineeringChangeFiles,
  ContractEngineeringChangeFiles, PersonAPIDeviceContract and
  OpsAreWhatTheHandlersWrite. All pass after merging main.

All 27 follow-up mutations were killed by assertion failures, then restored:

- Go validation: absolute path, backslash, invalid UTF-8, binary line counts,
  candidate and base commit length, binaries greater than files, Cc characters, bidi characters.
- Server projection: acceptance validation removed; default task view includes
  facts; detail opt-in removed; HTTP detail calls ordinary Task; active and
  retired step opt-in guards removed.
- Runner: final validation removed; commit-pattern guard removed; type-change
  mapping removed; non-Engineering publication includes facts.
- Native: empty/leading path segments, Cc characters, backslash, old-path
  validation, bidi characters, decode validation, assignment validation and
  repository-name pattern removed.

The executable mutation script, exact commands, exit statuses and per-mutation
logs are saved in site/build/slice5/validation/review/. Run it from the worktree
as python3 facts-review-mutations.py wire chat contract runner and
python3 facts-review-mutations.py native, plus
python3 facts-review-mutations.py extra-wire extra-chat. It restores each source
after testing. The 45-file fixture includes one retired round as well as two
active rounds, so both step collections are covered.

Live link verification: curl -sI
'https://amadan.net/oficina/equipo?ref=main&path=go.mod' returned HTTP/2 200 on
2026-11-26. A GET returned the go.mod file viewer and its module line, not a
repository listing or sign-in page. The existing /namespace/repo?ref=&path=
shape is correct; the native tests retain commit-pinned refs and plus escaping.

Main 7c113ac8 was merged normally in e0eeee7a. This includes the landed composer
and merge-credential fixes. The native parity gate found main's two new reviewed
stop reasons, work.reason.merge_credential and work.reason.amadan_unreachable;
both were copied exactly from the web catalog (Paul's existing approval).
No new wording or copy question was introduced. Measured size records cover the
new projection/guard tests and the merged main changes; no timing budget changed.


Final native gate passes: 356 tests in 47 suites, one existing known issue,
332 web-parity strings, Mac build and iOS Simulator build. Linux-targeted
make build and make vet pass with GOTOOLCHAIN=go1.26.11, CGO_ENABLED=0,
GOOS=linux and GOARCH=amd64. Staticcheck v0.7.0 and govulncheck pass using
make staticcheck / make govulncheck with their go-run -exec wrapper setting
GOOS=linux GOARCH=amd64 for the analyser. Formatting, spacing, copy release,
lane coverage, migration, measured size and gitleaks checks pass.

The ordinary macOS make build and make perf hit the existing Linux-only
toolproxy dependency (unix.O_PATH). TestPerfScreens and TestPerfBoot themselves
passed; the full Linux hub gate remains authoritative. No platform bypass,
new route or performance exemption was added.
