10 KiB
P06 Astra contract checkpoint
Disposition: approve the minimal contract direction below, subject to the required semantics and tests. This is not implementation or P06 phase approval. This read-only checkpoint inspected Tasks 13/14, the approved design, the subscription/domain/protobuf contracts, snapshot cursor behavior and the existing driver desired-subscription boundary at baseline 70f50201e plus active P05 work. No source was changed and no build/tests were run. Actor changes must remain serialized after the P05 owner finishes.
1. Preserve acquisition age without inventing network freshness
SnapshotItem currently retains a sample/version but not its source's monotonic received timestamp. DataSubscriptionValue, ValueUpdate and CompactUpdate currently carry no acquisition age or readiness. Required additions:
- Capture the actual existing
SourceState.Receivedwith the immutable snapshot item under the same partition capture lock. Retained snapshots, status-only changes, role/header overlays and reconnects must not replace it with snapshot/send/receive time. The timestamp remains process-local; never serialize an absolute monotonic counter. - Add per-update optional
origin_age_ticksand presence-bearing readiness to both fallback and compact forms, using new field numbers. Compute the elapsed origin age from the retained acquisition timestamp as late as practical at encoding/emission. A delayed encoded age is still a lower bound, never an exact receiver age. Preserve independently absent original source/server wall timestamps; do not infer age from them. - Decode age with explicit uncertainty. A small domain
DataAgeBoundsvalue with nullable lower and upper durations is sufficient: absent age means unknown, not zero; a supplied nonnegative origin age gives a lower bound at receipt and no finite stream upper bound. Accumulate receiver-local monotonic elapsed time afterward. Validate negative values, overflow and inconsistent bounds. Age zero is valid only when explicitly present. An absent readiness field must not silently become Ready; negotiate support or expose unknown/unavailable readiness while preserving original sample quality separately. - A receiver may certify a finite maximum-age requirement only from a known upper bound.
lower > maximumproves stale;lower <= maximumwith unknown upper proves neither fresh nor stale. Origin readiness, transport liveness and freshness are separate facts. A fresh authorized snapshot does not imply newly acquired device data.
Decision: additive wire age/readiness plus explicit domain age bounds/unknown freshness is sufficient for the current design. No stream probe/control extension is required now. Do not expose a plain lower-bound TimeSpan as though it were an exact age. A unary response can conservatively bound age above by its origin age plus elapsed time since that request began, provided the origin age was sampled within that causal request/response window. An unsolicited stream frame has no such finite upper bound. A later correlated probe may establish one only when its response is demonstrably ordered with the relevant sample/version; a heartbeat or metadata renewal alone cannot do so. Do not assume a finite one-way network delay or synchronized wall clocks.
Add codec parity/absence/invalid-duration tests and fake-time tests for a stalled snapshot, queued encoding, reconnect and status-only updates. Verify that absent wall timestamps do not prevent correct monotonic age, and that unknown stream freshness never satisfies a finite maximum-age predicate.
2. Commit delivery state at the actual adapter boundary
ReadAllAsync yielding a frame is not evidence of successful socket write. Use one serialized internal delivery sink/receipt boundary per stream. A prepared delivery owns bounded retained samples, authorization/publication gates, item/stream revisions and the expected committed baseline. The P07 transport adapter must await its actual WriteAsync; only successful completion acknowledges that delivery and commits the baseline/cursor. Failure, cancellation or ambiguous completion leaves no delivered baseline and resets/closes that epoch. This is transport acceptance, not a claim that the remote application consumed bytes.
The final authority/lease/revision check precedes handing bytes to the transport. Do not hold an actor/partition lock or a shared authority mutation lock through a potentially stalled socket write. Bytes already handed to the transport cannot be recalled; queued unsent payloads remain subject to the final gate. Removal acknowledgment is emitted only after earlier in-flight delivery is settled and every queued old-revision segment is canceled or rejected, so no old revision follows the acknowledgment.
Define the direct in-process adapter separately: enforce one consumer and choose an explicit successful bounded handoff/acceptance point. Commit there, or expose an acceptance receipt. Do not route the network adapter through an API that auto-commits merely on enumeration. Requesting the next item or disposing a frame must not accidentally stand in for an unobserved network result.
SnapshotLease.TryReadDelta currently mutates _versions and _positions before downstream delivery. P06 must replace or wrap that use with prepare/commit semantics. Keep last considered version, pending retained candidate and last successfully delivered baseline separate. Filtering/coalescing may advance considered work without claiming delivery; a failed candidate cannot advance the committed baseline or conceal a snapshot catch-up gap. Re-evaluate a candidate if its expected baseline changed while encoding. A receipt must be idempotent and scoped to the exact stream epoch/item revision so a late completion cannot commit into a replacement.
3. Use bounded session expiry and existing Open semantics
OpenSubscription.SessionLifetime already exists. Require a positive finite admitted duration, capped by server limits and current credential/authority lifetime. Expiry is measured monotonically and enforced even on a quiet control-only stream. At expiry, reject further commands/delivery, release demand and leases, and require a new Open/new stream epoch and snapshot. In v1, renewal can mean replacement with a newly authenticated Open; do not silently invent a renewal command or extend expiry on ordinary values/heartbeats.
If a requested duration cannot be admitted, reject it or report the effective duration explicitly; do not silently promise the requested lifetime while using an undisclosed revision. A duration is an upper lifetime limit, not a guarantee against earlier credential revocation. Separate command acknowledgment deadlines from session lifetime. An acknowledgment timeout after admission has an uncertain outcome and requires reconciliation through a fresh epoch/snapshot, not a fabricated rejection.
4. Acknowledge actual upstream demand, not mux interest
The current DriverHost sends a complete reference set with one publishing interval, and DriverInstance stores it then self-sends Subscribe. SubscriptionEstablished currently reports only diagnostic ID/reference count and is swallowed on ordinary self-resubscription; it proves neither a requested demand revision nor an effective sampling cadence. DependencyMux interest changes do not configure physical acquisition.
Required implementation boundary:
- Maintain a versioned demand registry merged with the existing legacy references/alarm behavior. Removing the final gRPC consumer must never remove a legacy interest. Preserve principal, export, target-mode/pinned-node, consistency and serving-generation isolation in sharing keys; shared physical samples do not share authorization.
- Carry a desired revision and current producer incarnation to the actual driver subscription operation; return an acknowledged applied revision with effective supported settings or a rejection. Ignore late acknowledgment from a superseded desired revision/producer. Completion of the current driver's real Subscribe operation is a minimum requirement; do not claim arbitrary sampling/filter support merely because the generic method accepted an interval argument.
- Compute the fastest admitted cadence and union of required triggers, with no upstream value deadband by default. Keep sampling and downstream publishing distinct. The current single driver-level interval may force a common faster cadence; revise/reject unsupported per-item demands honestly. An adapter whose physical cadence cannot change must report its known supported behavior instead of inventing acknowledgment.
- A stronger add/modify remains pending until the actual origin establishment is acknowledged. Then take the registration/snapshot/version boundary and emit revised settings plus acknowledgment in order. Failure or timeout releases the tentative interest and does not send a success snapshot. Only safe relaxation may debounce; churn must coalesce bounded desired revisions without losing the latest stronger request.
- Atomically install partition interest and capture its immutable state/watermark under the same owner boundary. Updates between physical acknowledgment and snapshot capture must be represented by the snapshot or later dirty generation. Multi-partition capture remains a vector, with bounded catch-up/reset; it does not imply cross-item atomicity. Keep steady interest ownership distinct from the finite snapshot payload lease so disposing sent snapshot chunks does not silently remove demand or lose the catch-up boundary.
Essential regressions are actual driver acknowledgment/revision ordering; faster-demand failure and revised settings; legacy-plus-gRPC union and last-interest removal; quiet source/revocation/expiry; source changes during registration/capture; old prepared candidate versus changed baseline; failed/ambiguous writer; remove acknowledgment versus a blocked prior send; and bounded snapshot cancellation/reconnect pressure. Existing fake hub or mux registration tests alone cannot prove physical cadence.
These contracts permit P06 implementation to proceed without adding an unneeded network freshness probe. The implementation checkpoint must still demonstrate the acknowledged origin boundary, actual writer receipt and bounded resource ownership before P06 approval.