Repository navigation
docs: ADRs 0248-0250 + acceptance plan for the SDK server enablers - #822
Merged
Merged
Conversation
samuv
force-pushed
the
sdk/00-decision-record
branch
from
August 28, 2026 13:50
f7f0647 to
270c9d8
Compare
This was referenced Aug 28, 2026
jhrozek
reviewed
Aug 30, 2026
jhrozek
left a comment
Contributor
There was a problem hiding this comment.
Reviewed the three new ADRs and the acceptance plan against AGENTS.md's invariants and the existing proto/port conventions. Flagging three items here — one blocking (a numbering bug), two worth deciding before implementation starts.
samuv
added a commit
that referenced
this pull request
Aug 31, 2026
Four fixes from the #822 review. THE BLOCKING ONE: the ADR index numbered the three new entries 0243/0244/0245 while linking to files 0244-/0245-/0246-, and its "0243" collided with the already-existing ADR 0243 (local JSONL durability boundaries). The ADR bodies were numbered correctly and cross-referenced each other correctly throughout; only the index was wrong. ADR 0244 decision 7 said gRPC "returns the same string in a status detail" without saying what the detail is. It is now pinned to google.rpc.ErrorInfo, with the two reasons that made it the right carrier: it authors no new proto in contracts/proto (harness.proto is touched by most of the stack, and each extra edit is another conflict surface), and AIP-193's reason+domain+metadata shape is decodable by generic gRPC tooling with no mecatl-specific knowledge. That surfaced a casing decision the ADR was leaving for the parity gate to discover: AIP-193 conventionally spells reason in UPPER_SNAKE_CASE, but AC2.2 requires the IDENTICAL string on both transports. Parity wins, lower_snake_case on both sides, and the departure from the convention is now stated up front rather than found as a test failure by whoever implements the second transport. ADR 0245 decision 1 validated the run id only as colon-free, which moved ADR 0044's CWE-863 replay guard from internally-guaranteed (an atomic r<serial> counter, uniqueness impossible to violate by construction) to caller-trusted. The decision now records what was actually built: 128 bits of crypto/rand at one call site. It also records the alternative that was weighed — a host-supplied label plus a session-minted monotonic counter — and why the random id is stronger: a monotonic counter has to survive restarts and replicas to stay monotonic, which moves the burden onto a persistence scheme that can itself be got wrong, while 128 random bits collide negligibly however the process is restarted or replicated. AC2.4 claimed no problem body carries a secret, but the guard walks only the harness-authored halves (code, title, type). detail/error carry the server's own err.Error(), bounded and UTF-8-repaired but not content-scrubbed. The AC now says that, and says why scrubbing is the wrong control there: it would corrupt the diagnostic without being a real defence, since the obligation belongs with the backend that raises the error and knows which value is sensitive. Gates: docs/lint green; matlatl check --strict green (265 documents, 2320 references, 0 broken). Refs #821. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
samuv
added a commit
that referenced
this pull request
Aug 31, 2026
Three fixes from the #825 review, plus one thing found while making them. STALE COMMENT. toStatus carried a //nolint:gocyclo justifying "a flat error→code classifier; a switch is the correct shape". The 49-case switch it described is gone — the body is now a one-line delegation to classifyError. Dropped. THE CASING CHOICE IS NOW ON THE RECORD AT THE SITE. ErrorInfo.Reason carries the code in lower_snake_case, against AIP-193's UPPER_SNAKE_CASE convention, because AC2.2 requires the identical string on both transports and the HTTP side is lowercase to match RFC 9457 style. That was a deliberate trade with nothing at the code to say so, and a future reader "fixing" the casing would silently reintroduce exactly the divergence #822 raised the concern about. The comment names the trade and points at the parity test that fails if it is undone. A GENERIC NO-SHADOWING GATE. SpecificSentinelsWinOverGeneral protects the one known wrapping pair BY NAME, so any future pair depends on the next author remembering to hand-write another test. TestADR_0244_NoRegistryRowIsShadowed walks the registry itself and asserts every row's own sentinel resolves back to that row, so a mis-ordered pair fails with no test edit. Mutation-verified: swapping the two real rows produces "registry row 25 (failed_step_retry_ineligible) is SHADOWED". It asserts row IDENTITY, and that is the part worth reading twice. The obvious spelling is errors.Is — and errors.Is is VACUOUS here. A specific sentinel wraps the general one, so errors.Is(specific, general) is true, which means an errors.Is assertion holds both when the row resolves correctly and when it has been shadowed by the very row it wraps. It would pass in precisely the case it exists to catch. Only pointer identity separates them. The test carries its own bite check against a deliberately mis-ordered table so it cannot rot into theatre. AC2.4's SCOPE IS NOW TESTED, NOT ASSUMED. The no-secret walk covers code, title, and type — the halves mecatl authors — but the AC claimed "no problem body carries a secret", which reads as covering detail/error too. Those carry the caller's err.Error(), bounded and UTF-8-repaired but not scrubbed. Rather than weaken the test to match the words or strengthen the code to match the claim, the pass-through is now asserted explicitly, with the reason: a denylist over free-text error prose is the same false-positive generator the existing comment describes for titles, and this layer does not know which substring is sensitive — only the backend that raised the error does, which is where today's risky ones already sanitize. A future author adding scrubbing now has to delete an assertion that explains why it was not wanted. (The AC wording itself is narrowed in the plan doc, on the ADR commit.) Gates: go test green on internal/adapter/server; gofmt clean. Refs #821. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
Design record for the Go-side server contracts the TypeScript SDK (#821) is built on. No production code yet — this is the frozen decision record and the verification contract the nine-PR stack is measured against. ADR 0243 — SDK compatibility discovery and the typed error contract. GetServerInfo answers "what is this server?" without a probe session, and keeps `capabilities` (what the operator enabled) separate from `features` (what the build implements): conflating them makes a --no-bash deployment look like version skew. Features and error codes are open strings, not proto enums, so a new one is a minor SDK release rather than a wire-compat event — the discipline the event taxonomy already settled for EvNoProgress/StopBudget. ADR 0244 — Durable run identity. A host-minted, colon-free run id fed into the existing RunRequest.AskIDDiscriminator, whose ADR 0044 contract is already written in terms of a run id ("A durable host passes its own RunID") and which nothing supplies today. Persisted on the snapshot so an awaiting resume is the SAME run; stamped on Event at the relay chokepoint, Actor-style, so the loop stays storage-agnostic. An empty RunID is a meaning — session-scoped, not run-scoped — enforced by a closed set that today holds exactly the three schedule.* types. ADR 0245 — Durable cursors and the watch transport. port.CursorEventLog is additive; the Redis event log moves LIST -> Stream because a LIST cannot express a durable cross-process follow and positional cursors become wrong data the day anyone adds retention. Gap markers are log-record envelope variants surfaced as a delivery phase, never a session.Event, so the event union and kind-parity gate are untouched. The append-gap guarantee is deliberately weaker than #821 asked for: cross-process gap detection is not achievable, and the ADR states the residual rather than shipping an absolute a Redis outage falsifies. The acceptance plan carries 9 scenarios / 60 numbered ACs with verify: proofs, delivered as a linear stack of nine PRs — linear because six units edit harness.proto and five edit http.go, and contracts/gen is committed. Refs #821, #761. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
…s plan llms.txt is generated and goes stale the instant docs change; the CI docs job caught it on this PR. Regenerated with `task docs:llms`. Verified with the strict gate: 264 documents, 2312 references — 0 broken links, 0 broken anchors, 0 ambiguous, 0 orphans, 0 unreachable. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
main landed ADR 0243 (Local JSONL durability boundaries, #786) while this branch was in flight, so both claimed 0243. ADR numbering is monotonic and records are frozen on merge; the landed one keeps the number and the unmerged one moves. docs/lint's TestRealADRNumberUniqueness is the gate that catches this, and it is why the collision surfaced as a test failure rather than as two files quietly sharing an identity. Renumbered highest-first so 0244 -> 0245 could not collide with the 0243 -> 0244 it was about to vacate: 0243 SDK compatibility and error contract -> 0244 0244 Durable run identity -> 0245 0245 Durable cursors and watch -> 0246 Also updates every cross-reference and the acceptance plan's verify: test names (TestADR_0243_* -> TestADR_0244_*, and so on), which ac-trace resolves against the tree. llms.txt regenerated; it conflicted because main regenerated it too. Per AGENTS.md a generated file is never hand-merged — this took main's side and re-ran task docs:llms. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
Corrects decision 4 before the record freezes. The ADR is Status: Proposed
and unmerged, which is exactly the window this kind of finding is supposed
to land in.
Decision 4 said stamp Event.RunID "at the single relay chokepoint,
Actor-style". Contact with the code says there is no such chokepoint:
- Service.relayEvent has 4 callers but takes session.Event BY VALUE, so it
cannot mutate the copy its caller hands to toProto.
- Five further recorder.Observe sites bypass relayEvent entirely (the gRPC
drain-to-discard path, three HTTP paths, schedule.go).
- Actor works only because it is LOG-ONLY: persistence genuinely has one
chokepoint in appendEvent. RunID must also reach the client wire — the
SDK resolves a started run on the first run-ID-bearing event — and the
wire path never passes through appendEvent.
So "stamp at the relay" means stamping at ~9 sites by hand: the per-surface
drift class AGENTS.md records as having already fired three times.
The semantic argument for the Actor precedent does not transfer either.
Actor stays out of the loop because the loop "knows nothing about
principals" — a real domain boundary. A run id is not external metadata: the
run is the loop's own concept, and the loop already labels every event it
emits with run-scoped identity (ev.Seq = r.seq.Add(1)) at exactly the two
sites in question. RunID belongs on the next line.
Decision 2 changes with it: the id now reaches the engine as a new
RunRequest.RunID, and the engine derives the ask discriminator from it when
AskIDDiscriminator is empty. The host still sets ONE field, and ADR 0044's
"a durable host passes its own RunID" is now satisfied literally rather than
by coincidence. AskIDDiscriminator is retained and gains no second writer, so
a future need for a discriminator that is NOT the run id can still set it
explicitly — the derivation is a default, not a constraint.
The cost is recorded honestly in Consequences: engine/agent now carries an
identifier it did not have, and the accepted bound is narrow — the loop may
stamp the id and derive the discriminator from it, and nothing else. It must
never branch on it, log it, send it to a provider, or reach storage with it.
Acceptance plan AC4.2/AC4.3 are updated to match; AC4.3 inverts from "the
loop never stamps RunID" to "every emitted event carries it, stamped at
Run.emit/emitOrAbort".
Refs #821.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Samuele Verzi <[email protected]>
samuv
added a commit
that referenced
this pull request
Aug 31, 2026
Four fixes from the #822 review, plus a renumber forced by main. RENUMBERED 0244-0246 -> 0248-0250. main landed its own 0244 (full request + manual compaction), 0245 (safe build diagnostics), 0246 (goccy YAML parser) while this stack was open, so the SDK ADRs collided with three real records. 0248-0250 are the next free numbers. This is the second time these three have moved; the first was the off-by-one below. THE BLOCKING REVIEW ITEM: the ADR index numbered the three new entries 0243/0244/0245 while linking to files 0244-/0245-/0246-, and its "0243" collided with the already-existing ADR 0243 (local JSONL durability boundaries). The ADR bodies were numbered correctly and cross-referenced each other correctly throughout; only the index was wrong. ADR 0248 (was 0244) decision 7 said gRPC "returns the same string in a status detail" without saying what the detail is. It is now pinned to google.rpc.ErrorInfo, with the two reasons that made it the right carrier: it authors no new proto in contracts/proto (harness.proto is touched by most of the stack, and each extra edit is another conflict surface), and AIP-193's reason+domain+metadata shape is decodable by generic gRPC tooling with no mecatl-specific knowledge. That surfaced a casing decision the ADR was leaving for the parity gate to discover: AIP-193 conventionally spells reason in UPPER_SNAKE_CASE, but AC2.2 requires the IDENTICAL string on both transports. Parity wins, lower_snake_case on both sides, and the departure from the convention is now stated up front rather than found as a test failure by whoever implements the second transport. ADR 0249 (was 0245) decision 1 validated the run id only as colon-free, which moved ADR 0044's CWE-863 replay guard from internally-guaranteed (an atomic r<serial> counter, uniqueness impossible to violate by construction) to caller-trusted. The decision now records what was actually built: 128 bits of crypto/rand at one call site. It also records the alternative that was weighed — a host-supplied label plus a session-minted monotonic counter — and why the random id is stronger: a monotonic counter has to survive restarts and replicas to stay monotonic, which moves the burden onto a persistence scheme that can itself be got wrong, while 128 random bits collide negligibly however the process is restarted or replicated. AC2.4 claimed no problem body carries a secret, but the guard walks only the harness-authored halves (code, title, type). detail/error carry the server's own err.Error(), bounded and UTF-8-repaired but not content-scrubbed. The AC now says that, and says why scrubbing is the wrong control there: it would corrupt the diagnostic without being a real defence, since the obligation belongs with the backend that raises the error and knows which value is sensitive. Gates: docs/lint green (ADR number uniqueness included); matlatl check --strict green (271 documents, 2368 references, 0 broken). Refs #821. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
samuv
force-pushed
the
sdk/00-decision-record
branch
from
August 31, 2026 08:23
0ac7087 to
7f7a5bc
Compare
samuv
added a commit
that referenced
this pull request
Aug 31, 2026
Four fixes from the #822 review, plus a renumber forced by main. RENUMBERED 0244-0246 -> 0248-0250. main landed its own 0244 (full request + manual compaction), 0245 (safe build diagnostics), 0246 (goccy YAML parser) while this stack was open, so the SDK ADRs collided with three real records. 0248-0250 are the next free numbers. This is the second time these three have moved; the first was the off-by-one below. THE BLOCKING REVIEW ITEM: the ADR index numbered the three new entries 0243/0244/0245 while linking to files 0244-/0245-/0246-, and its "0243" collided with the already-existing ADR 0243 (local JSONL durability boundaries). The ADR bodies were numbered correctly and cross-referenced each other correctly throughout; only the index was wrong. ADR 0248 (was 0244) decision 7 said gRPC "returns the same string in a status detail" without saying what the detail is. It is now pinned to google.rpc.ErrorInfo, with the two reasons that made it the right carrier: it authors no new proto in contracts/proto (harness.proto is touched by most of the stack, and each extra edit is another conflict surface), and AIP-193's reason+domain+metadata shape is decodable by generic gRPC tooling with no mecatl-specific knowledge. That surfaced a casing decision the ADR was leaving for the parity gate to discover: AIP-193 conventionally spells reason in UPPER_SNAKE_CASE, but AC2.2 requires the IDENTICAL string on both transports. Parity wins, lower_snake_case on both sides, and the departure from the convention is now stated up front rather than found as a test failure by whoever implements the second transport. ADR 0249 (was 0245) decision 1 validated the run id only as colon-free, which moved ADR 0044's CWE-863 replay guard from internally-guaranteed (an atomic r<serial> counter, uniqueness impossible to violate by construction) to caller-trusted. The decision now records what was actually built: 128 bits of crypto/rand at one call site. It also records the alternative that was weighed — a host-supplied label plus a session-minted monotonic counter — and why the random id is stronger: a monotonic counter has to survive restarts and replicas to stay monotonic, which moves the burden onto a persistence scheme that can itself be got wrong, while 128 random bits collide negligibly however the process is restarted or replicated. AC2.4 claimed no problem body carries a secret, but the guard walks only the harness-authored halves (code, title, type). detail/error carry the server's own err.Error(), bounded and UTF-8-repaired but not content-scrubbed. The AC now says that, and says why scrubbing is the wrong control there: it would corrupt the diagnostic without being a real defence, since the obligation belongs with the backend that raises the error and knows which value is sensitive. Gates: docs/lint green (ADR number uniqueness included); matlatl check --strict green (271 documents, 2368 references, 0 broken). Refs #821. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
samuv
force-pushed
the
sdk/00-decision-record
branch
from
August 31, 2026 08:50
7f7a5bc to
7fe9777
Compare
samuv
added a commit
that referenced
this pull request
Aug 31, 2026
Three fixes from the #825 review, plus one thing found while making them. STALE COMMENT. toStatus carried a //nolint:gocyclo justifying "a flat error→code classifier; a switch is the correct shape". The 49-case switch it described is gone — the body is now a one-line delegation to classifyError. Dropped. THE CASING CHOICE IS NOW ON THE RECORD AT THE SITE. ErrorInfo.Reason carries the code in lower_snake_case, against AIP-193's UPPER_SNAKE_CASE convention, because AC2.2 requires the identical string on both transports and the HTTP side is lowercase to match RFC 9457 style. That was a deliberate trade with nothing at the code to say so, and a future reader "fixing" the casing would silently reintroduce exactly the divergence #822 raised the concern about. The comment names the trade and points at the parity test that fails if it is undone. A GENERIC NO-SHADOWING GATE. SpecificSentinelsWinOverGeneral protects the one known wrapping pair BY NAME, so any future pair depends on the next author remembering to hand-write another test. TestADR_0244_NoRegistryRowIsShadowed walks the registry itself and asserts every row's own sentinel resolves back to that row, so a mis-ordered pair fails with no test edit. Mutation-verified: swapping the two real rows produces "registry row 25 (failed_step_retry_ineligible) is SHADOWED". It asserts row IDENTITY, and that is the part worth reading twice. The obvious spelling is errors.Is — and errors.Is is VACUOUS here. A specific sentinel wraps the general one, so errors.Is(specific, general) is true, which means an errors.Is assertion holds both when the row resolves correctly and when it has been shadowed by the very row it wraps. It would pass in precisely the case it exists to catch. Only pointer identity separates them. The test carries its own bite check against a deliberately mis-ordered table so it cannot rot into theatre. AC2.4's SCOPE IS NOW TESTED, NOT ASSUMED. The no-secret walk covers code, title, and type — the halves mecatl authors — but the AC claimed "no problem body carries a secret", which reads as covering detail/error too. Those carry the caller's err.Error(), bounded and UTF-8-repaired but not scrubbed. Rather than weaken the test to match the words or strengthen the code to match the claim, the pass-through is now asserted explicitly, with the reason: a denylist over free-text error prose is the same false-positive generator the existing comment describes for titles, and this layer does not know which substring is sensitive — only the backend that raised the error does, which is where today's risky ones already sanitize. A future author adding scrubbing now has to delete an assertion that explains why it was not wanted. (The AC wording itself is narrowed in the plan doc, on the ADR commit.) Gates: go test green on internal/adapter/server; gofmt clean. Refs #821. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
Four fixes from the #822 review, plus a renumber forced by main. RENUMBERED 0244-0246 -> 0248-0250. main landed its own 0244 (full request + manual compaction), 0245 (safe build diagnostics), 0246 (goccy YAML parser) while this stack was open, so the SDK ADRs collided with three real records. 0248-0250 are the next free numbers. This is the second time these three have moved; the first was the off-by-one below. THE BLOCKING REVIEW ITEM: the ADR index numbered the three new entries 0243/0244/0245 while linking to files 0244-/0245-/0246-, and its "0243" collided with the already-existing ADR 0243 (local JSONL durability boundaries). The ADR bodies were numbered correctly and cross-referenced each other correctly throughout; only the index was wrong. ADR 0248 (was 0244) decision 7 said gRPC "returns the same string in a status detail" without saying what the detail is. It is now pinned to google.rpc.ErrorInfo, with the two reasons that made it the right carrier: it authors no new proto in contracts/proto (harness.proto is touched by most of the stack, and each extra edit is another conflict surface), and AIP-193's reason+domain+metadata shape is decodable by generic gRPC tooling with no mecatl-specific knowledge. That surfaced a casing decision the ADR was leaving for the parity gate to discover: AIP-193 conventionally spells reason in UPPER_SNAKE_CASE, but AC2.2 requires the IDENTICAL string on both transports. Parity wins, lower_snake_case on both sides, and the departure from the convention is now stated up front rather than found as a test failure by whoever implements the second transport. ADR 0249 (was 0245) decision 1 validated the run id only as colon-free, which moved ADR 0044's CWE-863 replay guard from internally-guaranteed (an atomic r<serial> counter, uniqueness impossible to violate by construction) to caller-trusted. The decision now records what was actually built: 128 bits of crypto/rand at one call site. It also records the alternative that was weighed — a host-supplied label plus a session-minted monotonic counter — and why the random id is stronger: a monotonic counter has to survive restarts and replicas to stay monotonic, which moves the burden onto a persistence scheme that can itself be got wrong, while 128 random bits collide negligibly however the process is restarted or replicated. AC2.4 claimed no problem body carries a secret, but the guard walks only the harness-authored halves (code, title, type). detail/error carry the server's own err.Error(), bounded and UTF-8-repaired but not content-scrubbed. The AC now says that, and says why scrubbing is the wrong control there: it would corrupt the diagnostic without being a real defence, since the obligation belongs with the backend that raises the error and knows which value is sensitive. Gates: docs/lint green (ADR number uniqueness included); matlatl check --strict green (271 documents, 2368 references, 0 broken). Refs #821. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
samuv
force-pushed
the
sdk/00-decision-record
branch
from
August 31, 2026 08:52
7fe9777 to
746c1bf
Compare
samuv
added a commit
that referenced
this pull request
Aug 31, 2026
Three fixes from the #825 review, plus one thing found while making them. STALE COMMENT. toStatus carried a //nolint:gocyclo justifying "a flat error→code classifier; a switch is the correct shape". The 49-case switch it described is gone — the body is now a one-line delegation to classifyError. Dropped. THE CASING CHOICE IS NOW ON THE RECORD AT THE SITE. ErrorInfo.Reason carries the code in lower_snake_case, against AIP-193's UPPER_SNAKE_CASE convention, because AC2.2 requires the identical string on both transports and the HTTP side is lowercase to match RFC 9457 style. That was a deliberate trade with nothing at the code to say so, and a future reader "fixing" the casing would silently reintroduce exactly the divergence #822 raised the concern about. The comment names the trade and points at the parity test that fails if it is undone. A GENERIC NO-SHADOWING GATE. SpecificSentinelsWinOverGeneral protects the one known wrapping pair BY NAME, so any future pair depends on the next author remembering to hand-write another test. TestADR_0244_NoRegistryRowIsShadowed walks the registry itself and asserts every row's own sentinel resolves back to that row, so a mis-ordered pair fails with no test edit. Mutation-verified: swapping the two real rows produces "registry row 25 (failed_step_retry_ineligible) is SHADOWED". It asserts row IDENTITY, and that is the part worth reading twice. The obvious spelling is errors.Is — and errors.Is is VACUOUS here. A specific sentinel wraps the general one, so errors.Is(specific, general) is true, which means an errors.Is assertion holds both when the row resolves correctly and when it has been shadowed by the very row it wraps. It would pass in precisely the case it exists to catch. Only pointer identity separates them. The test carries its own bite check against a deliberately mis-ordered table so it cannot rot into theatre. AC2.4's SCOPE IS NOW TESTED, NOT ASSUMED. The no-secret walk covers code, title, and type — the halves mecatl authors — but the AC claimed "no problem body carries a secret", which reads as covering detail/error too. Those carry the caller's err.Error(), bounded and UTF-8-repaired but not scrubbed. Rather than weaken the test to match the words or strengthen the code to match the claim, the pass-through is now asserted explicitly, with the reason: a denylist over free-text error prose is the same false-positive generator the existing comment describes for titles, and this layer does not know which substring is sensitive — only the backend that raised the error does, which is where today's risky ones already sanitize. A future author adding scrubbing now has to delete an assertion that explains why it was not wanted. (The AC wording itself is narrowed in the plan doc, on the ADR commit.) Gates: go test green on internal/adapter/server; gofmt clean. Refs #821. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
samuv
added a commit
that referenced
this pull request
Aug 31, 2026
Three fixes from the #825 review, plus one thing found while making them. STALE COMMENT. toStatus carried a //nolint:gocyclo justifying "a flat error→code classifier; a switch is the correct shape". The 49-case switch it described is gone — the body is now a one-line delegation to classifyError. Dropped. THE CASING CHOICE IS NOW ON THE RECORD AT THE SITE. ErrorInfo.Reason carries the code in lower_snake_case, against AIP-193's UPPER_SNAKE_CASE convention, because AC2.2 requires the identical string on both transports and the HTTP side is lowercase to match RFC 9457 style. That was a deliberate trade with nothing at the code to say so, and a future reader "fixing" the casing would silently reintroduce exactly the divergence #822 raised the concern about. The comment names the trade and points at the parity test that fails if it is undone. A GENERIC NO-SHADOWING GATE. SpecificSentinelsWinOverGeneral protects the one known wrapping pair BY NAME, so any future pair depends on the next author remembering to hand-write another test. TestADR_0244_NoRegistryRowIsShadowed walks the registry itself and asserts every row's own sentinel resolves back to that row, so a mis-ordered pair fails with no test edit. Mutation-verified: swapping the two real rows produces "registry row 25 (failed_step_retry_ineligible) is SHADOWED". It asserts row IDENTITY, and that is the part worth reading twice. The obvious spelling is errors.Is — and errors.Is is VACUOUS here. A specific sentinel wraps the general one, so errors.Is(specific, general) is true, which means an errors.Is assertion holds both when the row resolves correctly and when it has been shadowed by the very row it wraps. It would pass in precisely the case it exists to catch. Only pointer identity separates them. The test carries its own bite check against a deliberately mis-ordered table so it cannot rot into theatre. AC2.4's SCOPE IS NOW TESTED, NOT ASSUMED. The no-secret walk covers code, title, and type — the halves mecatl authors — but the AC claimed "no problem body carries a secret", which reads as covering detail/error too. Those carry the caller's err.Error(), bounded and UTF-8-repaired but not scrubbed. Rather than weaken the test to match the words or strengthen the code to match the claim, the pass-through is now asserted explicitly, with the reason: a denylist over free-text error prose is the same false-positive generator the existing comment describes for titles, and this layer does not know which substring is sensitive — only the backend that raised the error does, which is where today's risky ones already sanitize. A future author adding scrubbing now has to delete an assertion that explains why it was not wanted. (The AC wording itself is narrowed in the plan doc, on the ADR commit.) Gates: go test green on internal/adapter/server; gofmt clean. Refs #821. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
samuv
added a commit
that referenced
this pull request
Aug 31, 2026
Three fixes from the #825 review, plus one thing found while making them. STALE COMMENT. toStatus carried a //nolint:gocyclo justifying "a flat error→code classifier; a switch is the correct shape". The 49-case switch it described is gone — the body is now a one-line delegation to classifyError. Dropped. THE CASING CHOICE IS NOW ON THE RECORD AT THE SITE. ErrorInfo.Reason carries the code in lower_snake_case, against AIP-193's UPPER_SNAKE_CASE convention, because AC2.2 requires the identical string on both transports and the HTTP side is lowercase to match RFC 9457 style. That was a deliberate trade with nothing at the code to say so, and a future reader "fixing" the casing would silently reintroduce exactly the divergence #822 raised the concern about. The comment names the trade and points at the parity test that fails if it is undone. A GENERIC NO-SHADOWING GATE. SpecificSentinelsWinOverGeneral protects the one known wrapping pair BY NAME, so any future pair depends on the next author remembering to hand-write another test. TestADR_0244_NoRegistryRowIsShadowed walks the registry itself and asserts every row's own sentinel resolves back to that row, so a mis-ordered pair fails with no test edit. Mutation-verified: swapping the two real rows produces "registry row 25 (failed_step_retry_ineligible) is SHADOWED". It asserts row IDENTITY, and that is the part worth reading twice. The obvious spelling is errors.Is — and errors.Is is VACUOUS here. A specific sentinel wraps the general one, so errors.Is(specific, general) is true, which means an errors.Is assertion holds both when the row resolves correctly and when it has been shadowed by the very row it wraps. It would pass in precisely the case it exists to catch. Only pointer identity separates them. The test carries its own bite check against a deliberately mis-ordered table so it cannot rot into theatre. AC2.4's SCOPE IS NOW TESTED, NOT ASSUMED. The no-secret walk covers code, title, and type — the halves mecatl authors — but the AC claimed "no problem body carries a secret", which reads as covering detail/error too. Those carry the caller's err.Error(), bounded and UTF-8-repaired but not scrubbed. Rather than weaken the test to match the words or strengthen the code to match the claim, the pass-through is now asserted explicitly, with the reason: a denylist over free-text error prose is the same false-positive generator the existing comment describes for titles, and this layer does not know which substring is sensitive — only the backend that raised the error does, which is where today's risky ones already sanitize. A future author adding scrubbing now has to delete an assertion that explains why it was not wanted. (The AC wording itself is narrowed in the plan doc, on the ADR commit.) Gates: go test green on internal/adapter/server; gofmt clean. Refs #821. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Samuele Verzi <[email protected]>
samuv
added a commit
that referenced
this pull request
Aug 31, 2026
…ry (#825) * feat(server): RFC 9457 problem details and a stable error-code registry PR 2 of the #821 server-enabler stack. Implements Scenario 2 of docs/acceptance/sdk-server-enablers.md (AC2.1-AC2.6) per ADR 0243. HTTP errors were untyped prose: one writeError emitting {"error": "<msg>"}. A client could read a status and a human string but could not branch on a stable machine identifier. gRPC callers got a codes.Code, which is far coarser than the domain — a dozen distinct conditions collapse onto FailedPrecondition — so the two transports disagreed about what went wrong. That is fatal for an SDK whose premise is one normalized error surface. The structural change is collapsing TWO hand-maintained classifiers into one registry. toStatus (grpc.go) and writeServiceError (http.go) were 49-case errors.Is chains that had to agree by discipline alone. They did agree — I verified all 45 shared sentinels before touching them — but nothing enforced it, and a sentinel added to one and forgotten in the other would silently report a different class per transport. Both are now one-line registry lookups. ORDER IS LOAD-BEARING and the registry is a SLICE, not a map: sentinels wrap other sentinels (ErrFailedStepRetryIneligible wraps ErrFailedPrecondition), so errors.Is matches both and the specific row must come first. A map would randomise iteration and silently reclassify. Pinned by TestSDKServerEnablers_Scenario2_SpecificSentinelsWinOverGeneral. The behaviour-preservation proof is a golden table extracted mechanically from the PRE-refactor source, not retyped. It earned its place immediately: the first mechanical extraction silently dropped four port.*-qualified cases (ErrSessionMetadataCursorRestart, ErrSessionMetadataPagingUnsupported, ErrScheduleNotFound, ErrScheduleUnsupported) because the pattern only matched unqualified Err* identifiers. The compiler caught that one; the table is what catches the next. Codes are open strings, not a proto enum — same discipline as `features` in PR 1. RFC 9457 `type` is a URN (urn:mecatl:error:<code>) rather than an https:// URL, because publishing a URL we do not serve is worse documentation than one that never claimed to be fetchable; the bare code also travels in a `code` extension so clients branch on a string, not a URI parse. gRPC carries the same identifier as a google.rpc.ErrorInfo detail (Reason=code, Domain=mecatl.stacklok.com). Attaching it is best-effort: a marshal failure degrades to the bare status rather than losing the error. `detail` is UTF-8-repaired and bounded to 2048 bytes, cutting on a rune boundary — a truncated multi-byte rune is itself invalid UTF-8, re-creating the marshal-killing fault the repair exists to prevent. The `error` compatibility key carries the same repaired text, so old and new clients never see different messages. AC2.4's no-secret guard checks the two halves DIFFERENTLY on purpose. `code` is a machine vocabulary we author, so a bare-word denylist is exact there. `title` is English prose, and a word denylist on prose is a false-positive generator — the first run failed on "Management authorization required", which leaks nothing. The title half therefore checks value SHAPES (bearer forms, key=value, unbroken opaque runs), and the matcher itself is tested against both leaks it must catch and prose it must not, so it cannot be quietly defanged. Blast radius: only ERROR bodies moved to application/problem+json; success responses stay application/json (pinned). There are no in-repo non-test HTTP consumers — mecatui is a gRPC client. Gates: task lint 0 issues across all modules; Scenario 2 tests green. go.mod: genproto/googleapis/rpc promoted indirect -> direct (no version change) for errdetails. Refs #821. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Samuele Verzi <[email protected]> * test(server): close the review gaps on the error-code registry Three fixes from the #825 review, plus one thing found while making them. STALE COMMENT. toStatus carried a //nolint:gocyclo justifying "a flat error→code classifier; a switch is the correct shape". The 49-case switch it described is gone — the body is now a one-line delegation to classifyError. Dropped. THE CASING CHOICE IS NOW ON THE RECORD AT THE SITE. ErrorInfo.Reason carries the code in lower_snake_case, against AIP-193's UPPER_SNAKE_CASE convention, because AC2.2 requires the identical string on both transports and the HTTP side is lowercase to match RFC 9457 style. That was a deliberate trade with nothing at the code to say so, and a future reader "fixing" the casing would silently reintroduce exactly the divergence #822 raised the concern about. The comment names the trade and points at the parity test that fails if it is undone. A GENERIC NO-SHADOWING GATE. SpecificSentinelsWinOverGeneral protects the one known wrapping pair BY NAME, so any future pair depends on the next author remembering to hand-write another test. TestADR_0244_NoRegistryRowIsShadowed walks the registry itself and asserts every row's own sentinel resolves back to that row, so a mis-ordered pair fails with no test edit. Mutation-verified: swapping the two real rows produces "registry row 25 (failed_step_retry_ineligible) is SHADOWED". It asserts row IDENTITY, and that is the part worth reading twice. The obvious spelling is errors.Is — and errors.Is is VACUOUS here. A specific sentinel wraps the general one, so errors.Is(specific, general) is true, which means an errors.Is assertion holds both when the row resolves correctly and when it has been shadowed by the very row it wraps. It would pass in precisely the case it exists to catch. Only pointer identity separates them. The test carries its own bite check against a deliberately mis-ordered table so it cannot rot into theatre. AC2.4's SCOPE IS NOW TESTED, NOT ASSUMED. The no-secret walk covers code, title, and type — the halves mecatl authors — but the AC claimed "no problem body carries a secret", which reads as covering detail/error too. Those carry the caller's err.Error(), bounded and UTF-8-repaired but not scrubbed. Rather than weaken the test to match the words or strengthen the code to match the claim, the pass-through is now asserted explicitly, with the reason: a denylist over free-text error prose is the same false-positive generator the existing comment describes for titles, and this layer does not know which substring is sensitive — only the backend that raised the error does, which is where today's risky ones already sanitize. A future author adding scrubbing now has to delete an assertion that explains why it was not wanted. (The AC wording itself is narrowed in the plan doc, on the ADR commit.) Gates: go test green on internal/adapter/server; gofmt clean. Refs #821. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Signed-off-by: Samuele Verzi <[email protected]> --------- Signed-off-by: Samuele Verzi <[email protected]>
This was referenced Aug 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The frozen decision record and verification contract for the Go-side server enablers that the TypeScript SDK (#821) is built on. Docs only — no production code. The nine implementation PRs stack on top of this one.
Three ADRs and one acceptance plan (9 scenarios / 60 numbered ACs with
verify:proofs).Changed since review
ADRs renumbered 0244–0246 → 0248–0250.
mainlanded its own 0244 (full request + manual compaction), 0245 (safe build diagnostics), and 0246 (goccy YAML parser) while this stack was open, so the SDK three collided with real records. Second move for these — the first was the off-by-one @jhrozek caught in the index.Review fixes:
0244-/0245-/0246-, and the "0243" collided with the existing ADR 0243 (JSONL durability). The bodies were correct throughout; only the index was wrong.google.rpc.ErrorInfoand makes thelower_snake_case-over-AIP-193 casing decision explicit, rather than leaving it for the parity gate to discover.crypto/randminting that shipped, plus the alternative that was weighed (host label + session-minted counter) and why the random id won.detail/errorstay unscrubbed.One decision the ADRs now record that the review didn't ask for: ADR 0248 originally proposed the RPC name
GetServerInfo.main's ADR 0245 took that name for build identity behind a privacy boundary forbidding capabilities and configuration in the response, so Scenario 1 is nowGetCompatibilityInfo/GET /v1/compatibility, andbuild_versionis dropped in favour of 0245'sbuild_id. Rationale is in ADR 0248 decision 1 and on #823.Why this is a separate PR
#821 spans four milestones and mutates the proto contract, the engine public API, the HTTP error contract, and the daemon lifecycle surface. Splitting by contract surface rather than by milestone puts every invariant risk on the Go side first — where
task api:check, the layering DAG, the conformance suites, anddocs/lintactually have teeth — and lets the SDK be written against a merged, proven server.These nine decisions get frozen on merge, so they deserve a review of their own rather than being buried inside a code PR.
The decisions
ADR 0248 — compatibility discovery and the typed error contract.
GetCompatibilityInfoanswers "what may I do with this server?" without a probe session. It keepscapabilities(what the operator enabled) separate fromfeatures(what the build implements) — conflating them makes a--no-bashdeployment look like version skew. Features and error codes are open strings, not proto enums, so adding one is a minor SDK release rather than a wire-compat event: the discipline the event taxonomy already settled forEvNoProgress/StopBudget.ADR 0249 — durable run identity. A host-minted, colon-free
run_idfed into the existingRunRequest.AskIDDiscriminator, whose ADR 0044 contract is already written in terms of a run id — "A durable host (e.g. a downstream consumer) passes its own RunID" — and which nothing ininternal/orcmd/supplies today. It's persisted on the snapshot so an awaiting resume is genuinely the same run, and stamped onEventat the relay chokepointActor-style, so the loop stays storage-agnostic.An empty
RunIDis a meaning — session-scoped, not run-scoped — enforced by a closed set that today holds exactly the threeschedule.*types, whichappendEventreceives from the scheduler outside any loop. This is whyattach()andactivity()must be separate operations.ADR 0250 — durable cursors and the watch transport.
port.CursorEventLogis additive;port.EventLogis untouched. The Redis event log moves LIST → Stream: a LIST cannot express a durable cross-process follow, and positional cursors become wrong data the day anyone adds retention. Gap markers are log-record envelope variants surfaced as a deliveryphase, never asession.Event— so the event union and the kind-parity gate are untouched.ActivityGapError". Cross-process, that isn't achievable: a failed append consumes no position, so it leaves nothing for a watcher on another replica to observe. The ADR states the three-tier reality (best-effort durable gap marker / guaranteed process-local termination / stated undetectable residual) rather than an absolute a Redis outage falsifies. #821 explicitly asks for this: "stop and tighten the ADR wording rather than shipping a false guarantee."Delivery shape
A linear stack of nine PRs — linear because six of the nine units edit
contracts/proto/mecatl/v1/harness.proto, five editinternal/adapter/server/http.go, andcontracts/gen/is committed generated output. Parallel branches would churn the same generated files; a stack serializes those edits for free. Only two real dependencies exist (Scenario 4 → 5, Scenarios 4+6 → 7); the rest of the ordering is contention management.GetCompatibilityInfo+ feature registry +--deployment-idrun_idexpected_run_id+ strict steerport.CursorEventLog+ four backends + Redis migrationWatchSessionEventsmcp_serversTwo things reviewers should push on
v2.38.0implementsXADD/XLEN/XRANGE/XREADincluding the blocking path, so offline conformance covers it.mcp_serversis listener-scoped and server-enforced (ADR 0248 / Scenario 9), not the SDK-side check Prototype @stacklok/mecatl-sdk TypeScript SDK #821 specifies.mcp.ValidateClientURLis a scheme allowlist that permitshttp://127.0.0.1:*— correct for ACP, whose client is local, but on a network-exposed API a client-side check isn't enforcement. Scoping it to the UDS listener (per ADR 0237) puts the boundary where it can't be bypassed.Verification
go test ./docs/lint/...— green. It caught one real defect (a citation that wasn't repo-root-relative), now fixed.task testis unaffected.docs/lintgreen (ADR number uniqueness included) andmatlatl check . --strictgreen — 271 documents, 2369 references, 0 broken.llms.txtregenerated. Notetask docs:llms's> llms.txtredirect truncates the file beforego runfails, so a failed invocation silently empties it — worth knowing independently of this PR.Refs #821, #761.
🤖 Generated with Claude Code