Seven SDKs read a person id seven ways, and Go disagreed with itself - #908
Conversation
|
@codex review |
|
To use Codex here, create a Codex account and connect to github. |
There was a problem hiding this comment.
🟡 Changes recommended
Kotlin can overwrite the normalized label, and TypeScript lacks direct coverage for the distinct SGID rule.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Standardizes person-ID parsing across seven SDKs against Go’s strconv.ParseInt behavior while preserving the stricter SGID rule.
Changes:
- Adds shared parsers distinguishing syntax and range failures.
- Fixes Go normalization of signed and zero-padded IDs.
- Adds cross-SDK corpus tests and specification guidance.
[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or rungh pr ready --undo.
Click "Ready for review" or rungh pr readyto reengage.
File summaries
| File | Description |
|---|---|
SPEC.md |
Defines person-ID parsing rules. |
go/pkg/basecamp/normalize.go |
Emits canonical JSON numbers. |
go/pkg/basecamp/person_id_grammar_test.go |
Adds the Go oracle corpus. |
typescript/src/person-id.ts |
Implements shared parsing. |
typescript/src/services/base.ts |
Uses shared normalization. |
typescript/src/services/mentions.ts |
Uses shared flexible parsing. |
typescript/tests/helpers/person-id-corpus.ts |
Adds the measured corpus. |
typescript/tests/services/person-id-normalization.test.ts |
Tests response normalization. |
typescript/tests/services/my-notifications.test.ts |
Updates overflow expectations. |
typescript/tests/services/mentions.test.ts |
Tests reader outcomes. |
swift/Sources/Basecamp/FlexibleInt.swift |
Implements shared parsing. |
swift/Sources/Basecamp/Services/BaseService.swift |
Updates normalization. |
swift/Sources/Basecamp/Mentions.swift |
Documents SGID divergence. |
swift/Tests/BasecampTests/FlexibleIntTests.swift |
Adds corpus coverage. |
rust/basecamp-sdk/src/types.rs |
Pins decimal interpretation. |
ruby/lib/basecamp/ids.rb |
Adds ParseInt-compatible scanning. |
ruby/lib/basecamp/http.rb |
Shares the new parser. |
ruby/test/test_helper.rb |
Defines the Ruby corpus. |
ruby/test/basecamp/ids_test.rb |
Tests parser and reader. |
ruby/test/basecamp/normalize_person_ids_test.rb |
Tests normalization. |
python/src/basecamp/_person_id.py |
Adds shared parsing. |
python/src/basecamp/generated/services/_base.py |
Updates synchronous normalization. |
python/src/basecamp/generated/services/_async_base.py |
Updates asynchronous normalization. |
python/src/basecamp/services/_campfire_index.py |
Shares flexible parsing. |
python/src/basecamp/mentions.py |
Documents the SGID rule. |
python/tests/person_id_corpus.py |
Defines the Python corpus. |
python/tests/test_person_id.py |
Tests all parsing sites. |
python/tests/services/test_notifications.py |
Tests response integration. |
python/tests/services/test_recordings_summarize.py |
Expands flexible-ID coverage. |
kotlin/sdk/src/commonMain/kotlin/com/basecamp/sdk/serialization/ParseInt64.kt |
Implements shared parsing. |
kotlin/sdk/src/commonMain/kotlin/com/basecamp/sdk/serialization/NormalizePersonIds.kt |
Updates normalization. |
kotlin/sdk/src/commonMain/kotlin/com/basecamp/sdk/serialization/FlexibleLongSerializer.kt |
Shares parser outcomes. |
kotlin/sdk/src/commonMain/kotlin/com/basecamp/sdk/Mentions.kt |
Documents SGID validation. |
kotlin/sdk/src/commonTest/kotlin/com/basecamp/sdk/FlexibleLongSerializerTest.kt |
Adds corpus coverage. |
kotlin/sdk/src/commonTest/kotlin/com/basecamp/sdk/MentionsTest.kt |
Tests SGID divergence. |
Review details
- Files reviewed: 33/35 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
… own The normalizer rebuilds a Person-shaped object by replaying its members in order, and a JSON object's members ARE ordered. So when the sentinel branch wrote `system_label` from the raw id and the incoming body happened to spell its own `system_label` AFTER `id`, the loop reached that key afterwards and copied the wire value straight over the one just written. The value being overwritten came off the wire, which is what makes this worth a branch rather than a tidy-up: a response carrying its own `system_label` could choose the label this SDK reports for the system actor — the one field a caller reads to find out which actor it was handed. The reference cannot have the bug and so has no branch for it. `coercePersonID` assigns into a map (`go/pkg/basecamp/normalize.go:66-67`), so the label it writes wins however the body was spelled; only a builder that replays members in order can lose. Kotlin is the only port that rebuilds rather than assigns — Swift, TypeScript, Python and Ruby all overwrite a key — so this was Kotlin's alone. Dropped only for the sentinel outcome. A value or a range refusal never assigns `system_label` in the reference, so an incoming one is preserved here too, and a test pins that in case the fix is ever widened into dropping the key outright. Both orders are pinned, because only one of them was ever wrong and a test holding the other proves nothing. Restoring the old loop fails `aSentinelIdOverwritesAnyIncomingSystemLabelInEitherOrder`. Found by Copilot on #908.
…of zeros Every other gid case in this file is refused twice over — by the digit pre-walk and by the unsigned parse behind it — so none of them holds the walk on its own, and none of them carries a sign at all. `gid://bc3/Person/+7` was untested, which is the one shape this rule and `Ids.parse_int` answer differently about a real person: the reference walks the bytes and refuses anything outside 0..9 BEFORE parsing (`go/pkg/basecamp/mentions.go:252-256`), while `strconv.ParseInt` taken whole reads `"+7"` as 7. The acceptance half is pinned with it. Leading zeros carry no magnitude and pass the walk, so `"007"`, `"010"` and `"0009223372036854775807"` resolve — without those rows the refusal test could be satisfied by refusing too much, and a reader who "hardens" the rule into rejecting zero-padding diverges from the reference just as surely as one who loosens it. The mutation check taught me something I had wrong. My first attempt mutated `bounded_decimal`'s `signed:` flag and the suite stayed green — because the `/\A\d+\z/n` pre-walk is the guard, and the unsigned parse is a second, independent one. Either alone refuses `"+7"`; both have to go before the tests fail. So the verification is: drop the walk AND unsign the parse, and `test_refuses_a_signed_person_id_that_parse_int_would_accept` fails on `+7`. Ruby is defended twice here, which is worth knowing rather than assuming. Prompted by Copilot's finding of the same gap in TypeScript on #908; checked across all seven SDKs, and Ruby was the other one missing it.
… own The normalizer rebuilds a Person-shaped object by replaying its members in order, and a JSON object's members ARE ordered. So when the sentinel branch wrote `system_label` from the raw id and the incoming body happened to spell its own `system_label` AFTER `id`, the loop reached that key afterwards and copied the wire value straight over the one just written. The value being overwritten came off the wire, which is what makes this worth a branch rather than a tidy-up: a response carrying its own `system_label` could choose the label this SDK reports for the system actor — the one field a caller reads to find out which actor it was handed. The reference cannot have the bug and so has no branch for it. `coercePersonID` assigns into a map (`go/pkg/basecamp/normalize.go:66-67`), so the label it writes wins however the body was spelled; only a builder that replays members in order can lose. Kotlin is the only port that rebuilds rather than assigns — Swift, TypeScript, Python and Ruby all overwrite a key — so this was Kotlin's alone. Dropped only for the sentinel outcome. A value or a range refusal never assigns `system_label` in the reference, so an incoming one is preserved here too, and a test pins that in case the fix is ever widened into dropping the key outright. Both orders are pinned, because only one of them was ever wrong and a test holding the other proves nothing. Restoring the old loop fails `aSentinelIdOverwritesAnyIncomingSystemLabelInEitherOrder`. Found by Copilot on #908.
a1862c4 to
9409981
Compare
…of zeros Every other gid case in this file is refused twice over — by the digit pre-walk and by the unsigned parse behind it — so none of them holds the walk on its own, and none of them carries a sign at all. `gid://bc3/Person/+7` was untested, which is the one shape this rule and `Ids.parse_int` answer differently about a real person: the reference walks the bytes and refuses anything outside 0..9 BEFORE parsing (`go/pkg/basecamp/mentions.go:252-256`), while `strconv.ParseInt` taken whole reads `"+7"` as 7. The acceptance half is pinned with it. Leading zeros carry no magnitude and pass the walk, so `"007"`, `"010"` and `"0009223372036854775807"` resolve — without those rows the refusal test could be satisfied by refusing too much, and a reader who "hardens" the rule into rejecting zero-padding diverges from the reference just as surely as one who loosens it. The mutation check taught me something I had wrong. My first attempt mutated `bounded_decimal`'s `signed:` flag and the suite stayed green — because the `/\A\d+\z/n` pre-walk is the guard, and the unsigned parse is a second, independent one. Either alone refuses `"+7"`; both have to go before the tests fail. So the verification is: drop the walk AND unsign the parse, and `test_refuses_a_signed_person_id_that_parse_int_would_accept` fails on `+7`. Ruby is defended twice here, which is worth knowing rather than assuming. Prompted by Copilot's finding of the same gap in TypeScript on #908; checked across all seven SDKs, and Ruby was the other one missing it.
697b8b1 to
32ce521
Compare
… own The normalizer rebuilds a Person-shaped object by replaying its members in order, and a JSON object's members ARE ordered. So when the sentinel branch wrote `system_label` from the raw id and the incoming body happened to spell its own `system_label` AFTER `id`, the loop reached that key afterwards and copied the wire value straight over the one just written. The value being overwritten came off the wire, which is what makes this worth a branch rather than a tidy-up: a response carrying its own `system_label` could choose the label this SDK reports for the system actor — the one field a caller reads to find out which actor it was handed. The reference cannot have the bug and so has no branch for it. `coercePersonID` assigns into a map (`go/pkg/basecamp/normalize.go:66-67`), so the label it writes wins however the body was spelled; only a builder that replays members in order can lose. Kotlin is the only port that rebuilds rather than assigns — Swift, TypeScript, Python and Ruby all overwrite a key — so this was Kotlin's alone. Dropped only for the sentinel outcome. A value or a range refusal never assigns `system_label` in the reference, so an incoming one is preserved here too, and a test pins that in case the fix is ever widened into dropping the key outright. Both orders are pinned, because only one of them was ever wrong and a test holding the other proves nothing. Restoring the old loop fails `aSentinelIdOverwritesAnyIncomingSystemLabelInEitherOrder`. Found by Copilot on #908.
…of zeros Every other gid case in this file is refused twice over — by the digit pre-walk and by the unsigned parse behind it — so none of them holds the walk on its own, and none of them carries a sign at all. `gid://bc3/Person/+7` was untested, which is the one shape this rule and `Ids.parse_int` answer differently about a real person: the reference walks the bytes and refuses anything outside 0..9 BEFORE parsing (`go/pkg/basecamp/mentions.go:252-256`), while `strconv.ParseInt` taken whole reads `"+7"` as 7. The acceptance half is pinned with it. Leading zeros carry no magnitude and pass the walk, so `"007"`, `"010"` and `"0009223372036854775807"` resolve — without those rows the refusal test could be satisfied by refusing too much, and a reader who "hardens" the rule into rejecting zero-padding diverges from the reference just as surely as one who loosens it. The mutation check taught me something I had wrong. My first attempt mutated `bounded_decimal`'s `signed:` flag and the suite stayed green — because the `/\A\d+\z/n` pre-walk is the guard, and the unsigned parse is a second, independent one. Either alone refuses `"+7"`; both have to go before the tests fail. So the verification is: drop the walk AND unsign the parse, and `test_refuses_a_signed_person_id_that_parse_int_would_accept` fails on `+7`. Ruby is defended twice here, which is worth knowing rather than assuming. Prompted by Copilot's finding of the same gap in TypeScript on #908; checked across all seven SDKs, and Ruby was the other one missing it.
There was a problem hiding this comment.
🟡 Changes recommended
Global key-based normalization now coerces string IDs in schemas whose IDs are intentionally strict plain integers.
Get a fresh assessment by requesting another Copilot review.
Review details
- Files reviewed: 41/44 changed files
- Comments generated: 5
- Review effort level: Balanced
|
🤖 Holding this PR. Copilot's global-normalization finding is correct, and it is a regression this branch introduces. Not merging until the fix is settled. Posting the full site inventory here because it is the part that took the work, and the card 42 audit can build on it directly rather than re-deriving it. What the reference actually reachesGo's positional Ruby, Python and TypeScript instead run the positional walk on every response ( Every strict site the walk now reaches
That last row is the one card 42 should note: the strict shape card 42 documents is not affected by this branch either way, so the two pieces of work do not collide at that site. Operations affected: Severity, measuredThe pass fires only on a string id. In Why it is not already fixedThe fix is a fork, and the two branches differ in what they take from card 42:
Put to the operator rather than decided here, since it is a scope call across two cards. Whichever way it goes, the negative test lands with it — a strict site staying strict, proven to fail on the current head. cc the card 42 audit: the inventory above is stable regardless of which option is chosen. |
|
🤖 Adversarial review of 1.
|
…ng it `parse_int64` sliced `text[1:]` for a signed id, copying the whole remaining string before a scan that reaches its verdict within about 20 digits -- the per-digit `magnitude > _UINT64_MAX` check refuses there. So a long malformed id cost a copy of itself for nothing, bounded only by the response body cap, which limits the body rather than any one id inside it. It now takes an offset and walks the string lazily with `islice`, which keeps the ASCII byte test and the per-digit overflow check exactly where they were. Behaviour-neutral, so it adds no test: the 74-row corpus in every position is the regression test, and all 630 rows pass unchanged. Raised by Copilot on #908. Swift's sibling finding (`Array(text.utf8)`) is not taken here: `String.UTF8View` is not Int-indexable, so it is a loop rewrite rather than a line, and Swift does not build on this machine to prove it.
f2c8af0 to
cd982a0
Compare
… own The normalizer rebuilds a Person-shaped object by replaying its members in order, and a JSON object's members ARE ordered. So when the sentinel branch wrote `system_label` from the raw id and the incoming body happened to spell its own `system_label` AFTER `id`, the loop reached that key afterwards and copied the wire value straight over the one just written. The value being overwritten came off the wire, which is what makes this worth a branch rather than a tidy-up: a response carrying its own `system_label` could choose the label this SDK reports for the system actor — the one field a caller reads to find out which actor it was handed. The reference cannot have the bug and so has no branch for it. `coercePersonID` assigns into a map (`go/pkg/basecamp/normalize.go:66-67`), so the label it writes wins however the body was spelled; only a builder that replays members in order can lose. Kotlin is the only port that rebuilds rather than assigns — Swift, TypeScript, Python and Ruby all overwrite a key — so this was Kotlin's alone. Dropped only for the sentinel outcome. A value or a range refusal never assigns `system_label` in the reference, so an incoming one is preserved here too, and a test pins that in case the fix is ever widened into dropping the key outright. Both orders are pinned, because only one of them was ever wrong and a test holding the other proves nothing. Restoring the old loop fails `aSentinelIdOverwritesAnyIncomingSystemLabelInEitherOrder`. Found by Copilot on #908.
…of zeros Every other gid case in this file is refused twice over — by the digit pre-walk and by the unsigned parse behind it — so none of them holds the walk on its own, and none of them carries a sign at all. `gid://bc3/Person/+7` was untested, which is the one shape this rule and `Ids.parse_int` answer differently about a real person: the reference walks the bytes and refuses anything outside 0..9 BEFORE parsing (`go/pkg/basecamp/mentions.go:252-256`), while `strconv.ParseInt` taken whole reads `"+7"` as 7. The acceptance half is pinned with it. Leading zeros carry no magnitude and pass the walk, so `"007"`, `"010"` and `"0009223372036854775807"` resolve — without those rows the refusal test could be satisfied by refusing too much, and a reader who "hardens" the rule into rejecting zero-padding diverges from the reference just as surely as one who loosens it. The mutation check taught me something I had wrong. My first attempt mutated `bounded_decimal`'s `signed:` flag and the suite stayed green — because the `/\A\d+\z/n` pre-walk is the guard, and the unsigned parse is a second, independent one. Either alone refuses `"+7"`; both have to go before the tests fail. So the verification is: drop the walk AND unsign the parse, and `test_refuses_a_signed_person_id_that_parse_int_would_accept` fails on `+7`. Ruby is defended twice here, which is worth knowing rather than assuming. Prompted by Copilot's finding of the same gap in TypeScript on #908; checked across all seven SDKs, and Ruby was the other one missing it.
Both person-id sites — the pre-decode `normalizePersonIds` and `FlexibleLongSerializer` — shared one predicate, `toLongOrNull()` with a `^-?\d+$` regex behind it for the overflow case, and it was wrong in both directions at once. Divergences against the Go table: 12 of 74 at each site, 0 after. Accepting, which is the direction that matters, 7 rows: `toLongOrNull` goes through `digitOf`, which on JVM is `Character.digit` and therefore Unicode-aware. `"123"` read 123, `"٠١٢"` read 12, `"৭7"` and `"7৭"` read 77 — real person ids where Go reads its non-numeric sentinel `0`, which is the SYSTEM ACTOR (`LocalPerson`, `"basecamp"`, `"campfire"`). Verified against the real stdlib rather than assumed: `javap` on kotlin-stdlib 2.4.20 shows `digitOf` is a one-line `invokestatic Character.digit`, and jshell answers 123, 12 and 77 for those three. Sentinel-instead-of-refusal, 5 rows: the regex refuses the leading `+` Go accepts, so `"+9223372036854775808"` collapsed to the system actor rather than failing the read; and the regex gets the scan-order boundary backwards. `ParseUint` checks the magnitude INSIDE the scan against `UInt64.MAX` and returns `ErrRange` before it ever reaches the rest of the string, so `"18446744073709551616x"` is a range refusal that fails the read while `"18446744073709551615x"`, one digit shorter, is a syntax refusal that reads 0. Both sides of that pair are now pinned. `parseInt64` is that scan written out, with the two refusals kept apart as a sealed `ParsedInt64` the caller branches on — no single "is this a number?" predicate can tell them apart, since which refusal comes first depends on where the disqualifying byte sits. Depending on no platform parser also makes the `expect`/`actual` question moot: `digitOf` is per-target, and this module declares only a JVM target today, but the code is in commonMain and the common `digitToInt` contract is Unicode Nd on every target. The gid rule stays apart. `personIdFromSgid` walks the bytes and refuses anything outside `0..9` before parsing, so it rejects the leading `+` this scan accepts; loosening it is the defect #886 closed. `MentionsTest` now pins that in both directions — it refuses `+7`, `+007`, `+9223372036854775807`, `-7` and `-9223372036854775808`, and still accepts `007`, `010` and `0009223372036854775807`, so tightening the walk breaks a test as surely as loosening it. `Mentions.kt` needed no functional change and got none: it compares `personIdFromSgid`'s answer against a `Long` the wire already produced through `FlexibleLongSerializer`, which is the site above. The 74 rows are measured verdicts of the reference's own reader, asserted at both sites — the reader on `{"id":"<raw>"}`, and the normalizer by normalizing then decoding onto the real generated `Person` exactly as `BaseService` runs it, `system_label` included. `./gradlew :basecamp-sdk:check` and `make kt-test` both BUILD SUCCESSFUL. One coverage gap noted rather than closed, because it is about WHICH objects are normalized rather than the grammar: Go runs two passes, the `personable_type`-keyed one and a `creator`/`participants`-keyed one, and Kotlin has only the first. An embedded creator that omits `personable_type` still reads id 0 here, because the reader handles the sentinel where Go's plain int64 field cannot, but it gets no `system_label`.
… the system actor `normalizePersonIds` runs over every response body, and its `^-?\d+$` plus `Number.isSafeInteger` pair was wrong at both ends. It refused the leading `+` that `ParseInt` takes, so `"+7"` — a real person Go reads as 7 — became `id: 0`, which is Go's NON-NUMERIC SENTINEL: the id of a `LocalPerson`, `"basecamp"`, `"campfire"`. And it collapsed every id past `Number.MAX_SAFE_INTEGER` to that same `0` plus a `system_label` — range errors and genuine large int64 ids alike. A real person handed back as the system actor, silently, in the exact shape a caller is meant to trust. `personIdValue` in `mentions.ts` had the third defect, the scan-order one: `ParseUint` checks the magnitude INSIDE the scan against u64 and returns `ErrRange` before reaching the rest of the string, so `"18446744073709551616x"` fails the read in Go while `"18446744073709551615x"`, one digit shorter, is a syntax refusal that reads 0. It answered 0 to both. Both sites now go through one scan, `scanPersonId` in `src/person-id.ts`, which accumulates into a `bigint` so Go's answer is never rounded before a caller decides what to do with it, and keeps the two refusals apart as the thing the caller branches on. Divergences against the measured Go table: 26 of 74 before at the normalizer, 14 of 74 at the reader; 11 at each after, all of them the one residual below. (25 by the id alone at the normalizer; the 26th is `"+0"`, which agreed on `0` while attaching a spurious label.) THE RESIDUAL, argued rather than papered over. `"9007199254740993"` is a real person and a JS `number` cannot carry it — past `MAX_SAFE_INTEGER` two distinct int64s land on the same double — while the SDK types every id as `number` (`conformance/tests/integer-precision.json` records the same constraint for the JSON-number path, and waiver 1B.6 retains it). TypeScript also has no runtime decoder downstream to perform Go's RANGE refusal on its behalf, so whatever is chosen, a caller sees it. Writing `0` is what it did before and is the worst of the three: a wrong id that looks right is the one outcome nothing downstream can defend against. Throwing refuses a response Go reads fine, and refuses ALL of it — one unrepresentable id would discard the other ninety-nine readable people in the body, from inside a normalizer every response passes through. So the string is LEFT IN PLACE: nothing rounded, nothing invented, the digits verbatim for a caller that can hold them, and `typeof person.id === "string"` is a check a caller can actually make. That is the treatment the measured table already assigns to RANGE, so one rule covers both unrepresentable cases, and `personIdValue` already answered this way — the normalizer joins the reader rather than the reverse. Eleven rows, named in the test that pins the count. `personIdValue` is now exported at module level because the scan-order defect is unobservable through `mentionMarkup` — `0` and `undefined` both refuse the mention — so only the corpus can pin it. `index.ts` re-exports explicitly and has no `export *`, so the package's public API is unchanged. The gid rule stays apart: `personIdFromSGID` walks the bytes and refuses anything outside `0..=9` before parsing, which is correct at that site and is the defect #886 closed. Noted at both, in both directions. `make ts-check`: no drift, typecheck clean, 92 files, 1895 tests passed.
…an ICU regex
Both person-id sites — `BaseService.normalizeWalk` and `FlexibleInt` — paired
`Int(s)`, which is ASCII-strict, with `s.range(of: #"^-?\d+$"#, options:
.regularExpression)` to tell an overflow from a sentinel. That pairing was wrong
three separate ways, in both directions at once. Divergences against the Go
table: 13 of 74 at each site, 0 after.
REFUSED WHERE GO LABELS, 9 rows. `NSRegularExpression` is ICU and ICU's `\d` is
`\p{Nd}` — every Unicode decimal digit — while `Int(_:radix:)` is ASCII-only. So
`"123"`, `"٠١٢"`, `"৭"`, `"۷"`, `"7"` and their mixed forms failed `Int()`,
matched the regex, and were therefore reported as numeric OVERFLOW, which throws
and fails the whole response, where Go quietly reads its non-numeric sentinel 0.
And `"7\n"`, which neither the card nor the brief predicted: ICU's `$` matches
before a final newline, AND `range(of:options:)` asks for a match SOMEWHERE
rather than over the whole string. Two anchors that look like they pin both ends
pin neither. Found by calling the actual Swift API — a first ICU probe using
`uregex_matches`, which has full-string semantics, missed it.
NAMED THE SYSTEM ACTOR WHERE GO RAISES, 4 rows. The regex refuses the leading `+`
that `ParseInt` accepts, so `"+9223372036854775808"` fell through to the sentinel
branch; and it gets the scan-order boundary backwards — `ParseUint` checks the
magnitude INSIDE the scan against `UInt64.max` and returns `ErrRange` before
reaching the junk, so `"18446744073709551616x"` fails the read in Go while
`"18446744073709551615x"`, one digit shorter, is a syntax refusal that reads 0.
`parsePersonID` walks the UTF-8 bytes, which settles all three permanently:
there is no character class, anchor or match-mode semantics left to depend on a
library version. It keeps the two refusals apart as a `PersonIDReading` the
caller branches on, and both sites share it, because `coercePersonID` and
`FlexibleInt64` are two call sites of one `ParseInt` in the reference.
`"+7"` was NOT a divergence and the brief was wrong to say so: Swift's
`Int(_:radix:)` takes a leading `+`, so the regex was never reached for it. The
row stays in the corpus — it discriminates for the other ports.
The gid rule stays apart. `Mentions`' global-id parser keeps its digit walk and
its `id > 0`, untouched, with a comment facing the opposite way from the one on
`parsePersonID`: dropping the walk to share this scan would name person 77 for
`gid://bc3/Person/+77`, which is the defect #886 closed.
MEASURED, with what this machine has. There is no Swift toolchain here, so the
corpus was run under `swift:6.0-jammy` in Docker, against a standalone package
holding `FlexibleInt.swift` verbatim and the three normalizer statics lifted
verbatim: 74 rows through the real decode path and through the walk's real
decision logic, before and after, plus ICU's behaviour confirmed twice — through
`uregex_*` in C and through Swift's own `String.range(of:options:)`. Build
complete, 0 warnings, 0 errors under language mode v6.
Two things are reasoned rather than measured, and both are about the platform
rather than the rule. The whole package does not build on Linux for pre-existing
reasons (it is Darwin-only, and the generator has a trailing comma Swift 6.0
rejects), so macOS CI is the first place the full compile is exercised. And the
two new JSON-level normalizer tests fail on Linux — as do the three pre-existing
ones, unmodified — because iterating an `NSMutableDictionary` there yields a
Swift `Dictionary`, so `normalizeWalk`'s `as? NSMutableDictionary` misses nested
values and the walk is a no-op. Cause established rather than guessed;
pre-existing platform property, untouched here.
…erate "Match Go" was not sufficient guidance for a person id, because Go has two rules for one and they disagree on purpose. §10 now says which is which, where a port implementer meets it: the `ParseInt` grammar with its scan order, the three outcomes each site owes to the two refusals, the gid walk that must stay apart in both directions, and the shapes a corpus has to contain before a clean sweep over it means anything. It points at the oracle rather than restating a table. Every port that reasoned from `ParseInt`'s documentation instead of probing it got something wrong, and the probe is checked in as a dump mode on the Go test, so the numbers here can be re-derived rather than trusted. Per-SDK state included, with TypeScript's one residual named as a residual: a JS `number` cannot carry an `int64` past 2^53, the same constraint waiver 1B.6 and `conformance/tests/integer-precision.json` already record, so an id Go reads is reported unreadable rather than rounded or turned into the system actor.
… own The normalizer rebuilds a Person-shaped object by replaying its members in order, and a JSON object's members ARE ordered. So when the sentinel branch wrote `system_label` from the raw id and the incoming body happened to spell its own `system_label` AFTER `id`, the loop reached that key afterwards and copied the wire value straight over the one just written. The value being overwritten came off the wire, which is what makes this worth a branch rather than a tidy-up: a response carrying its own `system_label` could choose the label this SDK reports for the system actor — the one field a caller reads to find out which actor it was handed. The reference cannot have the bug and so has no branch for it. `coercePersonID` assigns into a map (`go/pkg/basecamp/normalize.go:66-67`), so the label it writes wins however the body was spelled; only a builder that replays members in order can lose. Kotlin is the only port that rebuilds rather than assigns — Swift, TypeScript, Python and Ruby all overwrite a key — so this was Kotlin's alone. Dropped only for the sentinel outcome. A value or a range refusal never assigns `system_label` in the reference, so an incoming one is preserved here too, and a test pins that in case the fix is ever widened into dropping the key outright. Both orders are pinned, because only one of them was ever wrong and a test holding the other proves nothing. Restoring the old loop fails `aSentinelIdOverwritesAnyIncomingSystemLabelInEitherOrder`. Found by Copilot on #908.
…of zeros Every other gid case in this file is refused twice over — by the digit pre-walk and by the unsigned parse behind it — so none of them holds the walk on its own, and none of them carries a sign at all. `gid://bc3/Person/+7` was untested, which is the one shape this rule and `Ids.parse_int` answer differently about a real person: the reference walks the bytes and refuses anything outside 0..9 BEFORE parsing (`go/pkg/basecamp/mentions.go:252-256`), while `strconv.ParseInt` taken whole reads `"+7"` as 7. The acceptance half is pinned with it. Leading zeros carry no magnitude and pass the walk, so `"007"`, `"010"` and `"0009223372036854775807"` resolve — without those rows the refusal test could be satisfied by refusing too much, and a reader who "hardens" the rule into rejecting zero-padding diverges from the reference just as surely as one who loosens it. The mutation check taught me something I had wrong. My first attempt mutated `bounded_decimal`'s `signed:` flag and the suite stayed green — because the `/\A\d+\z/n` pre-walk is the guard, and the unsigned parse is a second, independent one. Either alone refuses `"+7"`; both have to go before the tests fail. So the verification is: drop the walk AND unsign the parse, and `test_refuses_a_signed_person_id_that_parse_int_would_accept` fails on `+7`. Ruby is defended twice here, which is worth knowing rather than assuming. Prompted by Copilot's finding of the same gap in TypeScript on #908; checked across all seven SDKs, and Ruby was the other one missing it.
Go's wrapper runs TWO passes over a response body, not one.
`normalizeEmbeddedPeopleJSON` calls the generic `personable_type`-keyed pass AND
`normalizeEmbeddedPersonIds`, which finds people by their known structural
position — the `creator` object and each `participants` element, at any depth,
whether or not they carry a `personable_type`. Its comment says exactly why:
embedded creator/participants people frequently omit that key, so the first pass
skips precisely the payloads the second exists to fix.
TypeScript had only the first pass, and it is the one SDK where that is
observable. Every other port has a runtime decoder behind the normalizer —
Kotlin's `FlexibleLongSerializer`, Swift's `FlexibleInt`, Rust's `flexible_i64`,
Python's `_decoded_flexible_int64`, Ruby's `person_from_wire` — which converts
the string at read time whichever pass did or did not touch it. TypeScript has
none, so an un-normalized `creator.id` reached the caller as the STRING `"007"`
in a field typed `number`, where the reference and the other five give `7`.
Divergences over the 74 rows, per shape:
before after the ParseInt fix now
personable_type person 26/74 11/74 11/74
bare creator 62/74 62/74 11/74
participants element 62/74 62/74 11/74
nested creator 62/74 62/74 11/74
The 62 is every row but the 12 range ones, and those agreed only by accident:
"leave the string in place" is what doing nothing looks like. That accident is
also what made the honest string this normalizer still leaves behind — the id
past 2^53 that a JS `number` cannot carry — unreadable as a signal. It now means
one thing: Go read an int64 this platform cannot hold, and nothing else.
One walk here where Go runs two, which is safe only because `coercePersonId` is
idempotent and both passes apply it unchanged: after `JSON.parse` the body is a
tree, the set of coerced nodes is the same union either way, and a node in both
sets is coerced twice under both schemes — a no-op the second time, since its id
is no longer a string. Only the order differs. Argued in the comment rather than
asserted, and pinned by an idempotence test on a `creator` that also carries
`personable_type`.
Go's type assertions are mirrored, so a `creator: "me"` or a non-array
`participants` is skipped rather than coerced, and that is pinned too.
One test depended on the old behaviour — an hour-old one of my own asserting a
bare `creator: {id: "+7"}` came back as `"+7"` — and it was wrong for the reason
above. Every other TS test and every `spec/fixtures` JSON was scanned for a
string id under `creator`/`participants`: no other hits.
92 files, 1897 tests passed.
The §10 rule covered the grammar and not the coverage, and the coverage is where a port silently differs: `normalizeEmbeddedPeopleJSON` runs a second pass that finds people by structural position — `creator` and each `participants` element, at any depth, regardless of `personable_type` — because embedded people frequently omit that key. Worth stating because it is invisible from inside most ports. An id field with a decoder behind it converts the string at read time whichever pass touched it, so the missing pass shows up only in a port with no runtime decoder, which is how it reached a caller in TypeScript and nowhere else.
Nothing in this suite held Rule A. Every other `personIdFromSGID` case is refused for reasons unrelated to the digit walk and none of them carries a sign, so the `[0-9]` guard could be deleted and the suite would stay green while `gid://bc3/Person/+7` began naming person 7 — the `+77` defect #886 closed, on the field that decides WHO a mention names, so the failure is a tag pointing at the wrong person rather than a dropped read. Refused: `+7`, `-7`, `+007`, `+9223372036854775807`, `-9223372036854775808`, `0` and `-0`. Accepted: `007`, `010`, and `0009007199254740991` — the acceptance half matters as much, since without it the refusals could be satisfied by a walk that refuses too much, and "hardening" the rule into rejecting zero-padding diverges from the reference exactly as far as loosening it does. The nineteen-character padded row is there so the accepted set is not three digits wide: it fails the moment someone bounds the walk by length. Mutation-verified per guard, not per file, which is the lesson from getting it wrong in Ruby an hour earlier. This site has two independent guards, so mutating one leaves the rows the other catches green: removing the digit walk fails on `+7` (1 failed, 56 passed), removing `id <= 0` fails on `0` (2 failed, 55 passed). Each half is genuinely held, and the remaining signed rows are belt-and-braces. One expected value was corrected rather than asserted. `0009223372036854775807` is 9223372036854775807 in Go and `undefined` here: `personIdFromSGID` ends in a safe-integer check, so an id past 2^53 is refused rather than rounded into a neighbouring person. That is the same residual `personIdNumber` argues, reached at rule A's site, and refusing beats misattributing on this field — so it is pinned as the residual it is, with Go's real value named beside it, and SPEC §10 now records that the limit reaches this site too. `personIdFromSGID` itself is byte-identical. 92 files, 1898 tests passed.
… the system actor
`FlexibleInt` spent this branch getting its STRING path exactly right while the
other half quietly answered `0` — the system actor, `LocalPerson` /
`"basecamp"` / `"campfire"` — to everything that was neither an `Int` nor a
`String`. Twelve rows of a 22-row number corpus diverged from the reference; 0
now.
Go runs a JSON number through `json.Decoder` with `UseNumber()` and then calls
`json.Number.Int64()` (`go/pkg/types/flexible_int64.go:52-62`), which IS
`strconv.ParseInt` over the literal's text — the same scan the string path runs.
What the number path does NOT have is the `ErrSyntax`-becomes-`0` branch: `:60`
returns an error for either refusal. So `null`, `true`, `[7]`, `{"a":7}`, `7.5`
and an out-of-range magnitude all fail the read there, and now fail it here.
The row that matters most is the one the brief did not name.
`-9223372036854775809` as a bare JSON number read `0`: the NEGATIVE int64
boundary, the exact mirror of the refusal this branch spent its whole length
pinning on the string side, answering with the id of the actor that posts on
nobody's behalf. Three more the brief missed with it — `1e30`, `0.0`, `-0.0`.
Tests were written first and confirmed failing against the unfixed code.
`null` fails the read and an absent key does not, and here that falls out of the
model rather than needing a branch: `Person.id` is a non-optional `FlexibleInt`,
the SDK's only use site, so a served `null` reaches this initializer and throws
while a missing key is `keyNotFound` and never arrives. That matches
`encoding/json`, which calls `UnmarshalJSON` for a `null` — leaving the
`json.Number` empty, so `ParseInt("")` is a syntax error — while an absent field
keeps its zero value. Ruby's `person_from_wire` documents the same asymmetry.
Both halves are pinned, and so is an `OptionalWrapper` case, because making
`Person.id` optional is a one-character generator change that would silently
turn a served `null` into `nil` without this type ever seeing it. That is now a
failing test rather than a surprise.
SPEC §10's float-tolerant rule is deliberately NOT applied here and the comment
says so: a rich-text `width`/`height` is a bare `Int32?` where BC3 really does
serialize `1024.0` and `null` means "not an image". A pixel count may be
lenient; an identity may not.
ONE RESIDUAL, pinned as a test rather than left implicit: a float-spelled but
integral number in range — `7.0`, `1e3`, `7e0`, `0.0`, `-0.0` — reads as that
integer where Go refuses it. Unreachable rather than unfixed: measured under
Swift 6.0, `7` and `7.0` are indistinguishable through every accessor a
`SingleValueDecodingContainer` offers, because `JSONDecoder` unboxes via
`Int(exactly: Double)`. Closing it needs the raw bytes. The direction is benign
in the way that matters — it reads the CORRECT id for a spelling Go refuses, and
can never produce the system actor or name a different person, unlike the twelve
rows that did.
Two claims are reasoned, not measured, and are marked as such: Go's verdict on
the twelve rows was read off `flexible_int64.go:52-62` rather than run, and full
compilation on macos-15 is inferred, since the package is Darwin-only and there
is no Swift toolchain on this machine. The corpus itself was measured under
`swift:6.0-jammy` against the verbatim source.
Found by adversarial review (Opus) of the head intended for merge.
Python implemented one of the reference's two normalizer passes, and my reason
for thinking that was safe — "the flexible reader converts the string at read
time anyway" — was wrong for Python. That reader runs only inside the
recording-summary composite; every generated service returns a plain dict, so
for everything else nothing converts.
`normalizeEmbeddedPeopleJSON` also finds people by structural position: the
`creator` object and each `participants` element, at any depth, REGARDLESS of
`personable_type`. Go's comment says why — embedded creator and participant
people frequently omit that key, so the first pass skips exactly the payloads the
second exists to fix.
Divergences against the Go table, driven through the real request path rather
than by calling the walk:
before after
personable_type person 0/74 0/74
bare creator 62/74 0/74
participants element 62/74 0/74
nested creator 62/74 0/74
The same 62 as TypeScript, and the twelve that "agreed" agreed only by accident:
they are the RANGE rows, where leaving the string is what doing nothing looks
like.
IT IS REACHABLE ON A WRITE, which is the half a caller feels. Measured through
the real composite both ways:
old walk ApiError: ScheduleEntry field 'participants'[0].id is not
an integer: str '1049715915'
shipped walk OK, seeded participant_ids=[1049715915]
A merge-safe update refusing a body the reference accepts is the vanishing
direction, on a write, from data BC3 controls.
The WALK moved into `basecamp._person_id`, not just the id rule, so the sync and
async base files now import the same function object — pinned by a test
asserting identity rather than agreement, because agreement is what they had
before they drifted. One walk for Go's two, with the idempotence argument in the
docstring and pinned twice: a `creator` that also carries `personable_type`, and
idempotence asserted over all 74 rows. Go's type assertions are mirrored, so
`creator: "me"`, `creator: 7`, `participants: {}` and `participants: ["7", 7,
None]` are skipped.
TWO EXISTING TESTS ASSERTED THE DEFECT and both are corrected rather than
deleted. `test_edit_refuses_malformed_participants_before_writing[string-id]`
pinned the raise above; it is replaced by a `range-string-id` row
(`"9223372036854775808"`) which still raises, because the normalizer leaves a
RANGE string exactly as it arrived and this guard is the reader that refuses it.
The other four rows stay. And the recording-summary creator table now expects a
`system_label` beside the id on its sentinel rows, because that creator sits at a
`creator` key and the second pass reaches it first; Go has no label there, which
is the pre-existing Python breadth difference the file already documents as
Python-only — additive, an extra key beside an id Go agrees on, never a different
id. Verified independently that this cannot reach the cross-SDK comparison: every
one of the 68 creator ids in `conformance/tests/recording_summary.json` is an
integer, so no label is ever produced there.
Scope pinned so it cannot drift: the second pass is keyed on two names, not on
"anything person-shaped". `assignees` is not one of them, and Go does not widen
it either, so a string id there still needs `personable_type`.
2918 passed, 4 skipped. ruff, mypy and the service-drift check all clean.
Found by adversarial review (Opus) of the head intended for merge.
…nd stop to_i minting a bignum id
Three defects from the adversarial review, all on the same surface.
THE SECOND PASS. Ruby implemented one of the reference's two normalizer passes,
and my reason for thinking that was safe — "person_from_wire converts the string
at read time anyway" — was wrong for Ruby: every generated service returns a
plain Hash, so nothing converts. `normalizeEmbeddedPeopleJSON` also finds people
by structural position — the `creator` object and each `participants` element, at
any depth, REGARDLESS of the tag — because embedded creator and participant
people frequently omit it, so the tag-keyed pass skips exactly the payloads the
second exists to fix. Divergences against the 74-row table: bare `creator`
62 → 0, `participants` element 62 → 0, `creator` nested three deep 62 → 0, tagged
control 0 → 0. The twelve rows that "agreed" were the range rows, where leaving
the string is what doing nothing looks like.
One walk for the reference's two, and the equivalence was PROVEN rather than
asserted: `coerce_person_id` now carries the reference's own guard
(`normalize.go:41-44` — return unless the id is a String), so a second visit is a
no-op, and the single walk was run against a literal two-walk transcription of
`normalize.go` over 19 document shapes x 74 wires = 1406 documents: 0 mismatches,
and 0 documents changed by normalizing twice. Both are pinned.
Deliberately not widened past `creator`/`participants`, with a negative control
asserting `assignees` and a bare `person` key stay untouched — the reference
reaches those by tag or not at all.
THE WRITE PATH, which is the half a caller feels. Measured through
`MergeSafe.writable_id_list` on a participants element with a string id and no
tag: before, all 74 rows raised; after, 62 accept and 12 raise — and those 12 are
exactly the out-of-range rows, where the reference also leaves the string and its
own decoder fails the READ, so refusing the WRITE is the matching direction.
A PRE-EXISTING TEST PINNED THE DEFECT: the schedules guard table refused
`{"id" => "1049715914"}` as "a non-integer id", which is precisely the merge-safe
update BC3's own data was blocking. Replaced with an out-of-range id string that
is still malformed after normalization, plus a float id, so the guard stays held
for the right reason rather than the wrong one.
THE BIGNUM, which this branch introduced. `Types::Person` read its id with
`to_i`, so `"18446744073709551616x"` — now correctly left as a string for the
reader to refuse — became the bignum 18446744073709551616, an id that is not even
int64, where the reference fails the read. Divergences at `Types::Person#id`:
29 → 0 raw, 12 → 0 after normalization; that row is now nil.
Fixed in the GENERATOR, not its output: `ruby/scripts/generate-types.rb` already
keyed on `x-go-type: ...FlexibleInt64` to emit the `system_label` accessor, and
exactly one field in `openapi.json` carries that marker, so the flexible-id
branch goes beside it and `types.rb` was regenerated. Nothing under `generated/`
was hand-edited; `make rb-check-drift` confirms it.
1770 runs, 33625 assertions, 0 failures. Drift clean, rubocop clean.
Found by adversarial review (Opus) of the head intended for merge.
…use a mention it cannot name Two defects from the adversarial review, and the first says the earlier two-pass fix copied the wrong mechanism. THE KEY SET. Go never needs the normalizer for a typed read: `generated.Person.Id` is `types.FlexibleInt64`, so EVERY Person-typed field converts at decode. `normalizeEmbeddedPeopleJSON` exists only for the three wrapper paths whose `basecamp.Person.ID` is a plain int64 — so `creator`/`participants` is that wrapper's list, not the model's. TypeScript, which has no decoder at all, was still handing back `"007"` for `assignees`, `subscribers` and `completion_subscribers`, and `writableIdList` then refused it — a merge-safe update blocked by data BC3 controls. `PERSON_VALUED_KEYS` is now derived from the spec rather than typed out: every property whose schema `$ref`s `Person`, or an array of it. Twelve keys. A test recomputes the set from `openapi-stripped.json` and fails on any disagreement. THE GUARD EARNED ITSELF WITHIN THE HOUR. `performed_by` arrived on `Event` and `WebhookEvent` with #898 while this branch was being rebased — 450 schemas became 457 — and the check named it before anyone read the diff. A hand-maintained list would have rotted silently on its first day, which is precisely the failure this finding was. That is now the comment's stated reason for the guard. Three things the reference forced beyond a list of names. Arity is honoured, because Go's wrapper asserts `map[string]any` for `creator` and `[]any` for `participants` while `Assignees []Person` refuses a non-array — an object under `assignees` is a malformed body, not a person to coerce. The derivation asserts non-vacuity before comparing, since a walk that silently stops matching would otherwise "agree" with any set. And only `$ref: Person` counts: `OutOfOfficePerson` and its kin are person-SHAPED but plain int64 in Go. Divergences per position, 74 rows each, through the real pipeline: the five new object positions and the five new array positions were 62 of 74 and are now 11, every one of those 62 being the string reaching the caller untouched. The 11 are the unrepresentable-value residual, identical at every position. A PRE-EXISTING TEST PINNED THE DEFECT here too: an `it.each` row asserting `update` REFUSES a string assignee id. Removed — float, NaN, null and boolean still refused — and replaced with the positive case: a GET carrying `assignees: [{id: "007"}]` now PUTs `assignee_ids: [7]`. THE DROPPED MENTIONS. `mentionedPersonIds` silently skipped an id past 2^53: Go returned 5 for a six-mention text, Ruby 5, this 2, with no error. It now throws, naming the id. The argument, which is in the doc: unlike the normalizer, this returns `number[]` — there is no string to leave in place and no room to say "and one more I could not name". Under-reporting a set is the one failure a caller cannot detect, because the evidence it would need is the thing that was dropped, and it feeds the list deciding who gets notified. `mentions.ts`'s "every `<bc-attachment>` counts" now says so, with `@throws`. An id past INT64 is deliberately not that case: `ParseInt` raises, the reference answers "not a person", and so does this — skipped silently, as it skips it. Both boundaries pinned. One refactor beyond the brief, flagged by its author rather than slipped in: telling those two cases apart needs information `number | undefined` cannot carry, so the gid parse body moved to an internal `parsePersonSGID` and `personIdFromSGID` is a wrapper over it. Every answer is unchanged, and the tail is now literally the reference's shape — `scanPersonId` plus `id <= 0`, compared as a bigint — where `Number()` plus `isSafeInteger` stood, so the safe-integer boundary no longer decides identity. I re-ran the mutation check myself after the refactor: removing the `[0-9]` walk still fails with "+7: expected 7 to be undefined". Two gaps reported rather than hidden, both documented in the code: a response whose ROOT is a Person is unreached when the body omits `personable_type`, since the normalizer cannot know the operation's response schema; and on the new decoder-only positions TS writes a `system_label` where Go's generated path has nowhere to put one, and leaves the string on a range refusal where `FlexibleInt64` fails the read. Both additive or residual, neither a different id. 93 files, 1913 tests passed. No drift. Found by adversarial review (Opus) of the head intended for merge.
… it does not Ruby's `coerce_embedded_person_ids` said widening to `"assignees"` "would coerce ids the reference leaves alone", and Python's scope test said "Go does not widen it either". Both are true of Go's NORMALIZER and false of Go. The reference spells this rule twice. `normalizeEmbeddedPersonIds` covers `creator` and `participants` for the wrapper types whose `Person.ID` is a plain int64, and the generated DECODER covers every other person-valued field, because `generated.Person.Id` is a `types.FlexibleInt64`. So Go's observable answer at `assignees` is the number, reached by the other route — and a reader who took these comments at face value would conclude the string is correct there. It is not. Ruby and Python have no decoder on the generated path, so that second route does not exist for them and an `assignees` id that arrives as a string stays one — measured on a write, where merge-safe refuses a body the reference completes. Both comments now say that plainly, and say why the gap is not closed by widening the list: the faithful site is the reader, field by field, because some person ids in the model really are plain int64 there (`TemplateLibraryConfirmationPerson`) and a blanket sweep would break them. No behaviour changes. This is the comment-accuracy half of the same finding, and it matters because the branch's own review caught two other comments stating measured facts that were not measured. A comment that quietly licenses the defect is worse than no comment.
… JSON integer
`FlexibleLongSerializer`'s NUMBER path — the half the string-path work did not
touch — answered the system actor where Go fails the read. Seven of 25 bare
literals diverged; 0 now.
[7] [] {"a":7} {} read 0 Go fails the read
1e3 1E3 read 1000 Go fails the read
007 read 7 Go fails the read
The arrays and objects fell off the end of `deserialize` to a trailing
`return 0L`, and 0 is `LocalPerson` / `"basecamp"` / `"campfire"` — the system
actor, on the one field that says who acted. `1e3` came through
`JsonPrimitive.long`, which in kotlinx 1.11.0 accepts an exponent; the comment
claiming it is `content.toLong()` was stale. `007` came through kotlinx's
lenient number lexer.
THE FIX IS TWO STAGES, BECAUSE THE REFERENCE IS TWO STAGES. `encoding/json`
validates the token before it ever calls `UnmarshalJSON`, and only then does
`json.Number.Int64()` run `ParseInt(text, 10, 64)`. So: refuse a non-primitive
outright, then apply a JSON-integer token grammar, then hand the survivor to the
existing `parseInt64`. Both stages are load-bearing — reusing `parseInt64` alone
would have REGRESSED `+7` from a refusal to 7, since `ParseInt` takes a leading
sign and the lexer hands `+7` through as a literal. It is also what fixes `007`
for free: that is not valid JSON, and Go scans the document for validity before
dispatching.
There is no sentinel on this path at all. `"basecamp"` is a string, so only the
quoted path can answer 0 without having read a number.
`null` is decided rather than inherited: Go decodes it into an empty
`json.Number` and `ParseInt("")` fails, so `{"id": null}` fails the read while an
absent id is the zero value. Kotlin reaches the same verdict by a different
route — the literal's text is "null" — and both the route and the asymmetry are
written down at the guard, crediting Ruby's `person_from_wire`, which measured it.
MUTATIONS, one guard at a time, and M2 is the one that earns its keep: dropping
the whole grammar check fails only at `007`, NOT at `1e3`/`null`/`true`, because
`parseInt64`'s syntax branch already catches those. That is exactly the
overlapping-guard trap this branch hit twice before, so each guard's unique
contribution is pinned separately. M6 kills nothing and is reported as such
rather than given an invented row: the `Syntax -> 0L` arm is unreachable behind
the grammar check, and the code says so.
ONE ASSERTION REMOVED FROM ANOTHER TEST, deliberately and after checking who
depends on it. `DecodeIsolationTest` asserted the inner cause beneath the
mapped error is a `NumberFormatException`. Nothing reaches a numeric conversion
that can raise any more, so there is no numeric original to carry. Verified
independently that `cause.cause` is read in that one test and nowhere in main,
the generator or the conformance runner, while the composites and the runner read
the OUTER type through `decodeFailure`, which is untouched and still asserted.
The guarantee moved from a catch to the shape of the code, and the KDoc now says
that rather than describing a leak that no longer exists.
RESIDUAL, pinned as measured rather than fixed: an absent `id` is a
`MissingFieldException` where Go reads 0. That is model-layer required-field
handling for a spec-required field — the serializer is never called — and it errs
in the REFUSING direction, declining to invent a person rather than naming actor
0.
Noted for the other ports, not fixed here: kotlinx's lenient lexer means `007`
reads as 7 for EVERY numeric field in this SDK, not only this one. Go fails the
read on all of them.
`:basecamp-sdk:check` BUILD SUCCESSFUL, 717 tests, 0 failures. `make kt-test`
BUILD SUCCESSFUL.
Found by adversarial review (Opus) of the head intended for merge.
…e summary `mentionedPersonIds` threw on a mention whose person id is a valid int64 past 2^53, so that a short list could not pass for a short text. That reasoning is sound and the throw was still the wrong instrument, because of where it runs. `recordings.summarize()` calls it on server-returned `content`, and no sgid signature is verified on that path: `globalIDFromSGID` takes a bare unsigned envelope, so the id inside it is chosen by whoever wrote the comment. One crafted `<bc-attachment>` therefore failed the whole summary -- the content, the title, the creator and every other mention went with the one that could not be named. A denial of read, reachable by any Basecamp user who can comment. It now skips, which is also the reference's own failure mode: `MentionedPersonIDs` (go/pkg/basecamp/mentions.go:82-92) continues past every sgid `PersonIDFromSGID` declines and never fails the text. Go simply has fewer to decline, because an int64 fits its return type. The skip is not silent. `readMentions` returns the same list alongside the ids it could not name, as the decimal strings they arrived as -- strings, because these are exactly the ids a number would round into a neighbouring person. The summary carries them as `unnameable_mention_ids`, a key present only when the mention list is actually short, so no existing payload changes shape. Only TypeScript threw. Ruby and Python ints are arbitrary-precision and both already skipped a declined sgid. Proven to fail: restoring the throw turns three tests red for the stated reason, the summarize one among them -- still reads a recording whose rich text carries an unnameable mention BasecampError: rich text mentions person 9007199254740993, whose id does not fit a JavaScript number Decided by Jorge on card 35 (comment 10309557349): keep the refusal off the summarize path, skip with a distinguishable signal there.
Go's positional pass -- `normalizeEmbeddedPersonIds`, which finds a person under
`creator` and each `participants` element whether or not it carries
`personable_type` -- runs only where `normalizeEmbeddedPeopleJSON` is called:
`decodeGaugePayload` (gauges.go:170) and the notification decoders
(my_notifications.go:171, 281, 296). Nowhere else. Every other person id in Go
converts at DECODE, because `generated.Person.Id` is `types.FlexibleInt64`.
Ruby, Python and TypeScript ran it on every response body. TypeScript went
further and matched twelve spec-derived keys. Neither was safe, because the
keys are matched by name and are not unique to the wrapper types. They reach
schemas whose person id is a plain int64 in the reference, where a string is a
decode error --
Go: json: cannot unmarshal string into Go struct field
UpcomingScheduleEntry.creator.id of type int64
here: {"creator": {"id": 0, "system_label": "basecamp"}}
-- the SYSTEM ACTOR, on the field that says who acted, for a body the reference
refuses outright. A divergence in the accepting direction on an identity
field, which is the class this branch exists to remove. Six sites, now strict:
UpcomingSchedulePerson UpcomingScheduleEntry.creator, .participants,
UpcomingAssignable.assignees,
UpcomingAssignableCompletion.creator
MyAssignmentAssignee MyAssignment.assignees
OutOfOfficePerson DisableOutOfOfficeOutput.person
Latent -- BC3 sends integers at all six in spec/fixtures/schedules/upcoming.json
-- and still wrong. None of the operations serving them carries a genuine
Person field at any depth, so leaving them strict costs no coverage.
Each port now gates the pass on the reference's two surfaces: TypeScript on the
operation's service ("Gauges", "MyNotifications"), Ruby and Python on the
request path, because Go's own boundary is the call site and Ruby's
update_gauge_needle passes no operation id. The personable_type pass keeps its
reach: an object declaring that key IS the Person projection.
THIS WALKS BACK A MEASURED CLAIM, and the cost is stated rather than hidden. The
wider reach was covering a real gap: with no decoder, these three ports now
leave a string id in `assignees`, `subscribers`, `completion_subscribers` and
schedule `participants` as a string, where Go's decoder reads the number, and
the merge-safe composites refuse such a body before writing. That is the
refusing direction -- no id invented, no partial update sent -- and it is
decoder coverage, field by field, not normalizer reach. PR #913 owns it. The
tests that pinned the wider behaviour now pin the refusal, each saying so, as
the ones to flip when #913 lands.
One summarize expectation moves the other way, toward the reference. Python's
summary creator for a sentinel id carried a `system_label`, and only because
the positional pass wrote one onto the recording's untagged creator first. Go's
summary reads through `personFromGenerated` (people.go:920), which never sets
`SystemLabel`, so the reference's answer is `{"id": 0}`. It is now.
The negative test in each port is proven to fail on the previous head -- with
the gate removed, a strict site becomes the system actor:
typescript AssertionError: expected +0 to be 'basecamp'
ruby Expected: "basecamp" Actual: 0
python AssertionError: assert 0 == 'basecamp'
and each converted refusal test goes red the same way (ApiError expected but
nothing was raised), because unscoped the participant string was normalized.
Decided by Jorge on card 35 (comment 10309557349): narrow to Go's two surfaces.
…ng it `parse_int64` sliced `text[1:]` for a signed id, copying the whole remaining string before a scan that reaches its verdict within about 20 digits -- the per-digit `magnitude > _UINT64_MAX` check refuses there. So a long malformed id cost a copy of itself for nothing, bounded only by the response body cap, which limits the body rather than any one id inside it. It now takes an offset and walks the string lazily with `islice`, which keeps the ASCII byte test and the per-digit overflow check exactly where they were. Behaviour-neutral, so it adds no test: the 74-row corpus in every position is the regression test, and all 630 rows pass unchanged. Raised by Copilot on #908. Swift's sibling finding (`Array(text.utf8)`) is not taken here: `String.UTF8View` is not Int-indexable, so it is a loop rewrite rather than a line, and Swift does not build on this machine to prove it.
…de-off §10 said a person is found two ways and did not say where the second way runs, which is how three ports came to run it everywhere. It now states the rule -- the reference's call sites, gauges and notifications, and no wider -- names the six strict sites the wider reach turned into the system actor, and says what that reach had been covering and where that gap is tracked (#913), so a port implementer meets the boundary and the reason for it in the same place. The TypeScript row records the mentionedPersonIds skip as the availability trade-off it is: an under-report, deliberately chosen over a throw that let one crafted comment make a recording unreadable, and made visible through readMentions and the summary's unnameable_mention_ids.
…ain-text line
Two defects in the distinguishable signal added for skipped mentions, both
found by adversarial review (Opus) of the head intended for merge.
`unnameable` was deduplicated on the raw digits. The reference deduplicates on
the int64 (go/pkg/basecamp/mentions.go:87), so `9223372036854775807` and
`0009223372036854775807` are one person -- and the signal exists precisely so a
caller can see how short the mention list is. On the branch's own six-mention
text Go names 5 people; `ids` plus `unnameable` came to 6. The unrepresentable
case now carries the CANONICAL decimal, formatted from the bigint the scan
already produced, and is deduplicated on that. The count matches the
reference, and a leading-zero spelling reports digits a caller can match
against a person id.
A plain-text chat line kept `unnameable_mention_ids`. The projection runs the
rich-text walk over `content` and only then learns the line is not rich text,
where it resets `mentioned_person_ids` to `[]` -- but not the new key. So a
line BC3 never read as markup reported an unnameable mention of someone it does
not mention, in Go or here. The key is now dropped with the list it belongs to.
The `MentionedPerson` doc still said `mentionedPersonIds` "has to refuse
rather than drop" such a mention; it now says what the code does.
Proven to fail on the previous head:
dedup expected [ '9007199254740992', ...(3) ]
to deeply equal [ '9007199254740992', ...(2) ]
chat line expected true to be false ("unnameable_mention_ids" in text)
…he path
The gate added to run the positional pass only on Go's two surfaces was correct
on reading and half-unpinned in every port. Adversarial review (Opus) mutated
each piece and the suites stayed green:
typescript drop "Gauges" from the gate 1935 pass
wrong service on followed pages 1935 pass
ruby embedded_people: false in Response#json+parse_page 1780 pass
python async gate always False 2939 pass
every paginated sync site forced False 2939 pass
The only pinned positive case anywhere was the first page of a notifications
read. Each hole now has a test driven through the real client, and each is
proven to go red under the exact mutation that used to pass:
typescript gaugeNeedle, untagged creator expected '007' to be 7
listGaugeNeedles, page 2 expected '+8' to be 8
ruby get_gauge_needle / my notifications Expected: 7 Actual: "007"
list_gauge_needles, both pages Expected: [7, 8]
Actual: ["007", "+8"]
upcoming report, through HTTP (fails when the gate
always matches)
python async get_gauge_needle, async and 2 failed
sync list_gauge_needles on 2 pages 1 failed
Two gate fixes ride with them:
ANCHORED TO THE END OF THE PATH. Ruby and Python matched unanchored patterns
against the whole URL, host included, so a base URL whose own path contained
`/gauge_needles/` would have switched the pass on for every request. Each
pattern now matches only the URL's path, anchored at its end, per surface
(`/my/readings.json`, `/my/readings/bubble_ups.json`, `/gauge_needles/<id>`,
`/projects/<id>/gauge/needles.json`, `/reports/gauges.json`). Proven: under
the old patterns, a proxy prefix, a trailing segment and a nested path all
switch the pass on (python: 4 of 5 cases fail).
`httpx.Response.request` RAISES RuntimeError when unset; it is never merely
absent, so `getattr(response, "request", None)` let the error out of the gate
instead of defaulting. Proven: `RuntimeError: The request instance has not
been set on this response.`
Also corrects `_person_id.py`'s docstring, which still presented the pass as
the fix for `schedules.edit_entry` two paragraphs before the section that
walks that back, and an islice comment that said the scan decides "within ~20
digits" without saying leading zeros are walked in full, as Go walks them.
… gap
Two statements this round made were wrong, and adversarial review (Opus)
checked both against a probe of the reference.
The Python summarize table said `{"id": 0}` is "what Go's summary carries" for
a sentinel creator. Not for this fixture, which sends a creator with no name:
`commentFromGenerated` sets the creator only when `Id != 0 || Name != ""`
(go/pkg/basecamp/comments.go:364), so Go's summary has no `creator` key at all.
With a name, Go gives `{"id": 0, "name": ...}` -- which is what dropping the
label now matches. The comment now says both, and names the presence rule as a
pre-existing projection divergence (Python keeps `{"id": 0}`; Ruby omits the
creator, as Go does) left untouched rather than folded into a person-id change.
The contradicting comment block above it, which still explained a label that
is no longer there, is gone.
SPEC §10's list of what the narrowed pass leaves as a string was incomplete.
It named `assignees`, `subscribers`, `completion_subscribers` and schedule
`participants`. It now also names an untagged `creator` on every recording
read in all three decoder-less ports, and TypeScript's further seven keys
(`approver`, `booster`, `completer`, `performed_by`, `granted`, `revoked`,
`person`). All of it is decoder coverage and belongs to #913.
It also says where the gap is VISIBLE, and that was measured on the rebased
code, not taken from the review: a plain generated read. `comments.get` returns
an untagged `creator.id` of "7" as the string "7" in TypeScript, Ruby and
Python alike, where Go gives 7. The recording-summary composites do not show
it -- since #911 all three decode a nested person's id as a FlexibleInt64, so
`recordings.summarize()` gives 7 in every port. (Before rebasing onto #911 this
line claimed the opposite for TypeScript; it was true of that base and is not of
this one.)
…stem actor #911 landed a summarize test whose last assertion pinned the behaviour this branch removes. For a creator carrying `personable_type` and the id "9223372036854775807" it expected person 0, because `main`'s pre-pass collapsed every id past Number.MAX_SAFE_INTEGER into 0-plus-system_label -- the system actor, for a real person Go reads exactly. Its comment called that the behaviour "a caller actually sees on a real person", and at the time it was. That collapse is one of the defects #908 fixes. The pre-pass now reads the id Go reads and, unable to hold it in a number, leaves the string for the reader, which refuses it with the same "exactly" message it gives the untagged spelling a few lines above. So tagged and untagged now agree, and neither names the system actor. The two PRs were each correct against their own base; this is the merge of them, found by running the suite after rebasing onto #911. The assertion now expects the refusal. Proven to discriminate: restoring `main`'s collapse in `coercePersonId` makes it fail, because a summary comes back instead -- expected { id: 1, status: '', type: '', ...(7) } to be an instance of BasecampError
…mits
The summarize table's note on the pre-existing presence divergence said
"Python keeps {"id": 0} ... Ruby omits it". TypeScript keeps it too: the
convergence review probed `recordings.summarize` and a nameless sentinel creator
comes back as {"id": 0} there, where Go's `commentFromGenerated` drops the
creator entirely. So the sentence under-counted which ports diverge. It now
names both. Comment only.
d1cd306 to
efaaa58
Compare
Every SDK here turns a person id that arrived as a JSON string into a number, because BC3
serializes one that way on some payloads and spells its system actors —
LocalPerson,whose id is
"basecamp"or"campfire"— in the same string field. Go reads those actorsas 0.
Each SDK reached for its own language's integer parser, and none of those parsers is the
one the reference applies. Python's
int()read a fullwidth"123"as person 123.Kotlin's
toLongOrNulldid the same throughCharacter.digit. TypeScript turned every idpast 2^53 — and every id with a leading
+— intoid: 0, which is to say intoLocalPerson. Swift's ICU-flavoured\dtreated a fullwidth digit run as an overflow andfailed the whole response. Four ports read an oversized malformed id as the system actor
where Go raises.
And Go disagreed with itself. Its pre-decode normalizer held a
ParseInt-valid stringverbatim as a
json.Number, which the JSON encoder then refused — that grammar allowsneither a leading
+nor leading zeros — so the marshal failed, every caller fell back tothe raw body, and the raw body still has a string where the wrapper's
Person.IDis aplain
int64. An embedded creator with id"+7"or"007"failed the whole responseon the notification, gauge and bubble-up paths, while Go's own
FlexibleInt64, reading thesame bytes, read 7.
Context
One branch, because they are one surface. Follow-up filed as 42 Merge-safe writes refuse
assignee ids the reference accepts,
which is a different question — decoder coverage rather than normalizer grammar — and needs
a per-SDK, per-field audit rather than a sweep.
The rule
strconv.ParseInt(s, 10, 64), scan order included, written out once per language andshared by that language's person-id sites. Not its documentation:
ParseUintchecks themagnitude inside the scan and returns
ErrRangethe instant the accumulator wouldoverflow
uint64, before it reaches the rest of the string, so"18446744073709551616x"fails the read while
"18446744073709551615x"— the same length, one smaller — is a syntaxrefusal that reads 0. The pair differs by which refusal the scan reaches first:
...616overflows
uint64mid-scan and returnsErrRangebefore it ever sees thex, while...615does not overflow, so the scan runs on into thexand returnsErrSyntax. Every port had that pair backwards, in the direction that names the system actor.Its two refusals stay apart, because the SDK does different things with them: a syntax
refusal is the sentinel and reads 0; a range refusal leaves the value alone so the read
fails. No single "is this a number?" predicate can separate them.
The gid rule stays deliberately different, and every SDK now has a test saying so in
both directions.
PersonIDFromSGIDwalks the bytes and refuses anything outside0..=9before parsing, so it rejects the leading
+the other rule accepts — correct at thatsite, and loosening it is the
+77defect#886 closed. It is also not simply the
stricter of the two: leading zeros pass its walk, so a reader who "hardens" it by refusing
"007"breaks a test as surely as one who loosens it. Ruby and TypeScript had no such testat all; both could have lost the guard silently.
Measured against a linked oracle
Expectations come from a probe linked against the real
normalizeEmbeddedPeopleJSON, thereal
types.FlexibleInt64and the realPersonIDFromSGID, over a corpus built to hold theshapes that discriminate. It is checked in as a dump mode on the Go test, so the next
reader re-derives the table rather than trusting a comment.
Divergences over the 74 rows, per site, before and after:
coercePersonIDvsFlexibleInt64)TypeScript's 11 are one residual, argued in the code: a JS
numbercannot carry anint64past 2^53, so an id Go reads is reported unreadable rather than rounded to a different
person or collapsed to the system actor.
What adversarial review changed
A separate Opus reviewer read each head intended for merge, round after round. The findings
below are the ones that changed the code, in the order they were found; the last two are
defects this branch had itself introduced, and have their own section at the end.
The scan survived — 70 further corpus rows across five ports, 0 divergences; 26 mutations,
each guard mutated separately, all 26 caught — but the call paths did not.
The claim it broke was mine: that the other ports' decoders made a missing normalizer
pass unobservable. Go runs two passes, finding people by
personable_typeand bystructural position, because embedded creator and participant people frequently omit the
tag. Every port implemented one. Ruby and Python have no decoder at all, so both carried the
same 62 of 74 divergence at an untagged
creatororparticipantselement. Both portsnow run both passes, and Ruby proved its single walk equivalent to a literal two-walk
transcription over 1406 documents. Where that second pass runs turned out to matter as
much as whether it runs — see the last section.
Swift's number path answered the system actor for
9223372036854775808— the exactrefusal this branch spent its length pinning on the string side — along with
null,true,[7],{"a":7}and7.5. Twelve of a 22-row number corpus diverged; 0 now. Four rowsworse than the brief reported, and the one that matters most is
-9223372036854775809: the negative int64 boundary, read as0, which is the id of theactor that posts on nobody's behalf.
1e30,0.0and-0.0came with it.Kotlin's number path had the same hole, found the same way and fixed last: seven of 25
bare literals diverged, 0 now.
[7],[],{"a":7}and{}fell off the end ofdeserializeto a trailingreturn 0L;1e3came throughJsonPrimitive.long, whichaccepts an exponent in kotlinx 1.11.0;
007came through kotlinx's lenient number lexer.The fix is two stages because the reference is two stages —
encoding/jsonvalidates thetoken before
UnmarshalJSONever runs — and both are load-bearing: reusingparseInt64alone would have regressed
+7from a refusal to 7. Each guard's unique contribution ismutated separately, because dropping the whole grammar check fails only at
007, which isthe overlapping-guard trap this branch hit twice before.
And
mentionedPersonIdssilently dropped mentions: Go returned 5 for a six-mentiontext, Ruby 5, TypeScript 2, with no error. It briefly threw instead — and the last round
showed the throw was worse. See below.
What the last review round walked back
The final round — Copilot's re-review and a fresh adversarial Opus review, both on
32ce521f— found two defects this branch introduced. Both are fixed, and both fixeswere decided by Jorge on
card 35:
"1) keep the refusal off the summarize path, skip with a distinguishable signal there
2) narrow to Go's two surfaces".
1. A crafted comment could make a recording unreadable. To stop
mentionedPersonIdsunder-reporting, TypeScript made it throw on a mention whose id is a valid
int64past2^53. But
recordings.summarize()calls it on server-returnedcontent, and no sgidsignature is verified on that path — the id is chosen by whoever wrote the comment. One
crafted
<bc-attachment>failed the whole summary: a denial of read, reachable by anyuser who can comment, on the one input in the SDK that is untrusted by construction.
It now skips, which is also the reference's own failure mode —
MentionedPersonIDscontinues past every sgid it declines. The skip is not silent:
readMentionsreturns theids it could not name, as decimal strings, and the summary carries them as
unnameable_mention_ids— a key present only when the mention list is actually short, sono existing payload changes shape. The under-report is real and is now an availability
trade-off stated in SPEC §10 rather than a throw.
2. The positional pass reached schemas the reference refuses — so the measured write
fix is walked back. Go runs its positional pass only where
normalizeEmbeddedPeopleJSONis called:
decodeGaugePayload(gauges.go:170) and the notification decoders(
my_notifications.go:171,281,296). Everywhere else Go converts at decode, becausegenerated.Person.IdisFlexibleInt64. This branch ran the pass on every response inRuby, Python and TypeScript, and TypeScript widened it to twelve spec-derived keys to
stand in for the decoder it lacks.
That was a divergence in the accepting direction on an identity field. The keys are
matched by name and are not unique to the wrapper types, so the pass reached schemas whose
person id is a plain
int64in the reference — where a string is a decode error — andwrote person
0with asystem_label: the system actor, for a body Go refusesoutright. Measured latent (BC3 sends integers at all of them today in
spec/fixtures/schedules/upcoming.json), and still exactly the class this PR exists toremove. The pass now runs only on Go's two surfaces, and these six sites are left
strict:
int64id in Go)UpcomingSchedulePersonUpcomingScheduleEntry.creatorUpcomingSchedulePersonUpcomingScheduleEntry.participantsUpcomingSchedulePersonUpcomingAssignable.assigneesUpcomingSchedulePersonUpcomingAssignableCompletion.creatorMyAssignmentAssigneeMyAssignment.assigneesOutOfOfficePersonDisableOutOfOfficeOutput.personNone of the operations serving them carries a genuine
Personfield at any depth, soleaving them strict costs nothing there.
What it does cost, stated plainly, because earlier versions of this description claimed
the opposite:
schedules.edit_entryraised on a body the reference accepts, and that running bothpasses everywhere fixed it. The wider reach was what fixed it. With no decoder, Ruby,
Python and TypeScript now refuse a string id in
assignees,subscribers,completion_subscribersand scheduleparticipants, where Go's decoder reads the number.$.completerperson inspec/fixtures/cards/step.json— a real id, nopersonable_type— was normalized only bythe twelve-key set, and is not normalized now.
wrong way: by name, at any depth, on every body. It is now the reference's two keys.
schedules guard and Python's
[string-id]row, both asserting a string person id raises —describe what these ports do again. The refusal is now pinned deliberately, as a named
divergence, rather than by accident.
All four are the refusing direction: no id is invented, and every merge-safe composite
refuses before its PUT, so no partial update is sent. That is decoder coverage, field
by field against the reference, rather than normalizer reach, and it belongs to
#913 (card 42). The tests that pinned
the wider behaviour now pin the refusal, each named as the one to flip when #913 lands.
Each port has a negative test — a strict site keeps refusing a string id — proven to
fail on
32ce521ffor the stated reason, which is the system actor appearing:One expectation moved toward the reference. Python's summary creator for a sentinel id
carried a
system_label, only because the pass wrote one onto the recording's untaggedcreator first. Go's summary reads through
personFromGenerated(people.go:920), whichnever sets
SystemLabel.Every residual that remains is pinned as a test with its reason, and SPEC §10 states the
rule, the deliberate disagreements, and — new in this round — where the positional pass runs
and why no wider.