oficina / equipo Public

Match server JSON bounds for native changed-file facts

Paul Campbell pushed by claude agent, operated by paul@keymail.dev fb4c448413c8959ab5c1a3ecc0c81516dfb31059 parent 75031bf
3 files changed, +46 −4
  • docs/superpowers/plans/CONTROLLER-REPORT-changes-facts.md +25 −3
  • native/apple/Sources/EquipoKit/API/ChangeFiles.swift +12 −1
  • native/apple/Tests/EquipoKitTests/ChangeFilesTests.swift +9 −0

CI cancelled — superseded by a newer push — run details

CI log
=== prepare ===
ci-box: machine: aarch64, 32 CPUs, 62 GiB memory, kernel 7.0.0-1017-aws
ci-box: python 3.12.3; Docker version 29.1.3, build 29.1.3-0ubuntu3~24.04.2
ci-box: user namespaces allowed: 233151
ci-box: cgroup: cgroup2fs
ci-box: disk /home/ci/work/repos/oficina__equipo/wt/changes__facts: Type  Size Avail | ext4   96G   85G
ci-box: disk /home/ci/.cache/equipo-ci-box: Type  Size Avail | ext4   96G   85G
ci-box: bwrap: fetched and verified in 0.3s
ci-box: claude: fetched and verified in 1.5s
ci-box: codex: fetched and verified in 3.4s
ci-box: codex-code-mode-host: fetched and verified in 1.3s
ci-box: libwrap: fetched and verified in 0.3s
ci-box: socat: fetched and verified in 0.3s
npm warn deprecated node-domexception@1.0.0: Use your platform's native DOMException instead
ci-box: image pulled in 9.8s
ci-box: pi: installed and verified in 7.4s
ci-box: opencode: installed and verified in 2.2s
ci-box: chromium 156.0.8078.79-1~deb13u1: 76 packages fetched, verified and unpacked in 8.7s
ci-box: clone deepened in 4.4s
ci-box: file times set from content: 3082 files, 198 directories
ci-box: ready in 17.9s
=== copy ===
EQUIPO_RELEASE_COPY_CHECK=1 CGO_ENABLED=0 go test ./internal/equipotest -run '^TestReleaseCopyReviewed$' -count=1
ok  	amadan.net/oficina/equipo/internal/equipotest	0.144s
=== compile ===
go build ./...
RASTRILLO='go run amadan.net/rastrillo/rastrillo/cmd/rastrillo' python3 scripts/ci-test.py compile

amadan: job cancelled — a newer push superseded it
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-changes-facts.md b/docs/superpowers/plans/CONTROLLER-REPORT-changes-facts.md
index 84509633..bd0a93c9 100644
--- a/docs/superpowers/plans/CONTROLLER-REPORT-changes-facts.md
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-changes-facts.md
@@ -112,7 +112,7 @@ Additional focused commands pass:
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.
+error), and restore the source in finally. All 43 are killed.
Server/runner (23): downgrade boundary; wire entry bound; wire byte bound;
wire exact totals; truncation consistency; runner entry bound; runner byte
@@ -121,10 +121,11 @@ 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;
+Native (20): current candidate; latest matching step; Engineering specialist;
done state; facts SHA; facts base; valid facts; folder grouping; repository
shape; file path; deleted-file base ref; plus encoding; count argument order;
-entry bound; byte bound; truncation consistency; binary counts; duplicate paths.
+entry bound; byte bound; truncation consistency; binary counts; duplicate paths;
+server slash escaping; server HTML escaping.
The first current-candidate mutation survived because the old step fixture
still carried the new candidate's facts. The fixture now binds that old
@@ -162,3 +163,24 @@ Main c74fd0ac (landed Needs you) was merged normally before publishing. String
conflicts keep both reviewed catalogs; existing size exemptions include the
merged done_at mapping and tests. Full Go test, performance and Linux CI results
follow after completion.
+
+Final self-review added a test-first JSON byte-bound regression: Swift normally
+escapes slashes, whereas Go leaves them literal and escapes HTML characters.
+Native now measures the server's snake-case JSON representation with the same
+escaping. A valid 200-entry nested-path listing is accepted, while a shorter
+HTML-character listing over the server's byte bound is rejected. The test
+failed both assertions before the fix; removing either encoding rule is killed
+by changes-facts-mutate-json.py. The seven focused ChangeFiles tests pass.
+
+Final native gate after the main merge and byte-bound fix passes: 350 tests in
+46 suites, one existing known issue, 330 web-parity strings, Mac and Simulator
+builds. Post-merge budget, formatting and focused device/runner contract tests
+also pass. Post-commit runner-dead-references passes.
+
+The full local macOS `make test` is not green: toolproxy requires unix.O_PATH,
+browser tests have no Chromium, and existing runner/provider checks fail.
+Representative TestOnboardingClaudeHeadlessBrowserLogin and
+TestPublishCoreAuthorizationContract failures were reproduced unchanged on
+clean origin/main c74fd0ac in a detached worktree, then that worktree was removed.
+No platform bypass or test weakening was added. Linux hub CI is the final gate;
+its full result is archived beside the screenshots in validation/ci-final.json.
diff --git a/native/apple/Sources/EquipoKit/API/ChangeFiles.swift b/native/apple/Sources/EquipoKit/API/ChangeFiles.swift
index 7ce55108..04ded0db 100644
--- a/native/apple/Sources/EquipoKit/API/ChangeFiles.swift
+++ b/native/apple/Sources/EquipoKit/API/ChangeFiles.swift
@@ -38,9 +38,20 @@ public struct ThinChangeFiles: Codable, Sendable, Equatable {
}
}
guard binaries <= binary, truncated || (added == additions && removed == deletions && binaries == binary),
- let raw = try? JSONEncoder().encode(self), raw.count <= 96 * 1024 else { return false }
+ let size = wireSize, size <= 96 * 1024 else { return false }
return true
}
+ private var wireSize: Int? {
+ let encoder = JSONEncoder()
+ encoder.keyEncodingStrategy = .convertToSnakeCase
+ encoder.outputFormatting = [.withoutEscapingSlashes]
+ guard let data = try? encoder.encode(self), var json = String(data: data, encoding: .utf8) else { return nil }
+ // Match encoding/json's HTML and separator escaping, including old_path.
+ for (character, escape) in [("<", #"\u003c"#), (">", #"\u003e"#), ("&", #"\u0026"#), ("\u{2028}", #"\u2028"#), ("\u{2029}", #"\u2029"#)] {
+ json = json.replacingOccurrences(of: character, with: escape)
+ }
+ return json.utf8.count
+ }
static func commit(_ value: String) -> Bool {
value.utf8.count == 40 && value.utf8.allSatisfy { (48...57).contains($0) || (97...102).contains($0) }
}
diff --git a/native/apple/Tests/EquipoKitTests/ChangeFilesTests.swift b/native/apple/Tests/EquipoKitTests/ChangeFilesTests.swift
index 08f6d25e..f3e22a54 100644
--- a/native/apple/Tests/EquipoKitTests/ChangeFilesTests.swift
+++ b/native/apple/Tests/EquipoKitTests/ChangeFilesTests.swift
@@ -85,6 +85,15 @@ import Testing
facts = Self.facts(); facts.files = 2; facts.additions = 2; facts.entries.append(facts.entries[0])
#expect(!facts.isValid)
}
+ @Test func byteBoundUsesTheServersJSONEscaping() {
+ var facts = Self.facts(); facts.files = 200; facts.additions = 200
+ facts.entries = (0..<200).map { .init(path: String(repeating: "a/", count: 150) + "file\($0)", status: "added", additions: 1, deletions: 0, binary: false) }
+ // Go leaves slashes unescaped: this complete listing fits its 96 KiB bound.
+ #expect(facts.isValid)
+ facts.entries = (0..<200).map { .init(path: String(repeating: "<", count: 150) + "file\($0)", status: "added", additions: 1, deletions: 0, binary: false) }
+ // Go escapes HTML characters, so these shorter paths exceed that bound.
+ #expect(!facts.isValid)
+ }
@Test func initialCommitAndReviewedStatusWords() throws {
var facts = Self.facts(); facts.base = ""
#expect(facts.isValid)