Add bounded changed-file facts and native file lists
46 files changed,
+4,372
−41
.rastrillo/budgets.txt+4 −4docs/api/equipo-v1.openapi.json+102 −0docs/superpowers/plans/CONTROLLER-REPORT-changes-facts.md+161 −0internal/equipo/chat/change_files.go+31 −0internal/equipo/chat/change_files_test.go+63 −0internal/equipo/chat/tasks.go+4 −2internal/equipo/mergegate/presentation_regression_test.go+63 −0internal/equipo/mergegate/testdata/presentation-gate.json+2,696 −0internal/equipo/migrations/0108_change_files.sql+2 −0internal/equipo/migrations/schema.sql+3 −0internal/runner/thin/change_files.go+97 −0internal/runner/thin/change_files_test.go+150 −0internal/runner/thin/engineer.go+3 −0internal/runner/thin/sandbox_masks_test.go+4 −0internal/thintest/change_files_contract_test.go+54 −0internal/wire/assistant_test.go+1 −1internal/wire/change_files.go+84 −0internal/wire/change_files_test.go+93 −0internal/wire/injection_test.go+1 −1internal/wire/mixed_protocol_test.go+1 −1internal/wire/models_test.go+1 −1internal/wire/opencode_test.go+1 −1internal/wire/pinned_release_test.go+1 −1internal/wire/publish_test.go+1 −1internal/wire/runners.go+10 −1internal/wire/runners_test.go+1 −1internal/wire/schedule_test.go+1 −1internal/wire/stuck_test.go+1 −1internal/wire/tasks.go+17 −14internal/wire/usage_test.go+1 −1internal/wire/warm_test.go+1 −1internal/wire/wireschema/wireschema.go+8 −0native/apple/Sources/EquipoActivity/Resources/Localizable.xcstrings+138 −0native/apple/Sources/EquipoKit/API/ChangeFiles.swift+52 −0native/apple/Sources/EquipoKit/API/Thin.swift+1 −0native/apple/Sources/EquipoKit/Presentation/ChangedFiles.swift+48 −0native/apple/Sources/EquipoKit/Resources/Localizable.xcstrings+138 −0native/apple/Sources/EquipoKit/UI/Screens/ChangedFilesList.swift+65 −0native/apple/Sources/EquipoKit/UI/Screens/TaskDetailScreen.swift+14 −1native/apple/Sources/EquipoKit/UI/TaskViewFixture.swift+32 −4native/apple/Tests/EquipoKitTests/ChangeFilesTests.swift+104 −0native/apple/Tests/EquipoKitTests/Fixtures/task-detail/full.json+27 −1native/ios/UITests/TaskViewUITests.swift+18 −0native/scripts/check-strings.py+15 −1native/scripts/plurals.json+50 −0native/scripts/strings.json+9 −1
diff --git a/.rastrillo/budgets.txt b/.rastrillo/budgets.txt| index 6ee2fa62..0459dad6 100644 |
| --- a/.rastrillo/budgets.txt |
| +++ b/.rastrillo/budgets.txt |
| @@ -15,7 +15,7 @@ time internal/equipo/team 60s Plan 3 loaded CI measured 45.985s; niced serial re |
| time internal/equipotest 300s Final fix package rerun measured 187.035s (review 172.4s); 300s gives 60 percent headroom for HTTP, sandbox, authority and final regression coverage. |
| size internal/equipo 22598 - Stuck tasks: the task page Retry on a failed preview and the coordinator's retried attempt on the timeline (2026-11-25); measured 22598 source lines. |
| -size internal/wire 7067 - Native task evidence: additive device StepHosted failed job names; measured 7067 source lines (2026-11-26). |
| +size internal/wire 7163 - Protocol 31 bounded Engineering display facts and strict downgrade; measured 7163 source lines (2026-11-26). |
| size internal/equipotest - 12017 Task 21 repairs historical migration and conversation fixtures after Plan 3, and the Rastrillo upgrade contract comparing served assets with what Assets serves; measured 0/12017 source/test lines. |
| time internal/runner/checks 90s CI worker measured 44.553s (44.6s rounded); |
| time internal/runner 330s Plan 3 CI repair measured 292.120s for the full package (controller CI 472.184s). |
| @@ -38,7 +38,7 @@ time internal/runner/provider 15s Plan 3 CI repair measured 10.346s for the full |
| perf GET /releases/* skip Verified runner release file downloads, not browser GET screens. |
| perf GET /install.sh skip Mac runners: the one-line bootstrap a terminal pipes to sh, not a browser screen. |
| time internal/runner/containment 15s Plan 3 loaded CI measured 10.817s; |
| -size internal/runner/thin 28530 22894 Protocol 30: the preview scanner's health in the capability report, the stuck-task tools refused on an older link (2026-11-25); measured 28530/22894. |
| +size internal/runner/thin 28630 23048 Protocol 31 display-only local git measurements, byte/file bounds and publication regressions; measured 28630/23048 (2026-11-26). |
| time internal/thintest 240s Thin contract and page tests, the Assistant's and the models' included, share one harness. Measured 202s on a shared 16 CPU box (2026-11-13); CI runs two lanes. |
| time internal/runner/mac 30s Mac runners (Darwin worker): real process groups killed after a grace and proven gone (SIGTERM, SIGKILL, the marker sweep), and the probes run end to end with fake srt and xcodebuild, P6 killing. |
| time internal/runner/thin 45s Thin v1 slice 4 review: real git repositories for the merge and squash checks, a stalled fetch, and a 16 MiB candidate streamed through the review diff and the checks pack (about 5s). |
| @@ -56,7 +56,7 @@ perf GET /api/v1/tasks/{id} skip Thin v1 person API: bearer-only JSON for device |
| perf GET /api/v1/assistant/snapshot skip Assistant person API: bearer-only JSON for Base's chat, not a browser screen. |
| perf GET /api/v1/assistant/messages skip Assistant person API: bearer-only JSON for Base's chat, not a browser screen. |
| perf GET /api/v1/assistant/events skip Assistant event stream (Server-Sent Events), bearer-only and long-lived; not a screen. |
| -size internal/equipo/chat 34835 9583 Native task evidence: minimal hosted job projection and absence/privacy regression; measured 34835/9583 (2026-11-26). |
| +size internal/equipo/chat 34868 9646 Engineering display facts acceptance and device projection, separate from merge authority; measured 34868/9646 (2026-11-26). |
| perf GET /api/v1/questions/{id} skip Thin v1 person API: bearer-only JSON for devices; the browser reads questions on /tasks/{id}. |
| perf GET /api/v1/steps/{id}/log skip Thin v1 person API: bearer-only JSON for devices; the browser shows the log tail on /tasks/{id}. |
| perf GET /api/v1/connections/preference skip Connections slice 1 person API: bearer-only JSON for devices; the browser shows the preference on /conversation/connections. |
| @@ -71,7 +71,7 @@ perf GET /tasks/{id}/files/{file} skip Research kept images: the bytes of one im |
| perf GET /api/v1/runners skip Mac runners person API: bearer-only JSON for devices; the browser shows runners in the Team section. |
| time cmd/equipo-runner 60s TestReleaseRunnerHasNoFakeWorker builds the release runner and the thin package under testbuild (about 12s locally). |
| size internal/headless - 11437 Grant scenarios for a named repository (hub #48); the sign-in's account email at 1280 and 390; measured 11437 test lines. |
| -size internal/thintest - 35085 Stuck-task contracts plus paused-job fixed-clock coverage at three hours (2026-11-26); measured 35085 test lines. |
| +size internal/thintest - 35139 Protocol 31 Engineering facts runner-to-device and old-runner contracts; measured 35139 test lines (2026-11-26). |
| perf GET /api/v1/projects/{id}/merge-policy skip Merge authority person API: bearer-only JSON for devices; the browser reads the policy on /projects/{id}. |
| perf GET /api/v1/usage skip Thin v1 person API: bearer-only JSON for devices; the browser reads usage through /usage. |
diff --git a/docs/api/equipo-v1.openapi.json b/docs/api/equipo-v1.openapi.json| index f154878d..1a436c6e 100644 |
| --- a/docs/api/equipo-v1.openapi.json |
| +++ b/docs/api/equipo-v1.openapi.json |
| @@ -22337,6 +22337,9 @@ |
| }, |
| "retried_by": { |
| "type": "string" |
| + }, |
| + "change_files": { |
| + "$ref": "#/components/schemas/ChangeFiles" |
| } |
| }, |
| "required": [ |
| @@ -24167,6 +24170,105 @@ |
| ], |
| "additionalProperties": false, |
| "x-go-type": "wire.StepHosted" |
| + }, |
| + "ChangeFiles": { |
| + "type": "object", |
| + "properties": { |
| + "base": { |
| + "type": "string" |
| + }, |
| + "sha": { |
| + "type": "string" |
| + }, |
| + "files": { |
| + "type": "integer", |
| + "format": "int64", |
| + "minimum": 0 |
| + }, |
| + "additions": { |
| + "type": "integer", |
| + "format": "int64", |
| + "minimum": 0 |
| + }, |
| + "deletions": { |
| + "type": "integer", |
| + "format": "int64", |
| + "minimum": 0 |
| + }, |
| + "binary": { |
| + "type": "integer", |
| + "format": "int64", |
| + "minimum": 0 |
| + }, |
| + "entries": { |
| + "type": [ |
| + "array", |
| + "null" |
| + ], |
| + "items": { |
| + "$ref": "#/components/schemas/ChangedFile" |
| + }, |
| + "maxItems": 200, |
| + "description": "At most 200 entries. Totals cover the complete bounded scan; truncated is true when entries were omitted. The encoded facts are bounded to 96 KiB." |
| + }, |
| + "truncated": { |
| + "type": "boolean" |
| + } |
| + }, |
| + "required": [ |
| + "base", |
| + "sha", |
| + "files", |
| + "additions", |
| + "deletions", |
| + "binary", |
| + "entries", |
| + "truncated" |
| + ], |
| + "additionalProperties": false, |
| + "x-go-type": "wire.ChangeFiles" |
| + }, |
| + "ChangedFile": { |
| + "type": "object", |
| + "properties": { |
| + "path": { |
| + "type": "string" |
| + }, |
| + "old_path": { |
| + "type": "string" |
| + }, |
| + "status": { |
| + "type": "string", |
| + "enum": [ |
| + "added", |
| + "modified", |
| + "deleted", |
| + "renamed" |
| + ] |
| + }, |
| + "additions": { |
| + "type": "integer", |
| + "format": "int64", |
| + "minimum": 0 |
| + }, |
| + "deletions": { |
| + "type": "integer", |
| + "format": "int64", |
| + "minimum": 0 |
| + }, |
| + "binary": { |
| + "type": "boolean" |
| + } |
| + }, |
| + "required": [ |
| + "path", |
| + "status", |
| + "additions", |
| + "deletions", |
| + "binary" |
| + ], |
| + "additionalProperties": false, |
| + "x-go-type": "wire.ChangedFile" |
| } |
| }, |
| "responses": { |
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-changes-facts.md b/docs/superpowers/plans/CONTROLLER-REPORT-changes-facts.md| new file mode 100644 |
| index 00000000..26cc8c44 |
| --- /dev/null |
| +++ b/docs/superpowers/plans/CONTROLLER-REPORT-changes-facts.md |
| @@ -0,0 +1,161 @@ |
| +# 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 41 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 (18): 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. |
| + |
| +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. |
| + |
| +Full Go test, performance and Linux CI results follow after completion. |
diff --git a/internal/equipo/chat/change_files.go b/internal/equipo/chat/change_files.go| new file mode 100644 |
| index 00000000..14662b27 |
| --- /dev/null |
| +++ b/internal/equipo/chat/change_files.go |
| @@ -0,0 +1,31 @@ |
| +package chat |
| + |
| +import ( |
| + "encoding/json" |
| + |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// Presentation facts are bound to the accepted Engineering attempt. They |
| +// never enter acceptFacts or mergegate's inputs. |
| +func acceptChangeFiles(l Lease, role string, s stepRecord, f *wire.ChangeFiles) string { |
| + if l.Protocol < wire.ProtocolChangeFiles || role != wire.RolePrimary && role != wire.RoleWorker || |
| + s.Specialist != wire.SpecialistEngineering || !wire.ValidChangeFiles(f) || |
| + f.Base != s.BaseSHA || f.SHA != s.CandidateSHA { |
| + return "" |
| + } |
| + raw, _ := json.Marshal(f) |
| + return string(raw) |
| +} |
| + |
| +func stepChangeFilesView(s stepRecord) *wire.ChangeFiles { |
| + if s.Specialist != wire.SpecialistEngineering || s.State != wire.StepDone || s.ChangeFiles == "" { |
| + return nil |
| + } |
| + var f wire.ChangeFiles |
| + if json.Unmarshal([]byte(s.ChangeFiles), &f) != nil || !wire.ValidChangeFiles(&f) || |
| + f.Base != s.BaseSHA || f.SHA != s.CandidateSHA { |
| + return nil |
| + } |
| + return &f |
| +} |
diff --git a/internal/equipo/chat/change_files_test.go b/internal/equipo/chat/change_files_test.go| new file mode 100644 |
| index 00000000..0f7ea60a |
| --- /dev/null |
| +++ b/internal/equipo/chat/change_files_test.go |
| @@ -0,0 +1,63 @@ |
| +package chat |
| + |
| +import ( |
| + "encoding/json" |
| + "strings" |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +func TestEngineeringChangeFilesAcceptanceAndDeviceView(t *testing.T) { |
| + base, sha := strings.Repeat("a", 40), strings.Repeat("b", 40) |
| + facts := &wire.ChangeFiles{Base: base, SHA: sha, Files: 1, Additions: 2, Entries: []wire.ChangedFile{{Path: "space 日本語.txt", Status: "added", Additions: 2}}} |
| + good := stepRecord{ID: "s", State: wire.StepDone, Specialist: wire.SpecialistEngineering, BaseSHA: base, CandidateSHA: sha, Attempt: 2} |
| + for name, tc := range map[string]struct { |
| + protocol int |
| + role string |
| + step stepRecord |
| + facts *wire.ChangeFiles |
| + want bool |
| + }{ |
| + "primary": {31, wire.RolePrimary, good, facts, true}, |
| + "worker": {31, wire.RoleWorker, good, facts, true}, |
| + "old": {30, wire.RolePrimary, good, facts, false}, |
| + "role": {31, "unknown", good, facts, false}, |
| + "missing": {31, wire.RolePrimary, good, nil, false}, |
| + "review": {31, wire.RolePrimary, stepRecord{Specialist: wire.SpecialistReview, BaseSHA: base, CandidateSHA: sha}, facts, false}, |
| + "candidate": {31, wire.RolePrimary, stepRecord{Specialist: wire.SpecialistEngineering, BaseSHA: base, CandidateSHA: base}, facts, false}, |
| + "base": {31, wire.RolePrimary, stepRecord{Specialist: wire.SpecialistEngineering, BaseSHA: sha, CandidateSHA: sha}, facts, false}, |
| + } { |
| + t.Run(name, func(t *testing.T) { |
| + stored := acceptChangeFiles(Lease{Protocol: tc.protocol}, tc.role, tc.step, tc.facts) |
| + if (stored != "") != tc.want { |
| + t.Fatalf("accept: %q", stored) |
| + } |
| + s := tc.step |
| + s.ChangeFiles = stored |
| + v := stepView(s) |
| + if (v.ChangeFiles != nil) != tc.want { |
| + t.Fatalf("view %+v", v.ChangeFiles) |
| + } |
| + if tc.want { |
| + a, _ := json.Marshal(v.ChangeFiles) |
| + b, _ := json.Marshal(facts) |
| + if string(a) != string(b) { |
| + t.Fatalf("%s != %s", a, b) |
| + } |
| + } |
| + }) |
| + } |
| + raw, _ := json.Marshal(facts) |
| + for _, s := range []stepRecord{ |
| + {State: wire.StepDone, Specialist: wire.SpecialistReview, BaseSHA: base, CandidateSHA: sha, ChangeFiles: string(raw)}, |
| + {State: wire.StepDone, Specialist: wire.SpecialistEngineering, BaseSHA: base, CandidateSHA: base, ChangeFiles: string(raw)}, |
| + {State: wire.StepDone, Specialist: wire.SpecialistEngineering, BaseSHA: sha, CandidateSHA: sha, ChangeFiles: string(raw)}, |
| + {State: wire.StepRunning, Specialist: wire.SpecialistEngineering, BaseSHA: base, CandidateSHA: sha, ChangeFiles: string(raw)}, |
| + {State: wire.StepDone, Specialist: wire.SpecialistEngineering, BaseSHA: base, CandidateSHA: sha, ChangeFiles: "{"}, |
| + } { |
| + if stepView(s).ChangeFiles != nil { |
| + t.Fatal("stale or malformed projection") |
| + } |
| + } |
| +} |
diff --git a/internal/equipo/chat/tasks.go b/internal/equipo/chat/tasks.go| index 52d18800..17f23f1b 100644 |
| --- a/internal/equipo/chat/tasks.go |
| +++ b/internal/equipo/chat/tasks.go |
| @@ -224,6 +224,7 @@ type stepRecord struct { |
| // kept only when it passed acceptance. DecidedBy is who decided a |
| // merge step ("policy", or "person:<address>"); MergeSource and |
| // MergeParents (JSON) where its SHA came from. |
| + ChangeFiles string // Presentation only: bounded Engineering file list. |
| ChangeFacts string |
| DecidedBy string |
| MergeSource string |
| @@ -464,7 +465,7 @@ func (t *txn) latestStep(taskID string) (stepRecord, bool, error) { |
| } |
| func stepView(s stepRecord) wire.Step { |
| - return wire.Step{Hosted: stepHostedView(s), RunnerID: s.RunnerID, Needs: decodeList(s.Needs), Placement: s.Placement, Publication: s.Publication, TerminationKind: s.TerminationKind, ChecksSandbox: s.ChecksSandbox, ID: s.ID, Revision: s.Revision, TaskID: s.TaskID, Index: s.Idx, Specialist: s.Specialist, State: s.State, Reason: s.Reason, Attempt: s.Attempt, BaseSHA: s.BaseSHA, CandidateSHA: s.CandidateSHA, Pushed: s.Pushed, Terminated: s.Terminated, Summary: s.Summary, Headline: s.Headline, LogTail: s.LogTail, StartedAt: s.StartedAt, FinishedAt: s.FinishedAt, |
| + return wire.Step{ChangeFiles: stepChangeFilesView(s), Hosted: stepHostedView(s), RunnerID: s.RunnerID, Needs: decodeList(s.Needs), Placement: s.Placement, Publication: s.Publication, TerminationKind: s.TerminationKind, ChecksSandbox: s.ChecksSandbox, ID: s.ID, Revision: s.Revision, TaskID: s.TaskID, Index: s.Idx, Specialist: s.Specialist, State: s.State, Reason: s.Reason, Attempt: s.Attempt, BaseSHA: s.BaseSHA, CandidateSHA: s.CandidateSHA, Pushed: s.Pushed, Terminated: s.Terminated, Summary: s.Summary, Headline: s.Headline, LogTail: s.LogTail, StartedAt: s.StartedAt, FinishedAt: s.FinishedAt, |
| Round: s.Round, Family: s.Family, Account: s.Account, Model: s.Model, Verdict: s.Verdict, ReviewLabel: s.ReviewLabel, Findings: decodeFindings(s.Findings), BaseChecks: s.BaseChecks, Checks: s.Checks, Gate: s.Gate, ExitCode: s.ExitCode, Askable: s.Askable, |
| Rebase: s.Rebase, MergeSHA: s.MergeSHA, Into: s.MergeInto, Strategy: s.MergeStrategy, WithoutChecks: s.WithoutChecks, Activity: decodeActivity(s.Activity), Preview: decodePreview(s.Preview), Publish: decodePublish(s.Publish), RetriedBy: retriedBy(s)} |
| } |
| @@ -771,7 +772,7 @@ func (t *txn) writeStep(s *stepRecord) error { |
| } |
| s.Revision++ |
| s.UpdatedAt = t.now() |
| - if err := t.db.Model(&stepRecord{}).Where("id = ?", s.ID).Select("base_checks", "base_checks_sha", "copy_owner", "copy_revision", "copy_result", "failure_signature", "state", "reason", "attempt", "base_sha", "candidate_sha", "pushed", "terminated", "summary", "log_tail", "started_at", "finished_at", "revision", "updated_at", "headline", "family", "account", "verdict", "review_label", "findings", "checks", "gate", "exit_code", "output", "republish", "from_attempt", "askable", "rebase", "from_base", "from_candidate", "merge_sha", "merge_into", "merge_strategy", "without_checks", "switched", "activity", "runner_id", "needs", "placement", "waiting_since", "refused_by", "withdrawn", "termination_kind", "publication", "publication_id", "apple", "checks_sandbox", "change_facts", "decided_by", "merge_source", "merge_parents", "hosted_ci", "kind", "note", "sandbox_runner", "unsandboxed_by", "unsandboxed_at", "unsandboxed_attempt", "unsandboxed_runner", "has_preview", "preview", "boundary", "question", "request_turn", "sources_card", "sources_hash", "research_grant", "research_grant_revision", "hold", "housekeeping_attempt", "coordinator_attempt", "held_at", "publish", "model").Updates(s).Error; err != nil { |
| + if err := t.db.Model(&stepRecord{}).Where("id = ?", s.ID).Select("base_checks", "base_checks_sha", "copy_owner", "copy_revision", "copy_result", "failure_signature", "state", "reason", "attempt", "base_sha", "candidate_sha", "pushed", "terminated", "summary", "log_tail", "started_at", "finished_at", "revision", "updated_at", "headline", "family", "account", "verdict", "review_label", "findings", "checks", "gate", "exit_code", "output", "republish", "from_attempt", "askable", "rebase", "from_base", "from_candidate", "merge_sha", "merge_into", "merge_strategy", "without_checks", "switched", "activity", "runner_id", "needs", "placement", "waiting_since", "refused_by", "withdrawn", "termination_kind", "publication", "publication_id", "apple", "checks_sandbox", "change_files", "change_facts", "decided_by", "merge_source", "merge_parents", "hosted_ci", "kind", "note", "sandbox_runner", "unsandboxed_by", "unsandboxed_at", "unsandboxed_attempt", "unsandboxed_runner", "has_preview", "preview", "boundary", "question", "request_turn", "sources_card", "sources_hash", "research_grant", "research_grant_revision", "hold", "housekeeping_attempt", "coordinator_attempt", "held_at", "publish", "model").Updates(s).Error; err != nil { |
| return err |
| } |
| if s.Retired { |
| @@ -1557,6 +1558,7 @@ func (t *txn) stepReport(l Lease, v *wire.StepReport) error { |
| } |
| s.Pushed = true |
| } |
| + s.ChangeFiles = acceptChangeFiles(l, role, s, v.ChangeFiles) |
| s.Apple = v.Apple |
| s.Askable = v.Askable |
| if s.Rebase && s.BaseSHA != "" { |
diff --git a/internal/equipo/mergegate/presentation_regression_test.go b/internal/equipo/mergegate/presentation_regression_test.go| new file mode 100644 |
| index 00000000..30ad3557 |
| --- /dev/null |
| +++ b/internal/equipo/mergegate/presentation_regression_test.go |
| @@ -0,0 +1,63 @@ |
| +package mergegate |
| + |
| +import ( |
| + "encoding/json" |
| + "os" |
| + "path/filepath" |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// This golden was measured on main 18fb5be4 before ChangeFiles existed. |
| +// It pins byte-identical decisions for identical inputs, including protocol 31. |
| +func TestPresentationFactsLeaveReviewGateUnchanged(t *testing.T) { |
| + cases := map[string]func(*Inputs){ |
| + "ordinary": func(*Inputs) {}, |
| + "checked": func(i *Inputs) { i.Checks = wire.ChecksPassed; i.Eligible = true }, |
| + "failed": func(i *Inputs) { i.Checks = wire.ChecksFailed }, |
| + "not-approved": func(i *Inputs) { i.Verdict = wire.VerdictChanges }, |
| + "held": func(i *Inputs) { i.Hold = "Wait" }, |
| + "large": func(i *Inputs) { i.Change.Files = 201; i.Change.Lines = 5000 }, |
| + "binary": func(i *Inputs) { i.Change.Binary = 1 }, |
| + "special": func(i *Inputs) { i.Change.Special = true }, |
| + "signing": func(i *Inputs) { i.Change.Signing = true }, |
| + "gate-files": func(i *Inputs) { i.Change.GateFilesChanged = true }, |
| + "short-review": func(i *Inputs) { i.Change.ReviewTruncated = true }, |
| + "incomplete": func(i *Inputs) { i.Change.Complete = false }, |
| + "missing": func(i *Inputs) { i.Change = nil }, |
| + "ask": func(i *Inputs) { i.Policy.Mode = ModeAsk }, |
| + "person": func(i *Inputs) { i.Person = true }, |
| + } |
| + all := map[string]map[int]Decision{} |
| + for name, change := range cases { |
| + all[name] = map[int]Decision{} |
| + for _, protocol := range []int{27, 28, 30, 31} { |
| + in := passing() |
| + in.Protocol = protocol |
| + change(&in) |
| + all[name][protocol] = Decide(in) |
| + } |
| + } |
| + got, err := json.MarshalIndent(all, "", " ") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + got = append(got, '\n') |
| + file := filepath.Join("testdata", "presentation-gate.json") |
| + if os.Getenv("EQUIPO_CAPTURE_GATE_BASELINE") == "1" { |
| + if err := os.MkdirAll("testdata", 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := os.WriteFile(file, got, 0600); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + want, err := os.ReadFile(file) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if string(got) != string(want) { |
| + t.Fatal("Review gate decisions changed from main baseline") |
| + } |
| +} |
diff --git a/internal/equipo/mergegate/testdata/presentation-gate.json b/internal/equipo/mergegate/testdata/presentation-gate.json| new file mode 100644 |
| index 00000000..1867c53b |
| --- /dev/null |
| +++ b/internal/equipo/mergegate/testdata/presentation-gate.json |
| @@ -0,0 +1,2696 @@ |
| +{ |
| + "ask": { |
| + "27": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": false |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": false, |
| + "value": "ask" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "28": { |
| + "class": "ask", |
| + "stance": "merge", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": false, |
| + "value": "ask" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "30": { |
| + "class": "ask", |
| + "stance": "merge", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": false, |
| + "value": "ask" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "31": { |
| + "class": "ask", |
| + "stance": "merge", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": false, |
| + "value": "ask" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + } |
| + }, |
| + "binary": { |
| + "27": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": false |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": false |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "28": { |
| + "class": "ask", |
| + "stance": "merge", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": false |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "30": { |
| + "class": "ask", |
| + "stance": "merge", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": false |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "31": { |
| + "class": "ask", |
| + "stance": "merge", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": false |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + } |
| + }, |
| + "checked": { |
| + "27": { |
| + "class": "ask", |
| + "stance": "merge", |
| + "checks": true, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "first_ready_checked", |
| + "ok": true |
| + }, |
| + { |
| + "name": "checked_in_sandbox", |
| + "ok": true |
| + }, |
| + { |
| + "name": "trusted_base_checks", |
| + "ok": true |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": false |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "28": { |
| + "class": "act", |
| + "checks": true, |
| + "decided_by": "policy", |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "first_ready_checked", |
| + "ok": true |
| + }, |
| + { |
| + "name": "checked_in_sandbox", |
| + "ok": true |
| + }, |
| + { |
| + "name": "trusted_base_checks", |
| + "ok": true |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "30": { |
| + "class": "act", |
| + "checks": true, |
| + "decided_by": "policy", |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "first_ready_checked", |
| + "ok": true |
| + }, |
| + { |
| + "name": "checked_in_sandbox", |
| + "ok": true |
| + }, |
| + { |
| + "name": "trusted_base_checks", |
| + "ok": true |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "31": { |
| + "class": "act", |
| + "checks": true, |
| + "decided_by": "policy", |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "first_ready_checked", |
| + "ok": true |
| + }, |
| + { |
| + "name": "checked_in_sandbox", |
| + "ok": true |
| + }, |
| + { |
| + "name": "trusted_base_checks", |
| + "ok": true |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + } |
| + }, |
| + "failed": { |
| + "27": { |
| + "class": "never", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": false, |
| + "value": "failed" |
| + } |
| + ] |
| + }, |
| + "28": { |
| + "class": "never", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": false, |
| + "value": "failed" |
| + } |
| + ] |
| + }, |
| + "30": { |
| + "class": "never", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": false, |
| + "value": "failed" |
| + } |
| + ] |
| + }, |
| + "31": { |
| + "class": "never", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": false, |
| + "value": "failed" |
| + } |
| + ] |
| + } |
| + }, |
| + "gate-files": { |
| + "27": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": false |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": false |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "28": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": false |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "30": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": false |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "31": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": false |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + } |
| + }, |
| + "held": { |
| + "27": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": false |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": false |
| + } |
| + ] |
| + }, |
| + "28": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": false |
| + } |
| + ] |
| + }, |
| + "30": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": false |
| + } |
| + ] |
| + }, |
| + "31": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": false |
| + } |
| + ] |
| + } |
| + }, |
| + "incomplete": { |
| + "27": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": false |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": false |
| + }, |
| + { |
| + "name": "small", |
| + "ok": false |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": false |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "28": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": false |
| + }, |
| + { |
| + "name": "small", |
| + "ok": false |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": false |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "30": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": false |
| + }, |
| + { |
| + "name": "small", |
| + "ok": false |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": false |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "31": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": false |
| + }, |
| + { |
| + "name": "small", |
| + "ok": false |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": false |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + } |
| + }, |
| + "large": { |
| + "27": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": false |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": false |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "28": { |
| + "class": "ask", |
| + "stance": "merge", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": false |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "30": { |
| + "class": "ask", |
| + "stance": "merge", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": false |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "31": { |
| + "class": "ask", |
| + "stance": "merge", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": false |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + } |
| + }, |
| + "missing": { |
| + "27": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": false |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": false |
| + }, |
| + { |
| + "name": "small", |
| + "ok": false |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": false |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "28": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": false |
| + }, |
| + { |
| + "name": "small", |
| + "ok": false |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": false |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "30": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": false |
| + }, |
| + { |
| + "name": "small", |
| + "ok": false |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": false |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "31": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": false |
| + }, |
| + { |
| + "name": "small", |
| + "ok": false |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": false |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + } |
| + }, |
| + "not-approved": { |
| + "27": { |
| + "class": "never", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": false |
| + } |
| + ] |
| + }, |
| + "28": { |
| + "class": "never", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": false |
| + } |
| + ] |
| + }, |
| + "30": { |
| + "class": "never", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": false |
| + } |
| + ] |
| + }, |
| + "31": { |
| + "class": "never", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": false |
| + } |
| + ] |
| + } |
| + }, |
| + "ordinary": { |
| + "27": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": false |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "28": { |
| + "class": "act", |
| + "checks": false, |
| + "decided_by": "policy", |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "30": { |
| + "class": "act", |
| + "checks": false, |
| + "decided_by": "policy", |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "31": { |
| + "class": "act", |
| + "checks": false, |
| + "decided_by": "policy", |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + } |
| + }, |
| + "person": { |
| + "27": { |
| + "class": "act", |
| + "checks": false, |
| + "decided_by": "person", |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "28": { |
| + "class": "act", |
| + "checks": false, |
| + "decided_by": "person", |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "30": { |
| + "class": "act", |
| + "checks": false, |
| + "decided_by": "person", |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "31": { |
| + "class": "act", |
| + "checks": false, |
| + "decided_by": "person", |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + } |
| + ] |
| + } |
| + }, |
| + "short-review": { |
| + "27": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": false |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": false |
| + }, |
| + { |
| + "name": "small", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "28": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": false |
| + }, |
| + { |
| + "name": "small", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "30": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": false |
| + }, |
| + { |
| + "name": "small", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "31": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": false |
| + }, |
| + { |
| + "name": "small", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": true |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + } |
| + }, |
| + "signing": { |
| + "27": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": false |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": false |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "28": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": false |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "30": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": false |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "31": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": false |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + } |
| + }, |
| + "special": { |
| + "27": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": false |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": false |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "28": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": false |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "30": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": false |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + }, |
| + "31": { |
| + "class": "ask", |
| + "stance": "wait", |
| + "checks": false, |
| + "reasons": [ |
| + { |
| + "name": "approved_exact_sha", |
| + "ok": true |
| + }, |
| + { |
| + "name": "environment_reason", |
| + "ok": true, |
| + "value": "needs_macos" |
| + }, |
| + { |
| + "name": "runner_protocol", |
| + "ok": true |
| + }, |
| + { |
| + "name": "facts_present", |
| + "ok": true |
| + }, |
| + { |
| + "name": "gate_files_unchanged", |
| + "ok": true |
| + }, |
| + { |
| + "name": "review_diff_complete", |
| + "ok": true |
| + }, |
| + { |
| + "name": "small", |
| + "ok": true |
| + }, |
| + { |
| + "name": "not_sensitive", |
| + "ok": false |
| + }, |
| + { |
| + "name": "main_does_not_ship", |
| + "ok": true, |
| + "value": "no" |
| + }, |
| + { |
| + "name": "policy_allows", |
| + "ok": true, |
| + "value": "rules" |
| + }, |
| + { |
| + "name": "no_hold", |
| + "ok": true |
| + } |
| + ] |
| + } |
| + } |
| +} |
diff --git a/internal/equipo/migrations/0108_change_files.sql b/internal/equipo/migrations/0108_change_files.sql| new file mode 100644 |
| index 00000000..c5c326c3 |
| --- /dev/null |
| +++ b/internal/equipo/migrations/0108_change_files.sql |
| @@ -0,0 +1,2 @@ |
| +-- Bounded Engineering file-list facts, never merge authority. |
| +ALTER TABLE chat_steps ADD COLUMN change_files text; |
diff --git a/internal/equipo/migrations/schema.sql b/internal/equipo/migrations/schema.sql| index b766173e..7cd610ab 100644 |
| --- a/internal/equipo/migrations/schema.sql |
| +++ b/internal/equipo/migrations/schema.sql |
| @@ -777,3 +777,6 @@ ALTER TABLE chat_cards ADD COLUMN carry_on numeric; |
| ALTER TABLE chat_cards ADD COLUMN carry_on_connection text; |
| ALTER TABLE chat_releases ADD COLUMN connection text; |
| ALTER TABLE chat_steps ADD COLUMN coordinator_attempt integer; |
| + |
| +-- Bounded Engineering file-list facts, never merge authority. |
| +ALTER TABLE chat_steps ADD COLUMN change_files text; |
diff --git a/internal/runner/thin/change_files.go b/internal/runner/thin/change_files.go| new file mode 100644 |
| index 00000000..454b0495 |
| --- /dev/null |
| +++ b/internal/runner/thin/change_files.go |
| @@ -0,0 +1,97 @@ |
| +package thin |
| + |
| +import ( |
| + "context" |
| + "encoding/json" |
| + "math" |
| + "os/exec" |
| + "strings" |
| + |
| + "amadan.net/oficina/equipo/internal/runner/workspace" |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +// changeFiles reuses Review's NUL-safe parsers, without changing its |
| +// measurement or its conservative 200-file merge-authority bound. |
| +func changeFiles(ctx context.Context, git, gitDir, base, sha string) *wire.ChangeFiles { |
| + if base != "" && !shaPattern.MatchString(base) || !shaPattern.MatchString(sha) { |
| + return nil |
| + } |
| + run := func(args ...string) (string, bool) { |
| + cmd := exec.CommandContext(ctx, git, append([]string{"--git-dir=" + gitDir, "-c", "core.quotePath=false"}, args...)...) |
| + env := workspace.GitEnvironment() |
| + env["HOME"] = "/nonexistent" |
| + for k, v := range env { |
| + cmd.Env = append(cmd.Env, k+"="+v) |
| + } |
| + out, clipped, err := boundedOutput(cmd, factsOutput) |
| + return string(out), err == nil && !clipped |
| + } |
| + pair := []string{base, sha} |
| + if base == "" { |
| + parents, ok := run("rev-list", "--parents", "-n", "1", sha) |
| + if !ok || strings.TrimSpace(parents) != sha { |
| + return nil |
| + } |
| + pair = []string{"--root", "--no-commit-id", sha} |
| + } else if _, ok := run("merge-base", "--is-ancestor", base, sha); !ok { |
| + return nil |
| + } |
| + raw, ok1 := run(append([]string{"diff-tree", "-r", "-z", "--raw", "-M", "--no-abbrev", "--no-ext-diff", "--no-textconv"}, pair...)...) |
| + num, ok2 := run(append([]string{"diff-tree", "-r", "-z", "--numstat", "-M", "--no-ext-diff", "--no-textconv"}, pair...)...) |
| + if !ok1 || !ok2 { |
| + return nil |
| + } |
| + return changeFileListings(base, sha, raw, num) |
| +} |
| + |
| +func changeFileListings(base, sha, raw, num string) *wire.ChangeFiles { |
| + entries, ok1 := parseRaw(raw) |
| + stats, ok2 := parseNumstat(num) |
| + if !ok1 || !ok2 || len(entries) != len(stats) { |
| + return nil |
| + } |
| + f := &wire.ChangeFiles{Base: base, SHA: sha, Files: len(entries), Entries: []wire.ChangedFile{}} |
| + for i, e := range entries { |
| + s := stats[i] |
| + if s.path != e.New || s.old != e.Old || s.added > math.MaxInt-f.Additions || s.deleted > math.MaxInt-f.Deletions { |
| + return nil |
| + } |
| + f.Additions += s.added |
| + f.Deletions += s.deleted |
| + if s.binary { |
| + f.Binary++ |
| + } |
| + status := "" |
| + switch e.Status[0] { |
| + case 'A': |
| + status = "added" |
| + case 'D': |
| + status = "deleted" |
| + case 'M', 'T': |
| + status = "modified" |
| + case 'R': |
| + status = "renamed" |
| + default: |
| + return nil |
| + } |
| + if len(f.Entries) < wire.MaxChangeEntries { |
| + if !wire.ValidChangePath(e.New) || e.Old != "" && !wire.ValidChangePath(e.Old) { |
| + return nil |
| + } |
| + f.Entries = append(f.Entries, wire.ChangedFile{Path: e.New, OldPath: e.Old, Status: status, Additions: s.added, Deletions: s.deleted, Binary: s.binary}) |
| + } |
| + } |
| + for { |
| + f.Truncated = len(f.Entries) < f.Files |
| + encoded, _ := json.Marshal(f) |
| + if len(encoded) <= wire.MaxChangeFilesBytes { |
| + break |
| + } |
| + f.Entries = f.Entries[:len(f.Entries)-1] |
| + } |
| + if !wire.ValidChangeFiles(f) { |
| + return nil |
| + } |
| + return f |
| +} |
diff --git a/internal/runner/thin/change_files_test.go b/internal/runner/thin/change_files_test.go| new file mode 100644 |
| index 00000000..2dbc9291 |
| --- /dev/null |
| +++ b/internal/runner/thin/change_files_test.go |
| @@ -0,0 +1,150 @@ |
| +package thin |
| + |
| +import ( |
| + "context" |
| + "encoding/json" |
| + "fmt" |
| + "os" |
| + "path/filepath" |
| + "strings" |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/equipo/mergegate" |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +func TestEngineeringChangeFiles(t *testing.T) { |
| + dir, git := factsRepo(t) |
| + base := git("rev-parse", "HEAD") |
| + git("mv", "README.md", "read me 日本語.md") |
| + git("rm", "Sources/Pane.swift") |
| + writeFile(t, dir, "new space.txt", "one\ntwo\n") |
| + writeFile(t, dir, "assets/icon.png", "\x89PNG\x00changed") |
| + git("add", "-A") |
| + git("commit", "-qm", "candidate") |
| + sha := git("rev-parse", "HEAD") |
| + before := measure(t, dir, base, sha, "") |
| + decision := func(f *wire.ChangeFacts) []byte { |
| + b, err := json.Marshal(mergegate.Decide(mergegate.Inputs{Candidate: sha, Verdict: wire.VerdictApprove, Checks: wire.ChecksPassed, BaseChecks: true, Eligible: true, Change: f, Protocol: wire.ProtocolCurrent, Policy: mergegate.DefaultPolicy()})) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + return b |
| + } |
| + previous := string(decision(before)) |
| + f := changeFiles(context.Background(), "/usr/bin/git", filepath.Join(dir, ".git"), base, sha) |
| + if f == nil || f.Base != base || f.SHA != sha || f.Files != 4 || f.Additions != 2 || f.Deletions != 1 || f.Binary != 1 || f.Truncated || len(f.Entries) != 4 { |
| + t.Fatalf("facts: %+v", f) |
| + } |
| + entries := map[string]wire.ChangedFile{} |
| + for _, e := range f.Entries { |
| + entries[e.Path] = e |
| + } |
| + if e := entries["read me 日本語.md"]; e.Status != "renamed" || e.OldPath != "README.md" { |
| + t.Fatalf("rename: %+v", e) |
| + } |
| + if e := entries["Sources/Pane.swift"]; e.Status != "deleted" || e.Deletions != 1 { |
| + t.Fatalf("delete: %+v", e) |
| + } |
| + if e := entries["assets/icon.png"]; !e.Binary || e.Status != "modified" || e.Additions != 0 { |
| + t.Fatalf("binary: %+v", e) |
| + } |
| + if e := entries["new space.txt"]; e.Status != "added" || e.Additions != 2 { |
| + t.Fatalf("added: %+v", e) |
| + } |
| + after := measure(t, dir, base, sha, "") |
| + a, _ := json.Marshal(before) |
| + b, _ := json.Marshal(after) |
| + if string(a) != string(b) || previous != string(decision(after)) { |
| + t.Fatal("presentation changed Review facts or gate decision") |
| + } |
| + if changeFiles(context.Background(), "/usr/bin/git", filepath.Join(dir, ".git"), sha, base) != nil { |
| + t.Fatal("nonancestor accepted") |
| + } |
| +} |
| + |
| +func TestChangeFilesBounds(t *testing.T) { |
| + dir, git := factsRepo(t) |
| + base := git("rev-parse", "HEAD") |
| + for i := 0; i < wire.MaxChangeEntries+3; i++ { |
| + writeFile(t, dir, fmt.Sprintf("many/%03d.txt", i), "one\n") |
| + } |
| + git("add", "-A") |
| + git("commit", "-qm", "many") |
| + f := changeFiles(context.Background(), "/usr/bin/git", filepath.Join(dir, ".git"), base, git("rev-parse", "HEAD")) |
| + if f == nil || len(f.Entries) != 200 || !f.Truncated || f.Files != 203 || f.Additions != 203 || f.Deletions != 0 { |
| + t.Fatalf("bounded exact totals: %+v", f) |
| + } |
| +} |
| + |
| +func TestChangeFilesByteBoundAndMalformedListings(t *testing.T) { |
| + base, sha := strings.Repeat("a", 40), strings.Repeat("b", 40) |
| + var raw, num strings.Builder |
| + for i := 0; i < 200; i++ { |
| + name := fmt.Sprintf("%03d/%s", i, strings.Repeat("x", 3900)) |
| + fmt.Fprintf(&raw, ":000000 100644 %s %s A\x00%s\x00", base, sha, name) |
| + fmt.Fprintf(&num, "1\t0\t%s\x00", name) |
| + } |
| + f := changeFileListings(base, sha, raw.String(), num.String()) |
| + if f == nil || !f.Truncated || len(f.Entries) >= 200 || len(f.Entries) == 0 || f.Files != 200 || f.Additions != 200 { |
| + t.Fatalf("byte bound: %+v", f) |
| + } |
| + encoded, _ := json.Marshal(f) |
| + if len(encoded) > wire.MaxChangeFilesBytes { |
| + t.Fatalf("encoded %d bytes", len(encoded)) |
| + } |
| + for name, parts := range map[string][2]string{ |
| + "bad-raw": {"not raw", num.String()}, |
| + "bad-num": {raw.String(), "not numstat"}, |
| + "missing-stat": {raw.String(), ""}, |
| + "mismatched-path": {":000000 100644 " + base + " " + sha + " A\x00one\x00", "1\t0\ttwo\x00"}, |
| + "traversal": {":000000 100644 " + base + " " + sha + " A\x00../secret\x00", "1\t0\t../secret\x00"}, |
| + } { |
| + t.Run(name, func(t *testing.T) { |
| + if changeFileListings(base, sha, parts[0], parts[1]) != nil { |
| + t.Fatal("malformed listing accepted") |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestChangeFilesClippedScanNeverInventsTotals(t *testing.T) { |
| + dir := t.TempDir() |
| + fake := filepath.Join(dir, "git") |
| + // Exactly 4096 complete raw records fit the 1 MiB read bound. A final |
| + // complete record is clipped, so parsing the prefix alone would look valid. |
| + script := `#!/usr/bin/python3 |
| +import sys |
| +head=":000000 100644 "+"a"*40+" "+"b"*40+" A\0" |
| +width=256-len(head)-1 |
| +if "--raw" in sys.argv: |
| + for i in range(4097): |
| + name=str(i).zfill(width) |
| + sys.stdout.buffer.write((head+name+"\0").encode()) |
| +elif "--numstat" in sys.argv: |
| + for i in range(4096): |
| + sys.stdout.buffer.write(("1\t0\t"+str(i).zfill(width)+"\0").encode()) |
| +` |
| + if err := os.WriteFile(fake, []byte(script), 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + f := changeFiles(context.Background(), fake, dir, strings.Repeat("a", 40), strings.Repeat("b", 40)) |
| + if f != nil { |
| + t.Fatalf("clipped scan has invented totals: %+v", f) |
| + } |
| +} |
| + |
| +func TestChangeFilesInitialCommit(t *testing.T) { |
| + dir, git := factsRepo(t) |
| + root := git("rev-parse", "HEAD") |
| + f := changeFiles(context.Background(), "/usr/bin/git", filepath.Join(dir, ".git"), "", root) |
| + if f == nil || f.Base != "" || f.SHA != root || f.Files != 5 { |
| + t.Fatalf("initial commit: %+v", f) |
| + } |
| + writeFile(t, dir, "later.txt", "later\n") |
| + git("add", "-A") |
| + git("commit", "-qm", "later") |
| + if changeFiles(context.Background(), "/usr/bin/git", filepath.Join(dir, ".git"), "", git("rev-parse", "HEAD")) != nil { |
| + t.Fatal("missing base on non-root commit was guessed") |
| + } |
| +} |
diff --git a/internal/runner/thin/engineer.go b/internal/runner/thin/engineer.go| index ee0d9f89..d04cfe45 100644 |
| --- a/internal/runner/thin/engineer.go |
| +++ b/internal/runner/thin/engineer.go |
| @@ -420,6 +420,9 @@ func (e *Engineer) publish(ctx context.Context, r stepRow, rep wire.StepReport) |
| tree.GitDir = from |
| } |
| } |
| + if r.Specialist == wire.SpecialistEngineering { |
| + rep.ChangeFiles = changeFiles(ctx, tree.Git, tree.GitDir, r.Base, r.Candidate) |
| + } |
| expectedHead := "" |
| if r.Specialist == wire.SpecialistCopy { |
| expectedHead = r.CandidateSHA |
diff --git a/internal/runner/thin/sandbox_masks_test.go b/internal/runner/thin/sandbox_masks_test.go| index 61017f81..15a29685 100644 |
| --- a/internal/runner/thin/sandbox_masks_test.go |
| +++ b/internal/runner/thin/sandbox_masks_test.go |
| @@ -91,10 +91,14 @@ func TestSandboxMasksPublish(t *testing.T) { |
| t.Fatalf("real file removed: %v", err) |
| } |
| r.Candidate = sha |
| + r.Specialist = wire.SpecialistEngineering |
| rep := e.publish(ctx, r, wire.StepReport{}) |
| if rep.State != wire.StepDone || !rep.Pushed { |
| t.Fatalf("publish: %+v", rep) |
| } |
| + if rep.ChangeFiles == nil || rep.ChangeFiles.Base != r.Base || rep.ChangeFiles.SHA != sha || !wire.ValidChangeFiles(rep.ChangeFiles) { |
| + t.Fatalf("published candidate has no display facts: %+v", rep.ChangeFiles) |
| + } |
| paths := "\n" + gitOut(t, f.dir, "ls-tree", "-r", "--name-only", r.Branch) + "\n" |
| if kind == "placeholders" { |
| for _, p := range maskTestPaths { |
diff --git a/internal/thintest/change_files_contract_test.go b/internal/thintest/change_files_contract_test.go| new file mode 100644 |
| index 00000000..fe99ac67 |
| --- /dev/null |
| +++ b/internal/thintest/change_files_contract_test.go |
| @@ -0,0 +1,54 @@ |
| +package thintest |
| + |
| +import ( |
| + "encoding/json" |
| + "reflect" |
| + "strings" |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +func TestContractEngineeringChangeFiles(t *testing.T) { |
| + for _, protocol := range []int{wire.ProtocolChangeFiles, wire.ProtocolChangeFiles - 1} { |
| + t.Run(string(rune('A'+protocol)), func(t *testing.T) { |
| + r := newToolRigAt(t, protocol) |
| + base, cand := strings.Repeat("1", 40), strings.Repeat("2", 40) |
| + id := taskID(t, r.call("files-record", wire.ToolRecordTask, map[string]any{"repo": "oficina/sample", "title": "Changed file facts", "brief": "Adjust the README", "separate": true})) |
| + if res := r.call("files-start", wire.ToolStartTask, map[string]string{"task": id, "brief": "Adjust it"}); res.IsError { |
| + t.Fatal(res) |
| + } |
| + _, body := r.expect(wire.FrameDispatch) |
| + eng := body.(*wire.DispatchCommand) |
| + facts := &wire.ChangeFiles{Base: base, SHA: cand, Files: 2, Additions: 3, Deletions: 1, Entries: []wire.ChangedFile{ |
| + {Path: "docs/read me 日本語.md", OldPath: "README.md", Status: "renamed", Additions: 3, Deletions: 1}, |
| + {Path: "empty.txt", Status: "added"}, |
| + }} |
| + r.step("files-done", wire.StepReport{TaskID: id, StepID: eng.StepID, Attempt: eng.Attempt, State: wire.StepDone, BaseSHA: base, CandidateSHA: cand, Pushed: true, Termination: true, ChangeFiles: facts}) |
| + task, err := r.client.Task(r.ctx, id) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + got := task.Steps[0].ChangeFiles |
| + if protocol < 31 { |
| + if got != nil { |
| + t.Fatalf("old runner facts: %+v", got) |
| + } |
| + return |
| + } |
| + if !reflect.DeepEqual(got, facts) { |
| + t.Fatalf("device facts: %+v", got) |
| + } |
| + raw, _ := json.Marshal(got) |
| + for _, secret := range []string{"review_step", "old_mode", "new_mode", "complete", "repo", "content", "token"} { |
| + if strings.Contains(string(raw), "\""+secret+"\"") { |
| + t.Fatalf("non-display field: %s", raw) |
| + } |
| + } |
| + // Engineering presentation is never Review's accepted merge evidence. |
| + if task.MergeDecision != nil { |
| + t.Fatalf("Engineering facts made a merge decision: %+v", task.MergeDecision) |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/wire/assistant_test.go b/internal/wire/assistant_test.go| index 3d0b8ab5..4e8a748b 100644 |
| --- a/internal/wire/assistant_test.go |
| +++ b/internal/wire/assistant_test.go |
| @@ -81,7 +81,7 @@ func TestAssistantCardJSON(t *testing.T) { |
| // A runner that speaks 24 or more is spoken to at 24, the warm |
| // protocol; glances came at 23 and jobs at 22. |
| func TestSpokenIs24(t *testing.T) { |
| - if wire.Spoken(99) != 30 || wire.ProtocolCurrent != wire.ProtocolStuckTasks || wire.ProtocolWarm != wire.Protocol24 || wire.ProtocolGlance != wire.Protocol23 || wire.ProtocolJobs != wire.Protocol22 || wire.ProtocolCopy != wire.Protocol21 || wire.ProtocolUsageRefresh != wire.Protocol20 || wire.ProtocolAssistant != wire.Protocol19 { |
| + if wire.Spoken(99) != 31 || wire.ProtocolCurrent != wire.ProtocolChangeFiles || wire.ProtocolWarm != wire.Protocol24 || wire.ProtocolGlance != wire.Protocol23 || wire.ProtocolJobs != wire.Protocol22 || wire.ProtocolCopy != wire.Protocol21 || wire.ProtocolUsageRefresh != wire.Protocol20 || wire.ProtocolAssistant != wire.Protocol19 { |
| t.Fatalf("spoken %d, current %d", wire.Spoken(99), wire.ProtocolCurrent) |
| } |
| } |
diff --git a/internal/wire/change_files.go b/internal/wire/change_files.go| new file mode 100644 |
| index 00000000..fbac95e6 |
| --- /dev/null |
| +++ b/internal/wire/change_files.go |
| @@ -0,0 +1,84 @@ |
| +package wire |
| + |
| +import ( |
| + "encoding/json" |
| + "path" |
| + "strings" |
| + "unicode" |
| + "unicode/utf8" |
| +) |
| + |
| +// ChangeFiles is presentation only. Merge authority consumes ChangeFacts, |
| +// independently measured by Review, never these Engineering measurements. |
| +type ChangeFiles struct { |
| + Base string `json:"base"` |
| + SHA string `json:"sha"` |
| + Files int `json:"files"` |
| + Additions int `json:"additions"` |
| + Deletions int `json:"deletions"` |
| + Binary int `json:"binary"` |
| + Entries []ChangedFile `json:"entries"` |
| + Truncated bool `json:"truncated"` |
| +} |
| +type ChangedFile struct { |
| + Path string `json:"path"` |
| + OldPath string `json:"old_path,omitempty"` |
| + Status string `json:"status"` |
| + Additions int `json:"additions"` |
| + Deletions int `json:"deletions"` |
| + Binary bool `json:"binary"` |
| +} |
| + |
| +// MaxChangeFilesBytes leaves room for the rest of a bounded StepReport. |
| +const MaxChangeFilesBytes = 96 << 10 |
| + |
| +func ValidChangePath(s string) bool { |
| + return s != "" && len(s) <= 4096 && utf8.ValidString(s) && !strings.HasPrefix(s, "/") && |
| + s != "." && s != ".." && !strings.HasPrefix(s, "../") && path.Clean(s) == s && |
| + !strings.ContainsAny(s, "\\") && strings.IndexFunc(s, unicode.IsControl) < 0 |
| +} |
| + |
| +func ValidChangeFiles(f *ChangeFiles) bool { |
| + if f == nil || f.Entries == nil || f.Base != "" && len(f.Base) != 40 || len(f.SHA) != 40 || strings.Trim(f.Base+f.SHA, "0123456789abcdef") != "" || |
| + f.Files < 0 || f.Additions < 0 || f.Deletions < 0 || f.Binary < 0 || f.Binary > f.Files || |
| + len(f.Entries) > MaxChangeEntries || len(f.Entries) > f.Files || f.Truncated != (len(f.Entries) < f.Files) { |
| + return false |
| + } |
| + a, d, b := 0, 0, 0 |
| + seen := map[string]bool{} |
| + for _, e := range f.Entries { |
| + if !ValidChangePath(e.Path) || seen[e.Path] || e.Additions < 0 || e.Deletions < 0 { |
| + return false |
| + } |
| + seen[e.Path] = true |
| + switch e.Status { |
| + case "added", "modified", "deleted": |
| + if e.OldPath != "" { |
| + return false |
| + } |
| + case "renamed": |
| + if !ValidChangePath(e.OldPath) || e.OldPath == e.Path { |
| + return false |
| + } |
| + default: |
| + return false |
| + } |
| + // Subtraction checks also prevent integer overflow. |
| + if e.Additions > f.Additions-a || e.Deletions > f.Deletions-d { |
| + return false |
| + } |
| + a += e.Additions |
| + d += e.Deletions |
| + if e.Binary { |
| + b++ |
| + if e.Additions != 0 || e.Deletions != 0 { |
| + return false |
| + } |
| + } |
| + } |
| + if b > f.Binary || !f.Truncated && (a != f.Additions || d != f.Deletions || b != f.Binary) { |
| + return false |
| + } |
| + raw, err := json.Marshal(f) |
| + return err == nil && len(raw) <= MaxChangeFilesBytes |
| +} |
diff --git a/internal/wire/change_files_test.go b/internal/wire/change_files_test.go| new file mode 100644 |
| index 00000000..cd09f207 |
| --- /dev/null |
| +++ b/internal/wire/change_files_test.go |
| @@ -0,0 +1,93 @@ |
| +package wire_test |
| + |
| +import ( |
| + "encoding/json" |
| + "fmt" |
| + "strings" |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/wire" |
| +) |
| + |
| +func TestProtocol31ChangeFiles(t *testing.T) { |
| + if wire.ProtocolChangeFiles != 31 || wire.ProtocolCurrent != 31 { |
| + t.Fatal("protocol not 31") |
| + } |
| + facts := &wire.ChangeFiles{Base: strings.Repeat("a", 40), SHA: strings.Repeat("b", 40), Files: 1, Additions: 1, Entries: []wire.ChangedFile{{Path: "a.txt", Status: "added", Additions: 1}}} |
| + report := wire.StepReport{StepID: "s", Attempt: 1, State: wire.StepDone, ChangeFiles: facts} |
| + f, err := wire.NewFrame("r", wire.FrameStep, report) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + for p := 1; p <= 31; p++ { |
| + got, err := wire.Encode(f, p) |
| + if err != nil { |
| + t.Fatalf("%d: %v", p, err) |
| + } |
| + var fields map[string]json.RawMessage |
| + if err := json.Unmarshal(got.Data, &fields); err != nil { |
| + t.Fatal(err) |
| + } |
| + if (fields["change_files"] != nil) != (p >= 31) { |
| + t.Fatalf("field at %d: %s", p, got.Data) |
| + } |
| + if p < 31 { |
| + frozen13(t, "pre-31 StepReport", got.Data, frozen30StepReport) |
| + } |
| + |
| + } |
| + if report.ChangeFiles == nil { |
| + t.Fatal("Encode mutated input") |
| + } |
| +} |
| + |
| +func TestChangeFilesValidation(t *testing.T) { |
| + valid := func() *wire.ChangeFiles { |
| + return &wire.ChangeFiles{Base: strings.Repeat("a", 40), SHA: strings.Repeat("b", 40), Files: 1, Additions: 1, Entries: []wire.ChangedFile{{Path: "dir/a 日本語.txt", Status: "added", Additions: 1}}} |
| + } |
| + if !wire.ValidChangeFiles(valid()) { |
| + t.Fatal("valid paths refused") |
| + } |
| + for name, mutate := range map[string]func(*wire.ChangeFiles){ |
| + "nil-list": func(f *wire.ChangeFiles) { f.Files = 0; f.Additions = 0; f.Entries = nil }, |
| + "base": func(f *wire.ChangeFiles) { f.Base = "main" }, |
| + "sha": func(f *wire.ChangeFiles) { f.SHA = strings.Repeat("z", 40) }, |
| + "negative": func(f *wire.ChangeFiles) { f.Additions = -1 }, |
| + "totals": func(f *wire.ChangeFiles) { f.Additions = 2 }, |
| + "truncation": func(f *wire.ChangeFiles) { f.Files = 2 }, |
| + "status": func(f *wire.ChangeFiles) { f.Entries[0].Status = "copy" }, |
| + "old": func(f *wire.ChangeFiles) { f.Entries[0].OldPath = "old" }, |
| + "rename": func(f *wire.ChangeFiles) { f.Entries[0].Status = "renamed" }, |
| + "binary": func(f *wire.ChangeFiles) { f.Entries[0].Binary = true }, |
| + "path": func(f *wire.ChangeFiles) { f.Entries[0].Path = "../evil" }, |
| + "control": func(f *wire.ChangeFiles) { f.Entries[0].Path = "a\nb" }, |
| + "byte-bound": func(f *wire.ChangeFiles) { |
| + f.Files = 200 |
| + f.Additions = 200 |
| + f.Entries = []wire.ChangedFile{} |
| + for i := 0; i < 200; i++ { |
| + f.Entries = append(f.Entries, wire.ChangedFile{Path: fmt.Sprintf("%d/%s", i, strings.Repeat("x", 2000)), Status: "added", Additions: 1}) |
| + } |
| + }, |
| + "duplicate": func(f *wire.ChangeFiles) { f.Files = 2; f.Additions = 2; f.Entries = append(f.Entries, f.Entries[0]) }, |
| + "bound": func(f *wire.ChangeFiles) { |
| + f.Files = 201 |
| + f.Additions = 201 |
| + f.Entries = []wire.ChangedFile{} |
| + for i := 0; i < 201; i++ { |
| + f.Entries = append(f.Entries, wire.ChangedFile{Path: fmt.Sprintf("file-%d", i), Status: "added", Additions: 1}) |
| + } |
| + }, |
| + } { |
| + t.Run(name, func(t *testing.T) { |
| + f := valid() |
| + mutate(f) |
| + if wire.ValidChangeFiles(f) { |
| + t.Fatal("invalid accepted") |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// Frozen from main 18fb5be4, before protocol 31. |
| +var frozen30StepReport = keySet("base_checks base_checks_sha failure copy task_id step_id attempt state reason base_sha candidate_sha pushed termination summary headline log_tail family account verdict review_label findings checks gate exit_code output askable merge_sha into strategy usage switched termination_kind have phase apple checks_sandbox change merge_source merge_parents hosted has_preview preview research hold publish") |
diff --git a/internal/wire/injection_test.go b/internal/wire/injection_test.go| index e6678b6c..8e8fad51 100644 |
| --- a/internal/wire/injection_test.go |
| +++ b/internal/wire/injection_test.go |
| @@ -7,7 +7,7 @@ import ( |
| ) |
| func TestInjectionProtocolDowngrade(t *testing.T) { |
| - if wire.ProtocolInjectionDefences != 28 || wire.ProtocolCurrent != 30 { |
| + if wire.ProtocolInjectionDefences != 28 || wire.ProtocolCurrent != 31 { |
| t.Fatal("injection guarantees require protocol 28") |
| } |
| for version, want := range map[int]int{26: 26, 27: 27, 28: 28, 29: 29, 30: 30, 99: 30} { |
diff --git a/internal/wire/mixed_protocol_test.go b/internal/wire/mixed_protocol_test.go| index 38424ed1..73a547f3 100644 |
| --- a/internal/wire/mixed_protocol_test.go |
| +++ b/internal/wire/mixed_protocol_test.go |
| @@ -15,7 +15,7 @@ import ( |
| // both go out whole; at 11 both are downgraded. The numbers are written |
| // out so that pointing ProtocolResearch back at 12 fails here. |
| func TestEncodeMixedMeteredAndResearch(t *testing.T) { |
| - if wire.ProtocolMetered != wire.Protocol12 || wire.ProtocolResearch != wire.Protocol13 || wire.ProtocolCurrent != wire.Protocol30 { |
| + if wire.ProtocolMetered != wire.Protocol12 || wire.ProtocolResearch != wire.Protocol13 || wire.ProtocolCurrent != wire.Protocol31 { |
| t.Fatalf("metered %d, research %d, current %d", wire.ProtocolMetered, wire.ProtocolResearch, wire.ProtocolCurrent) |
| } |
| metered := wire.HeldConnection{LocalID: "tensorx-1", Person: "p", Provider: wire.ProviderTensorX, Kind: wire.KindAPIKey, State: wire.ConnHealthy, Harness: wire.HarnessPi, Upstream: "https://api.tensorx.ai", Billing: wire.BillingMetered, Model: "z-ai/glm-5.3", Budget: &wire.Budget{Day: 1, Month: 2, Currency: "USD"}, Spend: &wire.Spend{Currency: "USD"}} |
diff --git a/internal/wire/models_test.go b/internal/wire/models_test.go| index 28012643..892faa67 100644 |
| --- a/internal/wire/models_test.go |
| +++ b/internal/wire/models_test.go |
| @@ -94,7 +94,7 @@ func modelsFrames(t *testing.T) map[string]wire.Frame { |
| // protocol is checked because an older step in Encode's chain could |
| // undo a newer one (S5's bug). |
| func TestEncodeBelowProtocol18AgainstFrozenSchemas(t *testing.T) { |
| - if wire.ProtocolModels != wire.Protocol18 || wire.ProtocolCurrent != wire.Protocol30 { |
| + if wire.ProtocolModels != wire.Protocol18 || wire.ProtocolCurrent != wire.Protocol31 { |
| t.Fatalf("models %d, current %d", wire.ProtocolModels, wire.ProtocolCurrent) |
| } |
| fs := modelsFrames(t) |
diff --git a/internal/wire/opencode_test.go b/internal/wire/opencode_test.go| index ef98f25b..6458a7ef 100644 |
| --- a/internal/wire/opencode_test.go |
| +++ b/internal/wire/opencode_test.go |
| @@ -57,7 +57,7 @@ func providersIn(t *testing.T, raw []byte) (providers, harnesses []string) { |
| // leave hello and sync, its usage rows leave every report, and a connect |
| // or a report about one is refused. At 17 nothing changes. |
| func TestEncodeBelowProtocol17DropsOpenCode(t *testing.T) { |
| - if wire.ProtocolOpenCode != wire.Protocol17 || wire.ProtocolCurrent != wire.Protocol30 { |
| + if wire.ProtocolOpenCode != wire.Protocol17 || wire.ProtocolCurrent != wire.Protocol31 { |
| t.Fatalf("opencode %d, current %d", wire.ProtocolOpenCode, wire.ProtocolCurrent) |
| } |
| budget := &wire.Budget{Day: 1_000_000, Month: 10_000_000, Currency: "USD", Revision: 1} |
diff --git a/internal/wire/pinned_release_test.go b/internal/wire/pinned_release_test.go| index 0a71599a..aeb0eb6c 100644 |
| --- a/internal/wire/pinned_release_test.go |
| +++ b/internal/wire/pinned_release_test.go |
| @@ -13,7 +13,7 @@ import ( |
| // carrying a pinned release loses the release and its pin; an unpinned |
| // release is unchanged from protocol 14. |
| func TestEncodePinnedReleaseBelow29(t *testing.T) { |
| - if wire.ProtocolPinnedRelease != wire.Protocol29 || wire.ProtocolCurrent != wire.Protocol30 { |
| + if wire.ProtocolPinnedRelease != wire.Protocol29 || wire.ProtocolCurrent != wire.Protocol31 { |
| t.Fatalf("pinned %d, current %d", wire.ProtocolPinnedRelease, wire.ProtocolCurrent) |
| } |
| pinned, err := wire.NewFrame("f1", wire.FrameRelease, wire.ReleaseCommand{ID: "rl_1", Person: "p", TaskID: "tk1", StepID: "s1", StepRevision: 1, Connection: "claude-1"}) |
diff --git a/internal/wire/publish_test.go b/internal/wire/publish_test.go| index 6f940f0d..d47cb0c2 100644 |
| --- a/internal/wire/publish_test.go |
| +++ b/internal/wire/publish_test.go |
| @@ -17,7 +17,7 @@ import ( |
| // and a hello's sites capability are dropped, so nothing a protocol 15 |
| // peer decodes strictly carries them. |
| func TestEncodeBelowProtocol16DropsPublish(t *testing.T) { |
| - if wire.ProtocolPublish != wire.Protocol16 || wire.ProtocolCurrent != wire.Protocol30 { |
| + if wire.ProtocolPublish != wire.Protocol16 || wire.ProtocolCurrent != wire.Protocol31 { |
| t.Fatalf("publish %d, current %d", wire.ProtocolPublish, wire.ProtocolCurrent) |
| } |
| publish := wire.DispatchCommand{Person: "p", TaskID: "tk", StepID: "s", Attempt: 1, Specialist: wire.SpecialistPublish, Findings: []wire.Finding{}, CandidateSHA: strings.Repeat("e", 40), Publish: &wire.PublishDispatch{App: "site-sample", Into: "main"}} |
diff --git a/internal/wire/runners.go b/internal/wire/runners.go| index a1c77dc5..56d363f6 100644 |
| --- a/internal/wire/runners.go |
| +++ b/internal/wire/runners.go |
| @@ -56,6 +56,7 @@ const ( |
| Protocol28 = 28 |
| Protocol29 = 29 |
| Protocol30 = 30 |
| + Protocol31 = 31 |
| // ProtocolSpend is the first protocol with a fix round's Feedback and |
| // a usage row's Turns; Encode drops both below it. |
| ProtocolSpend = Protocol3 |
| @@ -194,7 +195,9 @@ const ( |
| // Below it Encode drops the tool health and refuses the tool's call |
| // (downgradeStuck). |
| ProtocolStuckTasks = Protocol30 |
| - ProtocolCurrent = ProtocolStuckTasks |
| + // ProtocolChangeFiles adds bounded Engineering file-list facts. |
| + ProtocolChangeFiles = Protocol31 |
| + ProtocolCurrent = ProtocolChangeFiles |
| ) |
| // Runner roles. A person's first runner is the primary: the coordinator, |
| @@ -637,6 +640,12 @@ func Encode(f Frame, protocol int) (Frame, error) { |
| } |
| changed = dropped |
| } |
| + if protocol < ProtocolChangeFiles { |
| + if v, ok := body.(*StepReport); ok && v.ChangeFiles != nil { |
| + v.ChangeFiles = nil |
| + changed = true |
| + } |
| + } |
| if protocol < ProtocolPinnedRelease { |
| if v, ok := body.(*ReleaseCommand); ok && v.Connection != "" { |
| return Frame{}, fmt.Errorf("%w: a pinned release at protocol %d", ErrProtocol, protocol) |
diff --git a/internal/wire/runners_test.go b/internal/wire/runners_test.go| index cbf4fdd6..d54328bd 100644 |
| --- a/internal/wire/runners_test.go |
| +++ b/internal/wire/runners_test.go |
| @@ -413,7 +413,7 @@ func TestEncodeBelowProtocol9DropsPreviews(t *testing.T) { |
| if _, err := wire.Encode(d, wire.ProtocolPreview); err != nil { |
| t.Fatal(err) |
| } |
| - if wire.ProtocolCurrent != wire.ProtocolStuckTasks || wire.ProtocolStuckTasks != 30 || wire.ProtocolPinnedRelease != 29 || wire.ProtocolInjectionDefences != 28 || wire.ProtocolWarm != 24 || wire.ProtocolGlance != 23 || wire.ProtocolJobs != 22 || wire.ProtocolCopy != 21 || wire.ProtocolUsageRefresh != 20 || wire.ProtocolAssistant != 19 || wire.ProtocolModels != 18 || wire.ProtocolOpenCode != 17 || wire.ProtocolPublish != 16 || wire.ProtocolReadings != 15 || wire.ProtocolScheduler != 14 || wire.ProtocolResearch != 13 || wire.ProtocolMetered != 12 || wire.ProtocolPreviewHost != 11 || wire.ProtocolExplore != 10 || wire.ProtocolPreview != 9 { |
| + if wire.ProtocolCurrent != wire.ProtocolChangeFiles || wire.ProtocolStuckTasks != 30 || wire.ProtocolPinnedRelease != 29 || wire.ProtocolInjectionDefences != 28 || wire.ProtocolWarm != 24 || wire.ProtocolGlance != 23 || wire.ProtocolJobs != 22 || wire.ProtocolCopy != 21 || wire.ProtocolUsageRefresh != 20 || wire.ProtocolAssistant != 19 || wire.ProtocolModels != 18 || wire.ProtocolOpenCode != 17 || wire.ProtocolPublish != 16 || wire.ProtocolReadings != 15 || wire.ProtocolScheduler != 14 || wire.ProtocolResearch != 13 || wire.ProtocolMetered != 12 || wire.ProtocolPreviewHost != 11 || wire.ProtocolExplore != 10 || wire.ProtocolPreview != 9 { |
| t.Fatalf("current %d", wire.ProtocolCurrent) |
| } |
| } |
diff --git a/internal/wire/schedule_test.go b/internal/wire/schedule_test.go| index 50478281..5eab12b5 100644 |
| --- a/internal/wire/schedule_test.go |
| +++ b/internal/wire/schedule_test.go |
| @@ -17,7 +17,7 @@ import ( |
| // refused anything that spends, never handed it), and a dispatch loses |
| // its priority, deadline and release; what 13 already had is unchanged. |
| func TestEncodeBelowProtocol14DropsScheduler(t *testing.T) { |
| - if wire.ProtocolScheduler != wire.Protocol14 || wire.ProtocolCurrent != wire.Protocol30 { |
| + if wire.ProtocolScheduler != wire.Protocol14 || wire.ProtocolCurrent != wire.Protocol31 { |
| t.Fatalf("scheduler %d, current %d", wire.ProtocolScheduler, wire.ProtocolCurrent) |
| } |
| by := time.Date(2026, 11, 20, 17, 0, 0, 0, time.UTC) |
diff --git a/internal/wire/stuck_test.go b/internal/wire/stuck_test.go| index 337db477..ea32482a 100644 |
| --- a/internal/wire/stuck_test.go |
| +++ b/internal/wire/stuck_test.go |
| @@ -14,7 +14,7 @@ import ( |
| // Stuck tasks (protocol 30): a hello's tool health is a fixed state per |
| // pinned tool, never a path, and an older instance never hears it. |
| func TestProtocol30ToolHealth(t *testing.T) { |
| - if wire.ProtocolStuckTasks != wire.Protocol30 || wire.ProtocolCurrent != wire.Protocol30 || wire.Spoken(99) != 30 { |
| + if wire.ProtocolStuckTasks != wire.Protocol30 || wire.ProtocolCurrent != wire.Protocol31 || wire.Spoken(99) != 31 { |
| t.Fatalf("stuck %d, current %d", wire.ProtocolStuckTasks, wire.ProtocolCurrent) |
| } |
| caps := func(h *wire.ToolHealth) wire.Capabilities { |
diff --git a/internal/wire/tasks.go b/internal/wire/tasks.go| index 951c8126..80596341 100644 |
| --- a/internal/wire/tasks.go |
| +++ b/internal/wire/tasks.go |
| @@ -235,20 +235,21 @@ type StepHosted struct { |
| // forge confirmed the branch points at it. Terminated is the runner's |
| // proof that the attempt's namespace has exited. |
| type Step struct { |
| - BaseChecks string `json:"base_checks,omitempty"` |
| - ID string `json:"id"` |
| - Revision int64 `json:"revision"` |
| - TaskID string `json:"task_id"` |
| - Index int `json:"index"` |
| - Specialist string `json:"specialist"` |
| - State string `json:"state"` |
| - Reason string `json:"reason"` |
| - Attempt int64 `json:"attempt"` |
| - BaseSHA string `json:"base_sha"` |
| - CandidateSHA string `json:"candidate_sha"` |
| - Pushed bool `json:"pushed"` |
| - Terminated bool `json:"terminated"` |
| - Summary string `json:"summary"` |
| + ChangeFiles *ChangeFiles `json:"change_files,omitempty"` |
| + BaseChecks string `json:"base_checks,omitempty"` |
| + ID string `json:"id"` |
| + Revision int64 `json:"revision"` |
| + TaskID string `json:"task_id"` |
| + Index int `json:"index"` |
| + Specialist string `json:"specialist"` |
| + State string `json:"state"` |
| + Reason string `json:"reason"` |
| + Attempt int64 `json:"attempt"` |
| + BaseSHA string `json:"base_sha"` |
| + CandidateSHA string `json:"candidate_sha"` |
| + Pushed bool `json:"pushed"` |
| + Terminated bool `json:"terminated"` |
| + Summary string `json:"summary"` |
| // Headline is the step's outcome in one plain sentence (Engineering's |
| // change, Review's verdict), written by the specialist; Summary has the |
| // rest. Empty when the specialist gave none. |
| @@ -792,6 +793,8 @@ type CancelStepCommand struct { |
| // its candidate), done (pushed), failed or cancelled. Termination is true |
| // once the attempt's namespace exit was observed. Reason is a fixed code. |
| type StepReport struct { |
| + // Protocol 31: Engineering file-list facts, presentation only. |
| + ChangeFiles *ChangeFiles `json:"change_files,omitempty"` |
| BaseChecks string `json:"base_checks,omitempty"` |
| BaseChecksSHA string `json:"base_checks_sha,omitempty"` |
| Failure *copydesk.Signature `json:"failure,omitempty"` |
diff --git a/internal/wire/usage_test.go b/internal/wire/usage_test.go| index 2eeede17..5b254189 100644 |
| --- a/internal/wire/usage_test.go |
| +++ b/internal/wire/usage_test.go |
| @@ -44,7 +44,7 @@ func headrooms(t *testing.T, raw []byte) []map[string]json.RawMessage { |
| // decodes strictly against the frozen protocol 14 headroom, and the |
| // caller's own values are untouched; at 15 nothing changes. |
| func TestEncodeBelowProtocol15DropsReadingTimes(t *testing.T) { |
| - if wire.ProtocolReadings != wire.Protocol15 || wire.ProtocolCurrent != wire.Protocol30 { |
| + if wire.ProtocolReadings != wire.Protocol15 || wire.ProtocolCurrent != wire.Protocol31 { |
| t.Fatalf("readings %d, current %d", wire.ProtocolReadings, wire.ProtocolCurrent) |
| } |
| at := time.Date(2026, 11, 12, 9, 58, 0, 0, time.UTC) |
diff --git a/internal/wire/warm_test.go b/internal/wire/warm_test.go| index 81358c7d..66bd188d 100644 |
| --- a/internal/wire/warm_test.go |
| +++ b/internal/wire/warm_test.go |
| @@ -13,7 +13,7 @@ import ( |
| // other (durable, acked), and Encode refuses it below 24: an older |
| // runner's strict decoder would close the stream on it. |
| func TestEncodeWarmBelow24(t *testing.T) { |
| - if wire.ProtocolWarm != 24 || wire.ProtocolCurrent != wire.ProtocolStuckTasks || wire.Spoken(99) != 30 { |
| + if wire.ProtocolWarm != 24 || wire.ProtocolCurrent != wire.ProtocolChangeFiles || wire.Spoken(99) != 31 { |
| t.Fatalf("protocols %d %d", wire.ProtocolWarm, wire.ProtocolCurrent) |
| } |
| f, err := wire.NewFrame("c1", wire.FrameWarm, wire.WarmCommand{Person: "ana@example.com"}) |
diff --git a/internal/wire/wireschema/wireschema.go b/internal/wire/wireschema/wireschema.go| index e04dddd3..807c7da7 100644 |
| --- a/internal/wire/wireschema/wireschema.go |
| +++ b/internal/wire/wireschema/wireschema.go |
| @@ -155,6 +155,7 @@ var EventData = map[string]any{ |
| // person has a primary runner, or whose primary has not reported, has a |
| // runner with no role. |
| var Enums = map[string][]string{ |
| + "ChangedFile.status": {"added", "modified", "deleted", "renamed"}, |
| "Turn.state": {"", wire.TurnQueued, wire.TurnRunning, wire.TurnWaiting, wire.TurnReplied, wire.TurnFailed, wire.TurnCancelled}, |
| "Turn.kind": {wire.TurnPerson, wire.TurnMoveIn, wire.TurnExplore, wire.TurnHousekeeping}, |
| "Message.role": {"", wire.RolePerson, wire.RoleCoordinator}, |
| @@ -460,6 +461,13 @@ func (g *gen) fields(t reflect.Type, name string, props *ordered, required *[]st |
| s.set("enum", values) |
| g.enums[name+"."+key] = true |
| } |
| + if name == "ChangeFiles" && key == "entries" { |
| + s.set("maxItems", wire.MaxChangeEntries) |
| + s.set("description", "At most 200 entries. Totals cover the complete bounded scan; truncated is true when entries were omitted. The encoded facts are bounded to 96 KiB.") |
| + } |
| + if (name == "ChangeFiles" || name == "ChangedFile") && (key == "additions" || key == "deletions" || key == "files" || name == "ChangeFiles" && key == "binary") { |
| + s.set("minimum", 0) |
| + } |
| props.set(key, s) |
| if !omit && !g.input { |
| *required = append(*required, key) |
diff --git a/native/apple/Sources/EquipoActivity/Resources/Localizable.xcstrings b/native/apple/Sources/EquipoActivity/Resources/Localizable.xcstrings| index fc9366ad..fbf8f889 100644 |
| --- a/native/apple/Sources/EquipoActivity/Resources/Localizable.xcstrings |
| +++ b/native/apple/Sources/EquipoActivity/Resources/Localizable.xcstrings |
| @@ -1333,6 +1333,144 @@ |
| } |
| } |
| }, |
| + "native.changes.added": { |
| + "comment": "COPY APPROVED: Luna, 2026-11-26.", |
| + "extractionState": "manual", |
| + "localizations": { |
| + "en": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "Added" |
| + } |
| + } |
| + } |
| + }, |
| + "native.changes.binary": { |
| + "comment": "COPY APPROVED: Luna, 2026-11-26.", |
| + "extractionState": "manual", |
| + "localizations": { |
| + "en": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "Non-text file" |
| + } |
| + } |
| + } |
| + }, |
| + "native.changes.deleted": { |
| + "comment": "COPY APPROVED: Luna, 2026-11-26.", |
| + "extractionState": "manual", |
| + "localizations": { |
| + "en": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "Deleted" |
| + } |
| + } |
| + } |
| + }, |
| + "native.changes.modified": { |
| + "comment": "COPY APPROVED: Luna, 2026-11-26.", |
| + "extractionState": "manual", |
| + "localizations": { |
| + "en": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "Changed" |
| + } |
| + } |
| + } |
| + }, |
| + "native.changes.renamed": { |
| + "comment": "COPY APPROVED: Luna, 2026-11-26.", |
| + "extractionState": "manual", |
| + "localizations": { |
| + "en": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "Renamed" |
| + } |
| + } |
| + } |
| + }, |
| + "native.changes.renamed_from": { |
| + "comment": "COPY APPROVED: Luna, 2026-11-26.", |
| + "extractionState": "manual", |
| + "localizations": { |
| + "en": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "Renamed from %@" |
| + } |
| + } |
| + } |
| + }, |
| + "native.changes.total": { |
| + "comment": "COPY APPROVED: Luna, 2026-11-26.", |
| + "extractionState": "manual", |
| + "localizations": { |
| + "en": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "%#@files@, %#@lines@, %3$lld removed" |
| + }, |
| + "substitutions": { |
| + "files": { |
| + "argNum": 1, |
| + "formatSpecifier": "lld", |
| + "variations": { |
| + "plural": { |
| + "one": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "%lld file" |
| + } |
| + }, |
| + "other": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "%lld files" |
| + } |
| + } |
| + } |
| + } |
| + }, |
| + "lines": { |
| + "argNum": 2, |
| + "formatSpecifier": "lld", |
| + "variations": { |
| + "plural": { |
| + "one": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "%lld line added" |
| + } |
| + }, |
| + "other": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "%lld lines added" |
| + } |
| + } |
| + } |
| + } |
| + } |
| + } |
| + } |
| + } |
| + }, |
| + "native.changes.truncated": { |
| + "comment": "COPY APPROVED: Luna, 2026-11-26.", |
| + "extractionState": "manual", |
| + "localizations": { |
| + "en": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "Showing the first %lld files. Open on Amadan for the full list." |
| + } |
| + } |
| + } |
| + }, |
| "native.step.log_tail": { |
| "extractionState": "manual", |
| "localizations": { |
diff --git a/native/apple/Sources/EquipoKit/API/ChangeFiles.swift b/native/apple/Sources/EquipoKit/API/ChangeFiles.swift| new file mode 100644 |
| index 00000000..7ce55108 |
| --- /dev/null |
| +++ b/native/apple/Sources/EquipoKit/API/ChangeFiles.swift |
| @@ -0,0 +1,52 @@ |
| +import Foundation |
| + |
| +public struct ThinChangedFile: Codable, Sendable, Equatable, Identifiable { |
| + public var path: String |
| + public var oldPath: String? = nil |
| + public var status: String |
| + public var additions: Int |
| + public var deletions: Int |
| + public var binary: Bool |
| + public var id: String { path } |
| +} |
| +public struct ThinChangeFiles: Codable, Sendable, Equatable { |
| + public var base: String |
| + public var sha: String |
| + public var files: Int |
| + public var additions: Int |
| + public var deletions: Int |
| + public var binary: Int |
| + public var entries: [ThinChangedFile] |
| + public var truncated: Bool |
| + |
| + var isValid: Bool { |
| + guard (base.isEmpty || Self.commit(base)), Self.commit(sha), files >= 0, additions >= 0, deletions >= 0, |
| + binary >= 0, binary <= files, entries.count <= 200, entries.count <= files, |
| + truncated == (entries.count < files), Set(entries.map(\.path)).count == entries.count else { return false } |
| + var added = 0, removed = 0, binaries = 0 |
| + for file in entries { |
| + guard Self.path(file.path), ["added", "modified", "deleted", "renamed"].contains(file.status), |
| + file.additions >= 0, file.deletions >= 0, |
| + file.additions <= additions - added, file.deletions <= deletions - removed else { return false } |
| + if file.status == "renamed" { |
| + guard let old = file.oldPath, Self.path(old), old != file.path else { return false } |
| + } else if file.oldPath != nil { return false } |
| + added += file.additions; removed += file.deletions |
| + if file.binary { |
| + guard file.additions == 0, file.deletions == 0 else { return false } |
| + binaries += 1 |
| + } |
| + } |
| + guard binaries <= binary, truncated || (added == additions && removed == deletions && binaries == binary), |
| + let raw = try? JSONEncoder().encode(self), raw.count <= 96 * 1024 else { return false } |
| + return true |
| + } |
| + static func commit(_ value: String) -> Bool { |
| + value.utf8.count == 40 && value.utf8.allSatisfy { (48...57).contains($0) || (97...102).contains($0) } |
| + } |
| + static func path(_ value: String) -> Bool { |
| + !value.isEmpty && value.utf8.count <= 4096 && !value.contains("\\") |
| + && value.rangeOfCharacter(from: .controlCharacters) == nil |
| + && value.split(separator: "/", omittingEmptySubsequences: false).allSatisfy { !$0.isEmpty && $0 != "." && $0 != ".." } |
| + } |
| +} |
diff --git a/native/apple/Sources/EquipoKit/API/Thin.swift b/native/apple/Sources/EquipoKit/API/Thin.swift| index 06282ed1..2eaa837e 100644 |
| --- a/native/apple/Sources/EquipoKit/API/Thin.swift |
| +++ b/native/apple/Sources/EquipoKit/API/Thin.swift |
| @@ -81,6 +81,7 @@ public struct ThinStepHosted: Codable, Sendable, Equatable { |
| } |
| public struct ThinStep: Codable, Sendable, Identifiable, Equatable { |
| + public var changeFiles: ThinChangeFiles? = nil |
| public var hosted: ThinStepHosted? = nil |
| public var baseChecks: String? = nil |
| public var revision: Int64? = nil |
diff --git a/native/apple/Sources/EquipoKit/Presentation/ChangedFiles.swift b/native/apple/Sources/EquipoKit/Presentation/ChangedFiles.swift| new file mode 100644 |
| index 00000000..dc66b443 |
| --- /dev/null |
| +++ b/native/apple/Sources/EquipoKit/Presentation/ChangedFiles.swift |
| @@ -0,0 +1,48 @@ |
| +import Foundation |
| + |
| +enum ChangedFilesPresentation { |
| + static func facts(_ task: ThinTask) -> ThinChangeFiles? { |
| + guard !task.candidateSha.isEmpty, |
| + let step = task.steps?.last(where: { $0.specialist == "engineering" && $0.candidateSha == task.candidateSha }), |
| + step.state == "done", let facts = step.changeFiles, facts.sha == task.candidateSha, facts.base == step.baseSha, |
| + facts.isValid else { return nil } |
| + return facts |
| + } |
| + struct Group: Identifiable { |
| + var folder: String |
| + var files: [ThinChangedFile] |
| + var id: String { folder } |
| + } |
| + static func groups(_ facts: ThinChangeFiles) -> [Group] { |
| + guard facts.entries.count > 10 else { return [Group(folder: "", files: facts.entries)] } |
| + let folders = Dictionary(grouping: facts.entries) { String($0.path.split(separator: "/").dropLast().joined(separator: "/")) } |
| + return folders.keys.sorted().map { Group(folder: $0, files: folders[$0] ?? []) } |
| + } |
| + static func fileURL(task: ThinTask, facts: ThinChangeFiles, file: ThinChangedFile) -> URL? { |
| + guard let source = task.repo else { return nil } |
| + let repo = source.hasPrefix("amadan.net/") ? String(source.dropFirst("amadan.net/".count)) : source |
| + let parts = repo.split(separator: "/", omittingEmptySubsequences: false) |
| + guard parts.count == 2, parts.allSatisfy({ |
| + $0 != "." && $0 != ".." && $0.range(of: #"^[A-Za-z0-9_.-]+$"#, options: .regularExpression) != nil |
| + }), ThinChangeFiles.path(file.path), |
| + (file.status != "deleted" || ThinChangeFiles.commit(facts.base)), ThinChangeFiles.commit(facts.sha) else { return nil } |
| + var url = URLComponents() |
| + url.scheme = "https"; url.host = "amadan.net"; url.path = "/" + repo |
| + url.queryItems = [URLQueryItem(name: "ref", value: file.status == "deleted" ? facts.base : facts.sha), |
| + URLQueryItem(name: "path", value: file.path)] |
| + // Go's query decoder treats a literal plus as a space. |
| + url.percentEncodedQuery = url.percentEncodedQuery?.replacingOccurrences(of: "+", with: "%2B") |
| + return url.url |
| + } |
| + static func total(files: Int, additions: Int, deletions: Int) -> String { |
| + String.localizedStringWithFormat(Bundle.module.localizedString(forKey: "native.changes.total", value: nil, table: nil), files, additions, deletions) |
| + } |
| + static func status(_ file: ThinChangedFile) -> String { |
| + switch file.status { |
| + case "added": EquipoStrings.text("native.changes.added") |
| + case "deleted": EquipoStrings.text("native.changes.deleted") |
| + case "renamed": EquipoStrings.text("native.changes.renamed") |
| + default: EquipoStrings.text("native.changes.modified") |
| + } |
| + } |
| +} |
diff --git a/native/apple/Sources/EquipoKit/Resources/Localizable.xcstrings b/native/apple/Sources/EquipoKit/Resources/Localizable.xcstrings| index fc9366ad..fbf8f889 100644 |
| --- a/native/apple/Sources/EquipoKit/Resources/Localizable.xcstrings |
| +++ b/native/apple/Sources/EquipoKit/Resources/Localizable.xcstrings |
| @@ -1333,6 +1333,144 @@ |
| } |
| } |
| }, |
| + "native.changes.added": { |
| + "comment": "COPY APPROVED: Luna, 2026-11-26.", |
| + "extractionState": "manual", |
| + "localizations": { |
| + "en": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "Added" |
| + } |
| + } |
| + } |
| + }, |
| + "native.changes.binary": { |
| + "comment": "COPY APPROVED: Luna, 2026-11-26.", |
| + "extractionState": "manual", |
| + "localizations": { |
| + "en": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "Non-text file" |
| + } |
| + } |
| + } |
| + }, |
| + "native.changes.deleted": { |
| + "comment": "COPY APPROVED: Luna, 2026-11-26.", |
| + "extractionState": "manual", |
| + "localizations": { |
| + "en": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "Deleted" |
| + } |
| + } |
| + } |
| + }, |
| + "native.changes.modified": { |
| + "comment": "COPY APPROVED: Luna, 2026-11-26.", |
| + "extractionState": "manual", |
| + "localizations": { |
| + "en": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "Changed" |
| + } |
| + } |
| + } |
| + }, |
| + "native.changes.renamed": { |
| + "comment": "COPY APPROVED: Luna, 2026-11-26.", |
| + "extractionState": "manual", |
| + "localizations": { |
| + "en": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "Renamed" |
| + } |
| + } |
| + } |
| + }, |
| + "native.changes.renamed_from": { |
| + "comment": "COPY APPROVED: Luna, 2026-11-26.", |
| + "extractionState": "manual", |
| + "localizations": { |
| + "en": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "Renamed from %@" |
| + } |
| + } |
| + } |
| + }, |
| + "native.changes.total": { |
| + "comment": "COPY APPROVED: Luna, 2026-11-26.", |
| + "extractionState": "manual", |
| + "localizations": { |
| + "en": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "%#@files@, %#@lines@, %3$lld removed" |
| + }, |
| + "substitutions": { |
| + "files": { |
| + "argNum": 1, |
| + "formatSpecifier": "lld", |
| + "variations": { |
| + "plural": { |
| + "one": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "%lld file" |
| + } |
| + }, |
| + "other": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "%lld files" |
| + } |
| + } |
| + } |
| + } |
| + }, |
| + "lines": { |
| + "argNum": 2, |
| + "formatSpecifier": "lld", |
| + "variations": { |
| + "plural": { |
| + "one": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "%lld line added" |
| + } |
| + }, |
| + "other": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "%lld lines added" |
| + } |
| + } |
| + } |
| + } |
| + } |
| + } |
| + } |
| + } |
| + }, |
| + "native.changes.truncated": { |
| + "comment": "COPY APPROVED: Luna, 2026-11-26.", |
| + "extractionState": "manual", |
| + "localizations": { |
| + "en": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "Showing the first %lld files. Open on Amadan for the full list." |
| + } |
| + } |
| + } |
| + }, |
| "native.step.log_tail": { |
| "extractionState": "manual", |
| "localizations": { |
diff --git a/native/apple/Sources/EquipoKit/UI/Screens/ChangedFilesList.swift b/native/apple/Sources/EquipoKit/UI/Screens/ChangedFilesList.swift| new file mode 100644 |
| index 00000000..ac703386 |
| --- /dev/null |
| +++ b/native/apple/Sources/EquipoKit/UI/Screens/ChangedFilesList.swift |
| @@ -0,0 +1,65 @@ |
| +import SwiftUI |
| + |
| +/// The bounded Engineering listing, shared by the phone tab and Mac detail. |
| +struct ChangedFilesList: View { |
| + let facts: ThinChangeFiles |
| + var openFile: (ThinChangedFile) -> Void |
| + |
| + var body: some View { |
| + VStack(alignment: .leading, spacing: 16) { |
| + Text(ChangedFilesPresentation.total(files: facts.files, additions: facts.additions, deletions: facts.deletions)) |
| + .font(.headline).fixedSize(horizontal: false, vertical: true) |
| + ForEach(ChangedFilesPresentation.groups(facts)) { group in |
| + VStack(alignment: .leading, spacing: 0) { |
| + if !group.folder.isEmpty { |
| + Text(verbatim: group.folder).font(Typo.secondaryStrong).foregroundStyle(Palette.secondary).padding(.bottom, 8) |
| + } |
| + ForEach(group.files) { file in |
| + Button { openFile(file) } label: { ChangedFileLabel(file: file) } |
| + .buttonStyle(.plain) |
| + .accessibilityLabel(accessibility(file)) |
| + .accessibilityIdentifier("changed-file-" + file.path) |
| + Divider() |
| + } |
| + } |
| + } |
| + if facts.truncated { |
| + Text(String(format: EquipoStrings.text("native.changes.truncated"), facts.entries.count)) |
| + .font(Typo.secondary).foregroundStyle(Palette.secondary).fixedSize(horizontal: false, vertical: true) |
| + } |
| + } |
| + } |
| + private func accessibility(_ file: ThinChangedFile) -> String { |
| + [file.path, ChangedFilesPresentation.status(file), |
| + file.oldPath.map { String(format: EquipoStrings.text("native.changes.renamed_from"), $0) }, |
| + file.binary ? EquipoStrings.text("native.changes.binary") |
| + : ChangedFilesPresentation.total(files: 1, additions: file.additions, deletions: file.deletions)] |
| + .compactMap { $0 }.joined(separator: ", ") |
| + } |
| +} |
| + |
| +private struct ChangedFileLabel: View { |
| + let file: ThinChangedFile |
| + var body: some View { |
| + HStack(alignment: .top, spacing: 12) { |
| + VStack(alignment: .leading, spacing: 6) { |
| + Text(verbatim: file.path).font(.system(.subheadline, design: .monospaced)) |
| + .foregroundStyle(Palette.text).fixedSize(horizontal: false, vertical: true) |
| + if let old = file.oldPath { |
| + Text(String(format: EquipoStrings.text("native.changes.renamed_from"), old)) |
| + .font(Typo.caption).foregroundStyle(Palette.secondary).fixedSize(horizontal: false, vertical: true) |
| + } |
| + HStack(spacing: 12) { |
| + Text(ChangedFilesPresentation.status(file)).font(Typo.caption).foregroundStyle(Palette.secondary) |
| + if file.binary { |
| + Text(EquipoStrings.text("native.changes.binary")).font(Typo.caption).foregroundStyle(Palette.secondary) |
| + } else { |
| + Text(verbatim: "+\(file.additions)").foregroundStyle(Palette.positive) |
| + Text(verbatim: "−\(file.deletions)").foregroundStyle(Palette.negative) |
| + } |
| + }.font(.system(.caption, design: .monospaced)) |
| + }.frame(maxWidth: .infinity, alignment: .leading) |
| + Image(systemName: "arrow.up.right").font(.caption).foregroundStyle(Palette.secondary) |
| + }.padding(.vertical, 12).frame(minHeight: 44).contentShape(Rectangle()) |
| + } |
| +} |
diff --git a/native/apple/Sources/EquipoKit/UI/Screens/TaskDetailScreen.swift b/native/apple/Sources/EquipoKit/UI/Screens/TaskDetailScreen.swift| index 918a7de6..577005c7 100644 |
| --- a/native/apple/Sources/EquipoKit/UI/Screens/TaskDetailScreen.swift |
| +++ b/native/apple/Sources/EquipoKit/UI/Screens/TaskDetailScreen.swift |
| @@ -46,7 +46,15 @@ public struct TaskScreen: View { |
| switch tab { |
| case .overview: overview(task) |
| case .checks: TaskChecksView(task: task, client: model.session.client) |
| - case .changes: webEvidence(task, preview: false) |
| + case .changes: |
| + if let facts = ChangedFilesPresentation.facts(task) { |
| + ChangedFilesList(facts: facts) { file in |
| + if let url = ChangedFilesPresentation.fileURL(task: task, facts: facts, file: file) { |
| + model.session.settings.openChanges(origin: model.session.origin, url: url) |
| + } else { openWeb(task) } |
| + } |
| + } |
| + webEvidence(task, preview: false) |
| case .preview: webEvidence(task, preview: true) |
| } |
| }.padding(16).frame(maxWidth: 760).frame(maxWidth: .infinity, alignment: .topLeading) |
| @@ -63,6 +71,11 @@ public struct TaskScreen: View { |
| } else { ProgressView().accessibilityLabel(EquipoStrings.text("work.details.task")) } |
| } |
| .background(Palette.background) |
| + #if DEBUG |
| + .onAppear { |
| + if (ProcessInfo.processInfo.environment["EQUIPO_TASK_FIXTURE"] ?? "").hasPrefix("changes") { tab = .changes } |
| + } |
| + #endif |
| .task(id: model.session.task(model.taskID)?.revision) { await model.load() } |
| .refreshable { await model.session.refresh(); await model.load() } |
| .sheet(item: $model.confirmation) { confirm in confirmationSheet(confirm) } |
diff --git a/native/apple/Sources/EquipoKit/UI/TaskViewFixture.swift b/native/apple/Sources/EquipoKit/UI/TaskViewFixture.swift| index cc54e279..f8c2ce5e 100644 |
| --- a/native/apple/Sources/EquipoKit/UI/TaskViewFixture.swift |
| +++ b/native/apple/Sources/EquipoKit/UI/TaskViewFixture.swift |
| @@ -45,6 +45,8 @@ public struct TaskViewFixture: View { |
| } |
| private struct TaskViewFixtureTransport: EquipoTransport { |
| + private var changes: Bool { (ProcessInfo.processInfo.environment["EQUIPO_TASK_FIXTURE"] ?? "").hasPrefix("changes") } |
| + private var candidate: String { changes ? String(repeating: "b", count: 40) : "3f9c2a167de8" } |
| private var hosted: Bool { ProcessInfo.processInfo.environment["EQUIPO_TASK_FIXTURE"] == "hosted" } |
| private var failed: Bool { hosted || ProcessInfo.processInfo.environment["EQUIPO_TASK_FIXTURE"] == "checks" } |
| let origin = URL(string: "https://fixture.invalid")! |
| @@ -62,12 +64,33 @@ private struct TaskViewFixtureTransport: EquipoTransport { |
| return APIResponse(status: 200, data: try JSONSerialization.data(withJSONObject: value)) |
| } |
| func lines(_ request: APIRequest) async throws -> AsyncThrowingStream<String, Error> { AsyncThrowingStream { $0.finish() } } |
| + private var changeFiles: [String: Any] { |
| + let base = String(repeating: "a", count: 40) |
| + func file(_ path: String, _ status: String, _ added: Int = 0, _ removed: Int = 0, old: String? = nil, binary: Bool = false) -> [String: Any] { |
| + var result: [String: Any] = ["path": path, "status": status, "additions": added, "deletions": removed, "binary": binary] |
| + if let old { result["old_path"] = old } |
| + return result |
| + } |
| + if ProcessInfo.processInfo.environment["EQUIPO_TASK_FIXTURE"] == "changes-long" { |
| + return ["base": base, "sha": candidate, "files": 203, "additions": 203, "deletions": 0, "binary": 0, |
| + "entries": (0..<200).map { file("Sources/Folder\($0 % 4)/File\($0).swift", "added", 1) }, "truncated": true] |
| + } |
| + return ["base": base, "sha": candidate, "files": 6, "additions": 55, "deletions": 10, "binary": 1, "truncated": false, |
| + "entries": [ |
| + file("Sources/Session/EquipoSession.swift", "modified", 24, 4), |
| + file("Tests/NeedsBadgeTests.swift", "modified", 19, 2), |
| + file("Sources/Needs/Badge.swift", "added", 12), |
| + file("Resources/Badge.png", "modified", binary: true), |
| + file("docs/Badge behaviour.md", "renamed", old: "docs/Badge notes.md"), |
| + file("Sources/Needs/OldBadge.swift", "deleted", 0, 4) |
| + ]] |
| + } |
| private var card: [String: Any] { |
| ["id": "card_merge", "revision": 3, "kind": "merge", "state": "open", "turn_id": "", "project_id": "project", "name": "", "question": "Merge the fix for the Needs you badge?", "options": ["merge", "not_now"], "choice": "", "task_id": "tk_fixture", "created_at": "2026-11-26T09:42:00Z", "updated_at": "2026-11-26T09:42:00Z"] |
| } |
| private var task: [String: Any] { |
| func step(_ id: String, _ specialist: String, _ headline: String, _ summary: String = "") -> [String: Any] { |
| - ["id": id, "specialist": specialist, "candidate_sha": "3f9c2a167de8", "state": "done", "reason": "", "headline": headline, "summary": summary, "verdict": "", "review_label": "", "checks": "", "gate": "", "started_at": "2026-11-26T09:42:00Z", "finished_at": "2026-11-26T09:48:00Z"] |
| + ["id": id, "specialist": specialist, "candidate_sha": candidate, "state": "done", "reason": "", "headline": headline, "summary": summary, "verdict": "", "review_label": "", "checks": "", "gate": "", "started_at": "2026-11-26T09:42:00Z", "finished_at": "2026-11-26T09:48:00Z"] |
| } |
| var checks = step("checks", "checks", failed ? "One test failed" : "Native checks passed") |
| checks["checks"] = failed ? "failed" : "passed"; checks["gate"] = ".amadan/ci.d"; checks["exit_code"] = failed ? 1 : 0 |
| @@ -81,10 +104,15 @@ private struct TaskViewFixtureTransport: EquipoTransport { |
| review["summary"] = "The signed-out account still contributes to the Needs you badge. Clear its count and prevent late requests from restoring it." |
| review["verdict"] = "changes_requested"; review["review_label"] = "changes_requested" |
| } |
| + var engineering = step("engineering", "engineering", "Clear the badge when signing out") |
| + if changes && ProcessInfo.processInfo.environment["EQUIPO_TASK_FIXTURE"] != "changes-old" { |
| + engineering["base_sha"] = String(repeating: "a", count: 40) |
| + engineering["change_files"] = changeFiles |
| + } |
| let steps = failed |
| - ? [step("engineering", "engineering", "Clear the badge when signing out"), earlierReview, checks, review] |
| - : [step("engineering", "engineering", "Clear the badge when signing out"), checks, review] |
| - return ["id": "tk_fixture", "revision": 9, "project_id": "project", "project": "Equipo", "repo": "oficina/equipo", "title": "Fix the Needs you badge after sign-out", "brief": "When I sign out on my iPhone, the Needs you badge still shows the old count. Clear it as soon as I sign out, and keep it clear if a request finishes afterwards.", "stage": "ready_to_merge", "branch": "equipo/needs-badge-sign-out", "url": "https://amadan.net/oficina/equipo", "candidate_sha": "3f9c2a167de8", "checks": failed ? "failed" : "passed", "checks_reason": "", "verdict": failed ? "changes_requested" : "approve", "review_label": failed ? "changes_requested" : "approved", "needs_you": failed ? "fix_rounds" : "merge", "merge_offered": !failed, "creator": "paul@example.com", "created_at": "2026-11-26T09:40:00Z", "updated_at": "2026-11-26T09:48:00Z", "steps": steps] |
| + ? [engineering, earlierReview, checks, review] |
| + : [engineering, checks, review] |
| + return ["id": "tk_fixture", "revision": 9, "project_id": "project", "project": "Equipo", "repo": "oficina/equipo", "title": "Fix the Needs you badge after sign-out", "brief": "When I sign out on my iPhone, the Needs you badge still shows the old count. Clear it as soon as I sign out, and keep it clear if a request finishes afterwards.", "stage": "ready_to_merge", "branch": "equipo/needs-badge-sign-out", "url": "https://amadan.net/oficina/equipo", "candidate_sha": candidate, "checks": failed ? "failed" : "passed", "checks_reason": "", "verdict": failed ? "changes_requested" : "approve", "review_label": failed ? "changes_requested" : "approved", "needs_you": failed ? "fix_rounds" : "merge", "merge_offered": !failed, "creator": "paul@example.com", "created_at": "2026-11-26T09:40:00Z", "updated_at": "2026-11-26T09:48:00Z", "steps": steps] |
| } |
| } |
| #endif |
diff --git a/native/apple/Tests/EquipoKitTests/ChangeFilesTests.swift b/native/apple/Tests/EquipoKitTests/ChangeFilesTests.swift| new file mode 100644 |
| index 00000000..08f6d25e |
| --- /dev/null |
| +++ b/native/apple/Tests/EquipoKitTests/ChangeFilesTests.swift |
| @@ -0,0 +1,104 @@ |
| +import Foundation |
| +import Testing |
| +@testable import EquipoKit |
| + |
| +@Suite struct ChangeFilesTests { |
| + static let base = String(repeating: "a", count: 40) |
| + static let sha = String(repeating: "b", count: 40) |
| + static func facts() -> ThinChangeFiles { |
| + .init(base: base, sha: sha, files: 1, additions: 1, deletions: 0, binary: 0, |
| + entries: [.init(path: "Sources/Hello 日本語.swift", status: "added", additions: 1, deletions: 0, binary: false)], truncated: false) |
| + } |
| + @Test func currentCandidateLatestEngineeringOnlyAndOldRunnerFallback() throws { |
| + var task = try TaskDetailTests.task(); task.candidateSha = Self.sha |
| + var step = task.steps![0]; step.specialist = "engineering"; step.state = "done"; step.pushed = true |
| + step.baseSha = Self.base; step.candidateSha = Self.sha; step.changeFiles = Self.facts() |
| + task.steps = [step] |
| + #expect(ChangedFilesPresentation.facts(task) == Self.facts()) |
| + var old = step; old.candidateSha = Self.base; old.changeFiles?.sha = Self.base |
| + task.steps = [step, old] |
| + #expect(ChangedFilesPresentation.facts(task) == Self.facts()) |
| + var newest = step; newest.id = "new"; newest.changeFiles = nil |
| + task.steps = [step, newest] |
| + #expect(ChangedFilesPresentation.facts(task) == nil) |
| + for specialist in ["review", "copy", "checks"] { |
| + step.specialist = specialist; task.steps = [step] |
| + #expect(ChangedFilesPresentation.facts(task) == nil) |
| + } |
| + step.specialist = "engineering"; step.changeFiles?.sha = Self.base; task.steps = [step] |
| + #expect(ChangedFilesPresentation.facts(task) == nil) |
| + step.changeFiles = Self.facts(); step.baseSha = Self.sha; task.steps = [step] |
| + #expect(ChangedFilesPresentation.facts(task) == nil) |
| + step.baseSha = Self.base; step.state = "running"; task.steps = [step] |
| + #expect(ChangedFilesPresentation.facts(task) == nil) |
| + step.state = "done"; step.changeFiles?.additions = -1; task.steps = [step] |
| + #expect(ChangedFilesPresentation.facts(task) == nil) |
| + let legacy: ThinTask = try Fixture.decode("thin/task") |
| + #expect(legacy.steps?.allSatisfy { $0.changeFiles == nil } == true) |
| + } |
| + @Test func fileLinksArePinnedEncodedAndAllowlisted() throws { |
| + var task = try TaskDetailTests.task(); task.repo = "amadan.net/oficina/equipo" |
| + var file = Self.facts().entries[0]; file.path = "docs/a+b & 日本語 #%.md" |
| + let url = try #require(ChangedFilesPresentation.fileURL(task: task, facts: Self.facts(), file: file)) |
| + #expect(url.host == "amadan.net") |
| + #expect(url.path == "/oficina/equipo") |
| + #expect(url.absoluteString.contains("%2B")) |
| + let query = try #require(URLComponents(url: url, resolvingAgainstBaseURL: false)?.queryItems) |
| + #expect(query.first { $0.name == "ref" }?.value == Self.sha) |
| + #expect(query.first { $0.name == "path" }?.value == file.path) |
| + var opened: URL? |
| + SettingsNavigation.openChanges(origin: URL(string: "https://equipo.example")!, url: url) { opened = $0 } |
| + #expect(opened == url) |
| + file.status = "deleted" |
| + let deleted = try #require(ChangedFilesPresentation.fileURL(task: task, facts: Self.facts(), file: file)) |
| + #expect(URLComponents(url: deleted, resolvingAgainstBaseURL: false)?.queryItems?.first { $0.name == "ref" }?.value == Self.base) |
| + for repo in ["evil.example/oficina/equipo", "https://evil.example/oficina/equipo", "amadan.net@evil.example/o/r", "../evil", "oficina/equipo/extra"] { |
| + task.repo = repo |
| + #expect(ChangedFilesPresentation.fileURL(task: task, facts: Self.facts(), file: file) == nil) |
| + } |
| + task.repo = "oficina/equipo"; file.path = "../secret" |
| + #expect(ChangedFilesPresentation.fileURL(task: task, facts: Self.facts(), file: file) == nil) |
| + } |
| + @Test func boundsAndGroupingKeepEveryDisplayedPath() { |
| + var facts = Self.facts() |
| + facts.entries = (0..<200).map { .init(path: "folder\($0 % 3)/file\($0).txt", status: "added", additions: 1, deletions: 0, binary: false) } |
| + facts.files = 203; facts.additions = 203; facts.truncated = true |
| + #expect(facts.isValid) |
| + let groups = ChangedFilesPresentation.groups(facts) |
| + #expect(groups.count == 3) |
| + #expect(Set(groups.flatMap(\.files).map(\.path)) == Set(facts.entries.map(\.path))) |
| + facts.entries.append(.init(path: "extra", status: "added", additions: 1, deletions: 0, binary: false)) |
| + #expect(!facts.isValid) |
| + facts = Self.facts(); facts.files = 2 |
| + #expect(!facts.isValid) |
| + facts = Self.facts(); facts.entries[0].additions = -1 |
| + #expect(!facts.isValid) |
| + facts = Self.facts(); facts.entries[0].status = "future" |
| + #expect(!facts.isValid) |
| + facts = Self.facts(); facts.entries[0].binary = true; facts.binary = 1 |
| + #expect(!facts.isValid) |
| + } |
| + @Test func encodedBytesAndDuplicatePathsAreBounded() { |
| + var facts = Self.facts(); facts.files = 200; facts.additions = 200 |
| + facts.entries = (0..<200).map { .init(path: "\($0)/" + String(repeating: "x", count: 3900), status: "added", additions: 1, deletions: 0, binary: false) } |
| + #expect(!facts.isValid) |
| + facts = Self.facts(); facts.files = 2; facts.additions = 2; facts.entries.append(facts.entries[0]) |
| + #expect(!facts.isValid) |
| + } |
| + @Test func initialCommitAndReviewedStatusWords() throws { |
| + var facts = Self.facts(); facts.base = "" |
| + #expect(facts.isValid) |
| + var task = try TaskDetailTests.task(); task.repo = "oficina/equipo" |
| + #expect(ChangedFilesPresentation.fileURL(task: task, facts: facts, file: facts.entries[0]) != nil) |
| + for (status, words) in [("added", "Added"), ("modified", "Changed"), ("deleted", "Deleted"), ("renamed", "Renamed")] { |
| + var file = facts.entries[0]; file.status = status |
| + #expect(ChangedFilesPresentation.status(file) == words) |
| + } |
| + } |
| + @Test func reviewedCountsPluralizeFilesAndLines() { |
| + #expect(ChangedFilesPresentation.total(files: 1, additions: 1, deletions: 0) == "1 file, 1 line added, 0 removed") |
| + #expect(ChangedFilesPresentation.total(files: 2, additions: 1, deletions: 3) == "2 files, 1 line added, 3 removed") |
| + #expect(ChangedFilesPresentation.total(files: 1, additions: 2, deletions: 1) == "1 file, 2 lines added, 1 removed") |
| + #expect(ChangedFilesPresentation.total(files: 0, additions: 0, deletions: 0) == "0 files, 0 lines added, 0 removed") |
| + } |
| +} |
diff --git a/native/apple/Tests/EquipoKitTests/Fixtures/task-detail/full.json b/native/apple/Tests/EquipoKitTests/Fixtures/task-detail/full.json| index 1992fa63..d69c7642 100644 |
| --- a/native/apple/Tests/EquipoKitTests/Fixtures/task-detail/full.json |
| +++ b/native/apple/Tests/EquipoKitTests/Fixtures/task-detail/full.json |
| @@ -405,7 +405,33 @@ |
| "bytes": 7, |
| "outcome": "outcome fixture" |
| }, |
| - "retried_by": "retried_by fixture" |
| + "retried_by": "retried_by fixture", |
| + "change_files": { |
| + "base": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", |
| + "sha": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", |
| + "files": 2, |
| + "additions": 4, |
| + "deletions": 1, |
| + "binary": 0, |
| + "truncated": false, |
| + "entries": [ |
| + { |
| + "path": "docs/日本語 notes.md", |
| + "old_path": "docs/old notes.md", |
| + "status": "renamed", |
| + "additions": 4, |
| + "deletions": 1, |
| + "binary": false |
| + }, |
| + { |
| + "path": "empty.txt", |
| + "status": "added", |
| + "additions": 0, |
| + "deletions": 0, |
| + "binary": false |
| + } |
| + ] |
| + } |
| } |
| ], |
| "thread": [ |
diff --git a/native/ios/UITests/TaskViewUITests.swift b/native/ios/UITests/TaskViewUITests.swift| index 84b221f8..d9c43172 100644 |
| --- a/native/ios/UITests/TaskViewUITests.swift |
| +++ b/native/ios/UITests/TaskViewUITests.swift |
| @@ -1,6 +1,24 @@ |
| import XCTest |
| final class TaskViewUITests: XCTestCase { |
| + @MainActor func testChangedFilesAndOldRunnerFallback() { |
| + let app = launch("changes") |
| + XCTAssertTrue(app.buttons["changed-file-Sources/Session/EquipoSession.swift"].waitForExistence(timeout: 15)) |
| + XCTAssertTrue(app.staticTexts["6 files, 55 lines added, 10 removed"].exists) |
| + XCTAssertTrue(app.staticTexts["Non-text file"].exists) |
| + XCTAssertTrue(app.staticTexts["Renamed from docs/Badge notes.md"].exists) |
| + capture("iphone-changed-files") |
| + app.terminate() |
| + let old = launch("changes-old") |
| + XCTAssertTrue(old.buttons["Open on the web"].waitForExistence(timeout: 15)) |
| + XCTAssertFalse(old.buttons["changed-file-Sources/Session/EquipoSession.swift"].exists) |
| + capture("iphone-changed-files-old-runner") |
| + } |
| + @MainActor func testChangedFilesLargeText() { |
| + let app = launch("changes", large: true) |
| + XCTAssertTrue(app.buttons["changed-file-Sources/Session/EquipoSession.swift"].waitForExistence(timeout: 15)) |
| + capture("iphone-changed-files-large") |
| + } |
| @MainActor func testOverviewMenuAndMergeConfirmation() { |
| let app = launch("overview") |
| XCTAssertTrue(app.buttons["task-more"].waitForExistence(timeout: 15)) |
diff --git a/native/scripts/check-strings.py b/native/scripts/check-strings.py| index e02953d4..dfdd26d7 100755 |
| --- a/native/scripts/check-strings.py |
| +++ b/native/scripts/check-strings.py |
| @@ -14,9 +14,11 @@ source = json.loads((native / 'scripts/strings.json').read_text()) |
| # iPhone's widget extension draws the Live Activity with on its own. |
| catalog_paths = [native / 'apple/Sources' / target / 'Resources/Localizable.xcstrings' for target in ('EquipoKit', 'EquipoActivity')] |
| +plurals = json.loads((native / 'scripts/plurals.json').read_text()) |
| + |
| def catalog(): |
| return {'sourceLanguage': 'en', 'version': '1.0', 'strings': { |
| - k: {'extractionState': 'manual', 'localizations': {'en': {'stringUnit': {'state': 'translated', 'value': v}}}} |
| + k: {**({'comment': 'COPY APPROVED: Luna, 2026-11-26.'} if k.startswith('native.changes.') else {}), 'extractionState': 'manual', 'localizations': {'en': plurals.get(k, {'stringUnit': {'state': 'translated', 'value': v}})}} |
| for k, v in sorted(source.items())}} |
| def used_keys(): |
| @@ -33,6 +35,18 @@ def used_keys(): |
| return keys |
| problems = [] |
| +# The plural catalog's ordinary forms must stay identical to the reviewed |
| +# English source. Singular forms are exercised by native localization tests. |
| +for key, value in plurals.items(): |
| + ordinary = value['stringUnit']['value'] |
| + for name, substitution in value['substitutions'].items(): |
| + ordinary = ordinary.replace('%#@' + name + '@', substitution['variations']['plural']['other']['stringUnit']['value']) |
| + ordinary = re.sub(r'%[0-9]+\$', '%', ordinary) |
| + if ordinary != source.get(key): |
| + problems.append(f'{key}: plural catalog differs from reviewed source') |
| + for match in re.findall(r'"value": "([^"]*)"', json.dumps(value, ensure_ascii=False)): |
| + if '—' in match or '!' in match: problems.append(f'{key}: unreviewed punctuation in plural form') |
| + |
| for k in sorted(used_keys() - source.keys()): problems.append(f'no English text for key: {k}') |
| for k, v in source.items(): |
| if '—' in v: problems.append(f'em dash in {k}') |
diff --git a/native/scripts/plurals.json b/native/scripts/plurals.json| new file mode 100644 |
| index 00000000..036343b2 |
| --- /dev/null |
| +++ b/native/scripts/plurals.json |
| @@ -0,0 +1,50 @@ |
| +{ |
| + "native.changes.total": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "%#@files@, %#@lines@, %3$lld removed" |
| + }, |
| + "substitutions": { |
| + "files": { |
| + "argNum": 1, |
| + "formatSpecifier": "lld", |
| + "variations": { |
| + "plural": { |
| + "one": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "%lld file" |
| + } |
| + }, |
| + "other": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "%lld files" |
| + } |
| + } |
| + } |
| + } |
| + }, |
| + "lines": { |
| + "argNum": 2, |
| + "formatSpecifier": "lld", |
| + "variations": { |
| + "plural": { |
| + "one": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "%lld line added" |
| + } |
| + }, |
| + "other": { |
| + "stringUnit": { |
| + "state": "translated", |
| + "value": "%lld lines added" |
| + } |
| + } |
| + } |
| + } |
| + } |
| + } |
| + } |
| +} |
diff --git a/native/scripts/strings.json b/native/scripts/strings.json| index f68353fa..7d5feeca 100644 |
| --- a/native/scripts/strings.json |
| +++ b/native/scripts/strings.json |
| @@ -483,5 +483,13 @@ |
| "work.stage.stopped": "Stopped", |
| "work.star.add": "Star %@", |
| "work.star.remove": "Unstar %@", |
| - "work.tl.merge_dropped": "An earlier attempt to add this change was dropped when the task became an exploration." |
| + "work.tl.merge_dropped": "An earlier attempt to add this change was dropped when the task became an exploration.", |
| + "native.changes.added": "Added", |
| + "native.changes.modified": "Changed", |
| + "native.changes.deleted": "Deleted", |
| + "native.changes.renamed": "Renamed", |
| + "native.changes.binary": "Non-text file", |
| + "native.changes.renamed_from": "Renamed from %@", |
| + "native.changes.truncated": "Showing the first %lld files. Open on Amadan for the full list.", |
| + "native.changes.total": "%lld files, %lld lines added, %lld removed" |
| } |