Skip to content

Seven SDKs read a person id seven ways, and Go disagreed with itself - #908

Merged
jorgemanrubia merged 28 commits into
mainfrom
person-id-grammar
Sep 16, 2026
Merged

jorgemanrubia merged 28 commits into
mainfrom
person-id-grammar

Conversation

@jorgemanrubia

@jorgemanrubia jorgemanrubia commented Sep 16, 2026

Copy link
Copy Markdown
Member

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 actors
as 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 toLongOrNull did the same through Character.digit. TypeScript turned every id
past 2^53 — and every id with a leading + — into id: 0, which is to say into
LocalPerson. Swift's ICU-flavoured \d treated a fullwidth digit run as an overflow and
failed 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 string
verbatim as a json.Number, which the JSON encoder then refused — that grammar allows
neither a leading + nor leading zeros — so the marshal failed, every caller fell back to
the raw body, and the raw body still has a string where the wrapper's Person.ID is a
plain int64. An embedded creator with id "+7" or "007" failed the whole response
on the notification, gauge and bubble-up paths, while Go's own FlexibleInt64, reading the
same 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 and
shared by that language's person-id sites. Not its documentation: ParseUint checks the
magnitude inside the scan and returns ErrRange the instant the accumulator would
overflow uint64, before it reaches the rest of the string, so "18446744073709551616x"
fails the read while "18446744073709551615x" — the same length, one smaller — is a syntax
refusal that reads 0. The pair differs by which refusal the scan reaches first: ...616
overflows uint64 mid-scan and returns ErrRange before it ever sees the x, while
...615 does not overflow, so the scan runs on into the x and returns ErrSyntax. 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. PersonIDFromSGID walks the bytes and refuses anything outside 0..=9
before parsing, so it rejects the leading + the other rule accepts — correct at that
site, and loosening it is the +77 defect
#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 test
at all; both could have lost the guard silently.

Measured against a linked oracle

Expectations come from a probe linked against the real normalizeEmbeddedPeopleJSON, the
real types.FlexibleInt64 and the real PersonIDFromSGID, over a corpus built to hold the
shapes 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:

normalizer reader
Go (coercePersonID vs FlexibleInt64) 13 → 0
Rust none to have 0 → 0
Ruby 3 → 0 3 → 0
Python 29 → 0 0 → 0
Kotlin 12 → 0 12 → 0
Swift 13 → 0 13 → 0
TypeScript 26 → 11 14 → 11

TypeScript's 11 are one residual, argued in the code: a JS number cannot carry an int64
past 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_type and by
structural 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 creator or participants element. Both ports
now 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 exact
refusal this branch spent its length pinning on the string side — along with null, true,
[7], {"a":7} and 7.5. Twelve of a 22-row number corpus diverged; 0 now. Four rows
worse than the brief reported, and the one that matters most is
-9223372036854775809: the negative int64 boundary, read as 0, which is the id of the
actor that posts on nobody's behalf. 1e30, 0.0 and -0.0 came 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 of
deserialize to a trailing return 0L; 1e3 came through JsonPrimitive.long, which
accepts an exponent in kotlinx 1.11.0; 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 UnmarshalJSON ever runs — and both are load-bearing: reusing parseInt64
alone would have regressed +7 from a refusal to 7. Each guard's unique contribution is
mutated separately, because dropping the whole grammar check fails only at 007, which is
the overlapping-guard trap this branch hit twice before.

And mentionedPersonIds silently dropped mentions: Go returned 5 for a six-mention
text, 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 fixes
were 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 mentionedPersonIds
under-reporting, TypeScript made it throw on a mention whose id is a valid int64 past
2^53. But recordings.summarize() calls it on server-returned content, and no sgid
signature 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 any
user 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 — MentionedPersonIDs
continues past every sgid it declines. The skip is not silent: readMentions returns the
ids 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, so
no 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 normalizeEmbeddedPeopleJSON
is called: decodeGaugePayload (gauges.go:170) and the notification decoders
(my_notifications.go:171,281,296). Everywhere else Go converts at decode, because
generated.Person.Id is FlexibleInt64. This branch ran the pass on every response in
Ruby, 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 int64 in the reference — where a string is a decode error — and
wrote person 0 with a system_label: the system actor, for a body Go refuses
outright. Measured latent (BC3 sends integers at all of them today in
spec/fixtures/schedules/upcoming.json), and still exactly the class this PR exists to
remove. The pass now runs only on Go's two surfaces, and these six sites are left
strict
:

type (plain int64 id in Go) field
UpcomingSchedulePerson UpcomingScheduleEntry.creator
UpcomingSchedulePerson UpcomingScheduleEntry.participants
UpcomingSchedulePerson UpcomingAssignable.assignees
UpcomingSchedulePerson UpcomingAssignableCompletion.creator
MyAssignmentAssignee MyAssignment.assignees
OutOfOfficePerson DisableOutOfOfficeOutput.person

None of the operations serving them carries a genuine Person field at any depth, so
leaving them strict costs nothing there.

What it does cost, stated plainly, because earlier versions of this description claimed
the opposite:

  • The merge-safe write fix is gone. This description said Python's
    schedules.edit_entry raised on a body the reference accepts, and that running both
    passes 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_subscribers and schedule participants, where Go's decoder reads the number.
  • The live fixture gap is open again. The $.completer person in
    spec/fixtures/cards/step.json — a real id, no personable_type — was normalized only by
    the twelve-key set, and is not normalized now.
  • TypeScript's spec-derived key set is gone. It was the right derivation applied the
    wrong way: by name, at any depth, on every body. It is now the reference's two keys.
  • Two tests this description called "holding the wrong behaviour in place" — Ruby's
    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 32ce521f for the stated reason, which is the system actor appearing:

typescript  AssertionError: expected +0 to be 'basecamp'
ruby        Expected: "basecamp"  Actual: 0
python      AssertionError: assert 0 == 'basecamp'

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 untagged
creator first. Go's summary reads through personFromGenerated (people.go:920), which
never 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.

Copilot AI balanced review requested due to automatic review settings September 16, 2026 10:32
@jorgemanrubia

Copy link
Copy Markdown
Member Author

@codex review

@github-actions github-actions Bot added typescript Pull requests that update TypeScript code ruby Pull requests that update the Ruby SDK go kotlin swift python Pull requests that update the Python SDK rust Rust SDK labels Sep 16, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to 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.

Comment thread typescript/tests/services/mentions.test.ts
jorgemanrubia added a commit that referenced this pull request Sep 16, 2026
… 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.
jorgemanrubia added a commit that referenced this pull request Sep 16, 2026
…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.
jorgemanrubia added a commit that referenced this pull request Sep 16, 2026
… 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.
jorgemanrubia added a commit that referenced this pull request Sep 16, 2026
…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.
jorgemanrubia added a commit that referenced this pull request Sep 16, 2026
… 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.
jorgemanrubia added a commit that referenced this pull request Sep 16, 2026
…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.
@jorgemanrubia
jorgemanrubia requested a balanced review from Copilot September 16, 2026 12:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread python/src/basecamp/_person_id.py Outdated
Comment thread ruby/lib/basecamp/http.rb
Comment thread typescript/src/services/base.ts Outdated
Comment thread python/src/basecamp/_person_id.py
Comment thread swift/Sources/Basecamp/FlexibleInt.swift
@jorgemanrubia

Copy link
Copy Markdown
Member Author

🤖 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 reaches

Go's positional creator/participants pass (normalizeEmbeddedPersonIds) runs only where normalizeEmbeddedPeopleJSON is called — gauges.go:171, my_notifications.go:171,281,296. Nowhere else. todos.go:68-77 mentions it in prose only. Every other person id in Go converts at decode, because generated.Person.Id is types.FlexibleInt64 (client.gen.go:2484).

Ruby, Python and TypeScript instead run the positional walk on every response (ruby/lib/basecamp/http.rb:55 via Response#json and parse_page; python/.../generated/services/_base.py:71,106,199,299,362,420,452; typescript/src/services/base.ts PERSON_VALUED_KEYS). Kotlin, Swift and Rust have no positional pass and are unaffected.

Every strict site the walk now reaches

Person.Id is FlexibleInt64, so Go converts a string there. These have a plain int64 id, so Go rejects a string:

type Go id reached by the walk at
UpcomingSchedulePerson int64 (:4196) UpcomingScheduleEntry.creator, .participants, UpcomingAssignable.assignees, UpcomingAssignableCompletion.creator
MyAssignmentAssignee int64 (:2323) MyAssignment.assignees
OutOfOfficePerson int64 (:2452) DisableOutOfOfficeOutput.person
PreferencesPayload no id member UpdateMyPreferencesInput.person — an input shape; inert
TemplateLibraryConfirmationPerson int64 (:3487) not reached. It sits under PeopleConfirmationRequiredError.people, and people is not a key in this walk

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: GetUpcomingSchedule, GetMyAssignments, GetMyDueAssignments, GetMyCompletedAssignments, PrioritizeAssignment / DeprioritizeAssignment / ReorderUpNext, DisableOutOfOffice. Each response schema walked to full depth: none contains a genuine Person-typed field, so scoping the pass away from these operations costs nothing.

Severity, measured

The pass fires only on a string id. In spec/fixtures/schedules/upcoming.json all six upcoming-schedule sites arrive as JSON integers, and those objects carry no personable_type. So the divergence is latent today, not a live defect — the same standard this branch applied to the root-Person case. Still a divergence from the reference, and still this branch's to fix.

Why it is not already fixed

The fix is a fork, and the two branches differ in what they take from card 42:

  1. Narrow to Go's two wrapper surfaces. Faithful and small, but it hands assignees / subscribers / completion_subscribers back to card 42 — and walks back the measured merge-safe-write fix this PR currently claims.
  2. Keep the wider reach, make it operation-aware from the spec. Keeps the measured improvement and satisfies "prove the reach is identical", but it keeps this PR standing in card 42's territory.

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.

@jorgemanrubia

Copy link
Copy Markdown
Member Author

🤖 Adversarial review of 32ce521f (a separate Opus reviewer, read-only, briefed to break the change). It holed it in three places, one of which I had not seen and which I think outranks the normalization finding.

1. recordings.summarize() now throws on untrusted rich text — new denial-of-read

mentionedPersonIds (typescript/src/services/mentions.ts:118) used to skip an sgid whose person id exceeds 2^53; this branch makes it throw, discarding every other mention in the text. projectRecording calls it unguarded on server-returned content (typescript/src/services/recordings-extensions.ts:1753).

The sgid's signature is not verifiedglobalIDFromSGID accepts a bare unsigned envelope — so the id is attacker-controlled by anyone who can write a <bc-attachment> into a comment. One crafted comment makes the whole summary unreadable:

THREW: BasecampError api_error
  rich text mentions person 9007199254740993, whose id does not fit a JavaScript number

The response was otherwise well-formed. Before this branch, summarize returned the summary with that mention skipped.

What makes this sharp is that person-id.ts argues against exactly this shape for the normalizer — "One unrepresentable id in one embedded person would discard every other record in the body… The id is safe; everything beside it pays." — and then this site does it, on the one input in the SDK that is untrusted by construction. The under-reporting argument in the docstring is sound and I still believe it; the throw is the wrong instrument at a site whose input an adversary writes. Severity: blocker in my read.

2. The positional pass reaches schemas the reference decodes as plain int64

Independently reproduced what Copilot found, with the reference's own refusal alongside:

Go:     json.Unmarshal(`{"creator":{"id":"basecamp",…}}`, &generated.UpcomingScheduleEntry{})
        -> cannot unmarshal string into field UpcomingScheduleEntry.creator.id of type int64
Ruby:   {"creator"=>{"id"=>0, …, "system_label"=>"basecamp"}}
Python: {'creator': {'id': 0, …, 'system_label': 'basecamp'}}
TS:     {"creator":{"id":0,…,"system_label":"basecamp"}}

So a body the reference refuses outright now reads as the system actor — in the accepting direction, on an identity field. These three sites were untouched before this diff, so it is new.

It also contradicts a rationale already written into this branch's own drift check (person-id-normalization.test.ts:186-190): "OutOfOfficePerson and friends are person-SHAPED but are plain int64 ids in the reference." The derivation excludes those schemas; the application is by key name, so the exclusion never takes effect for a name that a Person-typed field elsewhere already claims. creator and participants are both such names. Full site inventory in my previous comment.

3. Ruby and Python still refuse merge-safe writes that Go — and now TypeScript — accept

TypeScript closes assignees in this diff; Ruby and Python do not. Ruby documents the deferral (http.rb:71-86, "Tracked as its own unit of work"); Python does not mention it at all, and normalize_person_ids's docstring claims it "owns BOTH of the passes that function runs" — true of Go's normalizer, but it misses Go's second mechanism, the flexible decoder. The same write-path failure this PR fixes for participants, left standing on the sibling keys, now inconsistent across ports within one change.

4. Two doc errors, one of them mine

  • base.ts says twice that Go runs normalizeEmbeddedPeopleJSON on "notifications, gauges, todos". It does not — the only call sites are gauges.go:171 and my_notifications.go:171,281,296. Todo person ids reach Go through the generated decoder instead, which is the very distinction that comment is drawing.
  • The PR description called "18446744073709551615x" "one digit shorter" than "18446744073709551616x". Same length, one smaller. Fixed in the description; the pair differs by which refusal the scan reaches first, which is the whole point of it.

5. A wall-clock assertion

ids_test.rb, test_the_scan_bounds_itself_without_a_length_gate scans 10M digits in interpreted Ruby and asserts elapsed < 1.0. It pins something real, but it is the only timing assertion in this work and a flake candidate on a loaded runner.

What it attacked and could not break

Worth recording, since it bounds what the above does and does not cast doubt on. Grammar equivalence to strconv.ParseInt re-derived by hand in all six portsParseUint's in-loop u64 bound and ParseInt's asymmetric signed bound reproduce exactly everywhere, Kotlin's algebraic rearrangement included. It regenerated the Go oracle and mechanically diffed all five language corpora against it: 74 rows each, identical strings, identical verdicts, zero disagreements. Rule A / Rule B separation holds in every port, in both directions. Idempotence of the positional pass confirmed. Unicode digits (fullwidth, Arabic-Indic, Extended Arabic-Indic, Bengali, mixed) refused everywhere, none via a \p{Nd}-aware path. The replaced Ruby and Python tests are non-vacuous against the current code. All normalizer call sites are response-side only, so the injected system_label never reaches a PUT body. Line references in SPEC.md and the port comments all check out.

Not merging. Findings 1 and 2 both need a decision about scope before code: see my previous comment for the fork on 2, and 1 needs a call on whether the refusal moves, softens, or gets an opt-in reader. Both are with the operator.

jorgemanrubia added a commit that referenced this pull request Sep 16, 2026
…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.
jorgemanrubia added a commit that referenced this pull request Sep 16, 2026
… 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.
jorgemanrubia added a commit that referenced this pull request Sep 16, 2026
…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.
@jorgemanrubia
jorgemanrubia merged commit a5bc3ac into main Sep 16, 2026
55 checks passed
@jorgemanrubia
jorgemanrubia deleted the person-id-grammar branch September 16, 2026 14:02
@jorgemanrubia
jorgemanrubia restored the person-id-grammar branch September 16, 2026 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go kotlin python Pull requests that update the Python SDK ruby Pull requests that update the Ruby SDK rust Rust SDK swift typescript Pull requests that update TypeScript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants