diff --git a/docs/plans/evidence/grpc-data/p01-astra-review.md b/docs/plans/evidence/grpc-data/p01-astra-review.md index e40eb05a6..45553fa9d 100644 --- a/docs/plans/evidence/grpc-data/p01-astra-review.md +++ b/docs/plans/evidence/grpc-data/p01-astra-review.md @@ -1,9 +1,9 @@ # P01 Astra contract-freeze review Date: 2026-11-15 (America/Indiana/Indianapolis) -Scope: initial and corrected frozen P01 Task 2/3 working candidates based on `c3abd468211bf1c8202708447e84df9a2d90bd3f`; the five Core.Abstractions data-connection files, the new protobuf/service registration, mapper and value codec, and the four new test classes. Candidate file digests are recorded in phase runs `20261116T022304.446452Z-4dfc62e5c9c2` and `20261116T023911.320464Z-fa7c2928e3f6`. +Scope: initial and corrected frozen P01 Task 2/3 working candidates based on `c3abd468211bf1c8202708447e84df9a2d90bd3f`; the five Core.Abstractions data-connection files, the new protobuf/service registration, mapper and value codec, and the four new test classes. Final candidate file digests are recorded in phase run `20261116T024814.318745Z-3a06bbb5af5e`; earlier runs are retained below for traceability. -**Disposition after follow-up: revisions required; H2 and M5 remain open, and final green evidence is pending.** H1, H3, M1, M2, and M3 are resolved in the corrected candidate. M4's source correction is sound, with its test-name casing fix awaiting passing evidence. This review does not approve later phases or the completed feature. The reviewer inspected source and existing run evidence only; no build or test was executed, and only this review document was edited. +**Final disposition: approved for P01 contract freeze after correction.** All eight findings are resolved for this checkpoint. The final focused phase gate passed 51 tests with zero failures/skips, and the reviewed source/test digests match that run. Dependent phases may proceed against these contracts. This review does not approve later phases or the completed feature. The reviewer inspected source and existing run evidence only; no build or test was executed, and only this review document was edited. The review uses the [implementation plan](../../2026-11-15-grpc-data-connections-implementation-plan.md), [design](../../2026-11-15-grpc-data-connections-design.md), and preceding design/plan findings. Source line numbers below refer to the reviewed candidate, before corrective edits. @@ -14,21 +14,27 @@ The complete corrected source and tests were reread. The following table superse | Finding | Follow-up assessment | |---|---| | H1 | Resolved: required `DataCapabilities.ClusterId` is encoded/decoded and validated; capability round-trip and empty cluster identity tests cover it. Configured expected-cluster comparison remains a P07 selector obligation. | -| H2 | Partially resolved: receiver-owned `DataDecodeLimits`, aggregate typed-value accounting, collection-count checks, and read/write/metadata response helpers are present. `DecodeMetadata` checks the fixed 16-dimension ceiling before `ToArray`. Remaining gaps and evidence requests are below. | +| H2 | Resolved: receiver-owned `DataDecodeLimits`, aggregate typed-value accounting, collection-count checks, and read/write/metadata response helpers are present. Browse requests now use the same preflight. `DecodeMetadata` checks the fixed 16-dimension ceiling before `ToArray`; final tests cover oversized browse input and valid/oversized/over-rank nested metadata. The accounting and runtime limits of this approval are stated below. | | H3 | Resolved: both compact/fallback value decoders require validated `expectedServing`, compare every sample/batch against it, and check ack-handle stream/epoch consistency. Regression cases cover changed incarnation, fallback node mismatch, and another ack epoch. Runtime control/reset transitions must supply the correctly updated context; they are not implicitly accepted by the codec. | | M1 | Resolved: array element kind is preserved and validated in both directions; positive and malformed array metadata tests passed in the follow-up run. | | M2 | Resolved: framing/write item counts and value-element counts are separate parameters. A positive `MaxValueElements` is advertised with an explicit backward default. One-item/100-element write and compact/fallback cases passed. | | M3 | Resolved: known value kinds/operation bits are intersected, unknown compact version falls back, and major mismatch still rejects. The corresponding capability test passed. | -| M4 | Source correction complete: stable explicit domain values, full existing-field descriptor assertions, service signatures, and hash invariance/change tests are present. The second run failed only because the generated wire enum uses `Uint8` while the test parsed `UInt8` case-sensitively. The reviewed `ignoreCase: true` correction needs successful execution before closing this evidence item. | -| M5 | Partially resolved: identities, ready epochs, samples, settings, negotiated limits, top-level command/frame generations, and lease duration are checked; sub-tick timestamp precision is rejected explicitly. The residual cases below still pass through the decode boundary. | +| M4 | Resolved: stable explicit domain values, full existing-field descriptor assertions, service signatures, and hash invariance/change tests are present. The generated wire enum name-casing fix passed in the final gate. | +| M5 | Resolved: identities, ready epochs, samples, settings, negotiated limits, top-level command/frame generations, and lease duration are checked; sub-tick timestamp precision is rejected explicitly. The final correction also rejects orphan mapping revisions, invalid write identity/preconditions/budget, negative control/watermark fields, and cross-stream removal handles. | -### H2 residual work +### Final H2 assessment and runtime boundary + +The final `DecodeBrowseRequest` accepts receiver-owned limits and runs preflight before returning the domain request. Nested metadata has a fixed graph of view/address/type fields and at most 16 copied dimensions; top-level repeated collections are checked before domain list/array construction. Variable string content is charged through encoded size, per-item domain structure through the fixed allowance, and typed-value/array content through additional aggregate cost. The resulting accounting rule bounds accepted work and retained domain shape for this schema. It is not an exact measurement of managed heap usage, allocation churn, pooled-buffer release, protobuf parser memory, or decompression expansion. P07 must enforce transport/parser/decompression limits, and P04/P06/P11 must verify their actual retained-memory and load budgets. A later schema or representation change must revisit the fixed accounting allowance. + +The final nested-metadata regression accepts the maximum supported rank, rejects an over-rank shape before dimension copying, and rejects a strict receiver budget. Together with the aggregate-write/count tests and the source review of collection entry points, this closes the concrete P01 gaps without claiming the later workload gates have run. + +### Earlier H2 residual request — resolved `DataProtoMapper.DecodeBrowseRequest` still has no receiver limits or preflight, unlike the other operation envelopes (corrected source lines 743–749). An arbitrarily large filter/continuation/view within the transport's separate ceiling can therefore bypass a stricter receiver decode budget. Add the same receiver-owned boundary to this entry point. The generic preflight now estimates decoded cost as `encoded * 2 + count * 256 + 128` plus typed-value cost (lines 25–47). This is meaningfully stronger than the initial code, but its constants and the assumption that nested object graphs fit inside the per-item allowance are not documented or pinned by boundary tests. Do not treat it as a measured heap bound. The fixed dimension check prevents unbounded metadata-dimension copies, but the suite still needs valid maximal-rank metadata nested in browse/metadata-result envelopes, strict-budget/over-count response cases, and an oversized browse request. Establish and document the accounting invariant for nested view/address/metadata/ID/list overhead and test both sides of its rejection threshold. Transport parsing/decompression remains explicitly outside this post-parse accounting. -### M5 residual work +### Earlier M5 residual request — resolved - `DataView.Validate` still permits `MappingId = null` with a positive `MappingRevision`. - `DecodeWriteRequest` still admits empty operation ID/expected serving incarnation and nonpositive catalog revision/remaining budget without structural validation. Validate these before allocating/returning owned values. @@ -37,6 +43,8 @@ The generic preflight now estimates decoded cost as `encoded * 2 + count * 256 + These are transport/domain structure checks. They do not replace P03 authorization or P05 live role/catalog/deadline revalidation. Likewise, `DataView.Subject` remains a caller-supplied claim copied by the mapper. P03 must resolve the authoritative subject from the active catalog and authenticated principal/key, and reject a spoofed claim; no P01 type or codec makes that string authoritative. Carry this explicit negative test into P03. +The final domain correction documents `DataView.Subject` as untrusted. `IDataConnectionFactory` now explicitly creates caller-bound facades from host-established `DataAuthenticatedContext`, which separates principal, public key identity, non-secret credential version, original expiry, and authority epoch. `DataWriteAdmission` also retains the credential version and original expiry. The context/admission tests passed. The factory implementation and P03/P05 policy must enforce these contracts: request payloads cannot create trusted contexts, key replacement cannot relabel an admitted operation or extend its original expiry, and an authoritative subject must come from the active catalog. + ## H1 — Preserve the expected cluster identity through capabilities **Severity: High. Status: resolved in follow-up.** Originally, `CapabilitiesResponse.cluster_id` existed at wire field 10, but `DataCapabilities` had no cluster identity (`DataContracts.cs:113–114`). `DataProtoMapper.EncodeCapabilities` never wrote that field and `DecodeCapabilities` discarded it (`DataProtoMapper.cs:743–803`). `ServingIdentity` supplies node/incarnation, not cluster. Thus the normal domain-to-wire-to-domain capabilities path could not supply the information required to verify `DataTarget.ExpectedClusterId` before node/cluster selection. An identity check added only to raw gRPC messages would also leave the transport-neutral path inconsistent. @@ -45,7 +53,7 @@ These are transport/domain structure checks. They do not replace P03 authorizati ## H2 — Enforce receiver-owned aggregate decode budgets before collection allocation -**Severity: High. Status: open.** `DecodeWriteRequest` checks aggregate encoded size, then independently decodes every value with the entire `maxBytes` allowance (`DataProtoMapper.cs:559–585`). It never sums decoded storage, so several individually small values can collectively exceed the batch's decoded budget. For example, two byte values each accepted by the per-value decoded limit can fit the encoded envelope while their combined copies exceed that limit. +**Severity: High. Status: resolved after final follow-up.** Originally, `DecodeWriteRequest` checked aggregate encoded size, then independently decoded every value with the entire `maxBytes` allowance (`DataProtoMapper.cs:559–585`). It never summed decoded storage, so several individually small values could collectively exceed the batch's decoded budget. For example, two byte values each accepted by the per-value decoded limit could fit the encoded envelope while their combined copies exceeded that limit. Other exposed collection decoders have no receiver-owned count/byte parameters and allocate with `ToArray`/`List` directly: read requests (529–538), metadata requests (617–618), subscription commands (270–308), browse responses (642–659), and control/ack frames (858–901). Payload-supplied `Budget` is validated only for positivity and is not an independent receiver limit. Compact/fallback value-frame accounting covers typed values but does not account for their per-item domain samples/list entries or other decoded frame state. A wire-byte ceiling alone does not establish the decoded resource bound required by P01 and the design. @@ -79,13 +87,13 @@ Other exposed collection decoders have no receiver-owned count/byte parameters a ## M4 — Freeze all wire decisions and compatibility-sensitive descriptors -**Severity: Medium. Status: source corrected; final passing evidence pending.** Originally, most wire decisions were bare `int32` fields populated by casts from implicitly numbered C# enums (`DataContracts.cs:3–8`). Inserting a status/write/control enum member could silently renumber deployed meanings. `DataConnectionProtoContract.Validate` pinned only three field numbers and the zero `ValueKind`; the test added one compact timestamp field. Most field numbers, wire types, oneofs, enum values, operation bits, and service request/response signatures were consequently outside the promised contract lock. +**Severity: Medium. Status: resolved after final follow-up.** Originally, most wire decisions were bare `int32` fields populated by casts from implicitly numbered C# enums (`DataContracts.cs:3–8`). Inserting a status/write/control enum member could silently renumber deployed meanings. `DataConnectionProtoContract.Validate` pinned only three field numbers and the zero `ValueKind`; the test added one compact timestamp field. Most field numbers, wire types, oneofs, enum values, operation bits, and service request/response signatures were consequently outside the promised contract lock. **Correction:** Assign explicit stable values to every wire-visible decision and pin the complete message/service/enum contract with a descriptor snapshot or equivalent comprehensive assertions. Protobuf enums are preferable for self-describing decisions; explicit domain-number assertions are required if `int32` remains deliberate. Reserve removed numbers/names. Keep evolution tests additive: adding fields/capabilities must not authorize renumbering existing ones. Add write-payload-hash tests proving correlation/remaining-budget independence and changes for value/address/semantic preconditions; those critical hash invariants currently have no test despite `WritePayloadHash` being implemented. ## M5 — Define and enforce malformed envelope invariants at decode boundaries -**Severity: Medium. Status: open.** Required enum validation is present in several paths, but the domain constructors/decoders otherwise accept structurally invalid state. Examples include empty node/incarnation and arbitrary epochs from `DecodeServing` (70–74), negative negotiated capacity values from `DecodeCapabilities` (790–800), and command/frame IDs, epochs, timeouts, and sequence values copied without validation. `DecodeSettings` accepts nonfinite deadband values without defining their meaning; `DecodeBrowseResponse` constructs a nonpositive lease without validating it. `DataView.Validate` also permits a positive mapping revision with no mapping ID. These values should not become apparently valid domain envelopes on which later admission and ordering code depends. +**Severity: Medium. Status: resolved after final follow-up.** Originally, required enum validation was present in several paths, but the domain constructors/decoders otherwise accepted structurally invalid state. Examples included empty node/incarnation and arbitrary epochs from `DecodeServing` (70–74), negative negotiated capacity values from `DecodeCapabilities` (790–800), and command/frame IDs, epochs, timeouts, and sequence values copied without validation. `DecodeSettings` accepted nonfinite deadband values without defining their meaning; `DecodeBrowseResponse` constructed a nonpositive lease without validating it. `DataView.Validate` also permitted a positive mapping revision with no mapping ID. These values must not become apparently valid domain envelopes on which later admission and ordering code depends. **Correction:** Define shared structural validation for identities, generations, settings, limits, leases, and required command/frame fields, then invoke it consistently on both mapping paths. Document any deliberately allowed sentinel values such as zero sampling before enforcing them; distinguish such protocol semantics from unsupported policy requests. Reject malformed known decisions and illegal combinations before later services consume them. Add focused negative cases for the examples above and full request/response/command round trips for all six services. Timestamp tests should cover nonzero subsecond precision and establish the policy for protobuf precision finer than the domain's ticks. @@ -93,7 +101,9 @@ Other exposed collection decoders have no receiver-owned count/byte parameters a The completed phase run `20261116T022304.446452Z-4dfc62e5c9c2` records the candidate SHA, tracked diff hash, and per-untracked-file hashes. Core.Abstractions executed 9 tests, all passed, with zero skips; its expected new and existing classes were verified. Commons executed 21 tests: 20 passed, 1 failed, zero skipped. The failure is the array metadata regression above; `run.json` correctly reports the phase as failed. No whole-solution or integration result is inferred. -The follow-up phase run `20261116T023911.320464Z-fa7c2928e3f6` also records the candidate digests and correctly reports failure. Core.Abstractions executed 13 tests, all passed, zero skipped. Commons executed 33 tests: 32 passed, one failed, zero skipped. The only failure was the generated `UInt8`/`Uint8` enum-name casing in the new contract-number test; the new metadata, aggregate-write/count, serving-context, independent-array-limit, capability, timestamp, and hash cases passed. The reviewer inspected `run.json` and the failure log directly. The casing correction was read in source but has no passing result in this review's evidence yet. +The intermediate phase run `20261116T023911.320464Z-fa7c2928e3f6` also records the candidate digests and correctly reports failure. Core.Abstractions executed 13 tests, all passed, zero skipped. Commons executed 33 tests: 32 passed, one failed, zero skipped. The only failure was the generated `UInt8`/`Uint8` enum-name casing in the new contract-number test; the new metadata, aggregate-write/count, serving-context, independent-array-limit, capability, timestamp, and hash cases passed. The reviewer inspected `run.json` and the failure log directly. + +**Final phase evidence:** `20261116T024814.318745Z-3a06bbb5af5e` passed. Core.Abstractions executed 15 tests and Commons executed 36, with zero failures/skips in either project. The runner verified `GrpcDataContractsTests`, `GrpcDataProtoContractTests`, `GrpcDataCodecTests`, `GrpcDataCompactCodecTests` and all required existing selectors (`DataChangeBatchContractTests`, `DeploymentArtifactProtoTests`, `MeshTransportProtoContractTests`, `TelemetryProtoContractTests`). The reviewer inspected `run.json` and compared every recorded new source/test file digest with the final files on disk; all matched. This was evidence inspection, not a reviewer test execution. The initial candidate's new tests cover enum validation examples, explicit write-outcome classification, optional timestamps, copied input bytes, request-start lease timing, handle revisions, scalar/array codec examples, one compact absence override, one stale handle, one mixed compact encoding case, control/ack round trips, and a small golden/unknown-field payload. They do not yet establish the aggregate budgets, complete service envelope mappings, expected serving provenance, operation hash, or additive negotiation required by this checkpoint. @@ -105,4 +115,4 @@ The initial candidate's new tests cover enum validation examples, explicit write - Full unsigned status codes, UInt64 values, null versus empty byte/array values, original optional timestamps, and explicit uncertain/unconfirmed write outcomes are represented. Compact timestamp override messages can express inherited, explicitly absent, and explicitly present values. The compact encoder refuses mixed provenance within a batch, and both decoders reject unknown/removed handle revisions. - The hash implementation omits transport correlation and remaining budget and includes the value/view and incarnation/catalog preconditions. Its missing regression coverage is called out in M4. No automatic retry or transport behavior is introduced by these contract files. -The residual H2/M5 work and final focused green evidence are required before the P01 freeze is approved. Later runtime policy, queue ordering, revocation, ingress authentication, Docker, scaling, and final-suite gates remain outstanding. +No unresolved P01 contract-freeze finding remains. Later runtime policy, queue ordering, revocation, ingress authentication, Docker, scaling, and final-suite gates remain outstanding.