Skip to content

feat(agent): bridge profile reconciliation to exact requester - #2214

Merged
Jurij89 merged 11 commits into
integration/2052-system-record-syncfrom
feat/2052-agent-profile-transport
Aug 10, 2026
Merged

feat(agent): bridge profile reconciliation to exact requester#2214
Jurij89 merged 11 commits into
integration/2052-system-record-syncfrom
feat/2052-agent-profile-transport

Conversation

@Jurij89

@Jurij89 Jurij89 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add a default-unused transport adapter that lets the bounded agent-profile reconciler resolve exact inventory and active-record closure artifacts through the requester introduced by feat(agent): add bounded exact record requester #2209.
  • Enforce one physical-slice envelope across provider failover: at most 12 remote requests, 2 MiB total request-plus-response bytes, the caller's at-most-three-second monotonic deadline, and one active nonqueued slice.
  • Continue a valid large authority closure across physical slices without raising those bounds. Requester leases transfer into one bounded logical row continuation, retained hits cost zero remote requests, and all retained payload/control ownership is released on every terminal path.
  • Preserve fail-closed verification across continuation. Only the built-in pure signature verifier is memoized; injected mutable authority and publication/seal verification rerun on every resumed physical preparation.
  • Keep dispatch cancellation-safe with an explicit prepareDispatch() boundary followed by one unraced dispatch() physical settlement. Freshness is resampled and clamped to the admitted monotonic deadline before the point of no return.
  • Preserve direct receiver/reconciler compatibility while confining exact lookup, provider selection, accounting, negative memoization, and lease transfer to the transport path.
  • Preserve Core's legacy validation traversal behavior, including exact thrown abort identity, while exposing bounded row-producing continuation state. Core remains authoritative for legal ambiguous root classification and exact child-kind validation.
  • Add no protocol, worker, timer, retry queue, lifecycle hook, configuration flag, or production activation. Activation and live-network validation remain later slices in the Reconnect-triggered background sync amplification can starve foreground catch-up #2052 plan.

Related

Diagrams

Large closure continuation

Before:

sequenceDiagram
    participant R as Reconciler
    participant T as Transport
    participant Q as Exact requester
    participant V as Receiver
    R->>T: Open physical slice
    V->>T: Resolve closure from artifact 1
    T->>Q: Up to 12 exact requests
    Q-->>T: Requester leases
    T-->>R: Slice capacity pause
    R->>T: Release slice and leases
    R->>T: Open next physical slice
    V->>T: Restart closure from artifact 1
Loading

After:

sequenceDiagram
    participant R as Reconciler
    participant T as Transport
    participant Q as Exact requester
    participant V as Receiver
    R->>T: Open physical slice
    V->>T: Resolve closure artifacts
    T->>Q: Up to 12 exact requests
    Q-->>T: Transfer owned leases
    T-->>R: Typed capacity pause; retain bounded continuation
    R->>T: Open next physical slice
    V->>T: Replay closure; rerun mutable verification
    T-->>V: Retained hits with zero remote cost
    T->>Q: Fetch only missing artifacts
    R->>V: prepareDispatch with admitted deadline
    R->>V: dispatch and await physical settlement
    R->>T: Complete or abort; release ownership once
Loading

Provider-scoped negative handling

Before:

sequenceDiagram
    participant R as Reconciler
    participant T as Transport
    participant A as Provider A
    participant B as Provider B
    R->>T: Resolve digest
    T->>A: Unbounded or noncanonical lookup path
    A-->>T: Missing or invalid
    T-->>R: Resolution fails
Loading

After:

sequenceDiagram
    participant R as Reconciler
    participant T as Transport
    participant A as Provider A
    participant B as Provider B
    R->>T: Resolve canonical exact coordinates
    T->>A: Exact request
    A-->>T: Timeout, absence, or invalid response
    T->>T: Memoize provider plus exact identity and outcome
    T->>T: Skip memo hits without request cost
    T->>B: Try next provider within slice budget
    B-->>T: Verified requester lease
    T-->>R: Exact artifact
Loading

Files changed

File What
packages/agent/src/system-records/reconcile-transport-v1.ts Adds the nonqueued requester bridge, physical bounds, provider failover, exact negative memoization, transferred-lease continuation, control accounting, and deterministic teardown.
packages/agent/src/system-records/reconcile-v1.ts Routes admitted transport slices, retains logical row preparation only across retryable pauses, preserves direct mode, and protects the dispatch settlement boundary.
packages/agent/src/system-records/receiver-v1.ts Adds bounded resumable preparation, mutable-verifier replay, freshness/deadline clamping, and two-stage dispatch.
packages/agent/test/support/agent-profile-reconcile-closure-v1-fixture.ts Builds the maximum realistic multi-authority active closure fixture.
packages/agent/test/support/agent-profile-reconcile-v1-fixture.ts Shares direct and transport reconciler fixtures.
packages/agent/test/system-record-reconcile-closure-continuation-v1.test.ts Proves 12 + 12 + 7 request continuation, no refetch, verifier replay, time resampling, byte caps, and ownership release.
packages/agent/test/system-record-reconcile-transport-integration-v1.test.ts Covers admitted routing, aggregate accounting, retryable pauses, terminal cleanup, and continuation caps.
packages/agent/test/system-record-reconcile-transport-v1.test.ts Covers failover, exact memo semantics, request/exchange accounting, lease validation, capacity, cancellation, and close races.
packages/agent/test/system-record-reconcile-v1.test.ts Covers reconciler progression, aggregate continuation accounting, and lifecycle behavior.
packages/agent/test/system-record-reconcile-public-api.typecheck.ts Pins the legacy direct reconciler and receiver contracts.
packages/agent/vitest.unit.config.ts Collects the new adapter coverage in the Agent unit lane.
packages/core/src/system-record-inventory-traversal-v1-internal.ts Adds bounded row-producing traversal while preserving the legacy throwing facade and exact failure identity.
packages/core/src/system-record-limits-v1.ts Freezes the shared negative-memo envelope.
packages/core/test/system-record-inventory-v1.test.ts Covers bounded continuation, ambiguous roots, and exact legacy failure identity.
packages/core/test/system-record-limits-v1.test.ts Pins the shared limits.
packages/core/test/system-record-package-export-v1.mjs Pins the Core runtime export surface.

Test plan

  • Run the eight PR-focused Agent suites, including the boundary suite: 175/175 passed.
  • Run pnpm --filter @origintrail-official/dkg-agent build: TypeScript, public type tests, and package-root checks passed.
  • Run the focused Core inventory suite after the final review fixes: 27 passed, 1 intentional skip.
  • Run the focused Core System Record lane: 104 passed, 2 skipped.
  • Run the Core baseline lane: 1,700 passed.
  • Run the Core export check: 272 exact exports.
  • Run the full Agent suite as a diagnostic: 3,923 passed and 183 skipped. The run lacked /tmp/dkg-hardhat-ctx-9547.json, causing the pre-existing Hardhat-dependent suites to fail; it also exposed the ambiguous-root rebase conflict, which was corrected and rerun successfully above.
  • Run an independent exact-head audit after the final review fixes: 95/95 focused tests passed; no blocker or high-severity findings.
  • Run git diff --check and verify a clean worktree with no generated deployment churn.
  • Lifecycle/config activation and live-network validation remain intentionally deferred to later default-off/cutover slices in the Reconnect-triggered background sync amplification can starve foreground catch-up #2052 plan.

Comment thread packages/agent/src/system-records/reconcile-transport-v1.ts Outdated
Comment thread packages/agent/src/system-records/receiver-v1.ts Outdated
Comment thread packages/agent/src/system-records/reconcile-transport-v1.ts
Comment thread packages/agent/src/system-records/reconcile-transport-v1.ts Outdated
Comment thread packages/agent/src/system-records/reconcile-transport-v1.ts
Comment thread packages/agent/src/system-records/reconcile-v1.ts Outdated
Comment thread packages/agent/src/system-records/reconcile-v1.ts Outdated
Comment thread packages/agent/src/system-records/reconcile-v1.ts
Comment thread packages/agent/src/system-records/receiver-v1.ts Outdated
Comment thread packages/agent/src/system-records/reconcile-transport-v1.ts
Comment thread packages/agent/test/system-record-reconcile-v1.test.ts Outdated
Comment thread packages/agent/vitest.unit.config.ts
@Jurij89

Jurij89 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Exact-head review requested for 91fc8b698: both fresh correctness findings are fixed with focused regressions, the continuation and integration suites are wired into the unit lane, and the oversized reconciler test is split. Local validation is 193/193 System Record tests plus the Agent package build; deferred structural items are tracked in #2216. Please review the current head; no merge action is requested.

Comment thread packages/agent/src/system-records/reconcile-v1.ts
Comment thread packages/agent/src/system-records/reconcile-transport-v1.ts
@Jurij89

Jurij89 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Exact-head review requested for 0d8fef1. The aggregate wire-accounting blocker is fixed with request-plus-response bounds and independent artifact caps; a reconciler-level invalid-response regression proves terminal retained-state cleanup. Local validation is 196/196 Agent System Record tests, 8/8 unit-lane continuation/integration tests, and a clean Agent package build. Structural observations are explicitly tracked in #2216. Please review the current head; no merge action is requested.

Comment thread packages/agent/test/system-record-reconcile-closure-continuation-v1.test.ts Outdated
Comment thread packages/agent/src/system-records/reconcile-v1.ts Outdated
Comment thread packages/agent/src/system-records/reconcile-v1.ts Outdated
Comment thread packages/agent/src/system-records/reconcile-transport-v1.ts Outdated
@Jurij89

Jurij89 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

Exact-head review requested for 626ecc6 under the round cap. The direct API compatibility blocker is fixed and pinned in the type lane; retained object/byte overflow and mixed inventory-plus-closure continuation budget coverage are added; mutable final verifiers rerun on resume. Local validation is 201/201 Agent System Record tests plus a clean Agent build/type/package-root run. Remaining architecture preferences are tracked in #2216 and the required final parent rebase. Please report only red/high behavioral defects or acceptance-criteria gaps; no merge action is requested.

Comment thread packages/agent/test/system-record-reconcile-transport-v1.test.ts
Comment thread packages/agent/src/system-records/reconcile-transport-v1.ts
@Jurij89
Jurij89 force-pushed the feat/2052-agent-profile-requester branch from ffae2e4 to 0c5f230 Compare August 10, 2026 03:30
Comment thread packages/core/src/system-record-inventory-traversal-v1-internal.ts
Comment thread packages/core/src/system-record-inventory-traversal-v1-internal.ts
@Jurij89
Jurij89 force-pushed the feat/2052-agent-profile-transport branch from 626ecc6 to 7000435 Compare August 10, 2026 07:07
@Jurij89
Jurij89 changed the base branch from feat/2052-agent-profile-requester to integration/2052-system-record-sync August 10, 2026 07:08
@Jurij89
Jurij89 force-pushed the feat/2052-agent-profile-transport branch from 7000435 to b611e98 Compare August 10, 2026 07:17
@Jurij89
Jurij89 force-pushed the feat/2052-agent-profile-transport branch from b611e98 to e82dcf4 Compare August 10, 2026 07:31
Comment thread packages/agent/src/system-records/reconcile-transport-v1.ts Outdated
Comment thread packages/agent/src/system-records/reconcile-v1.ts
@Jurij89
Jurij89 force-pushed the feat/2052-agent-profile-transport branch from e82dcf4 to d218c78 Compare August 10, 2026 07:49
@Jurij89
Jurij89 merged commit e25ee23 into integration/2052-system-record-sync Aug 10, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants