Skip to content

feat(agent): add exact active System Record receiver - #2202

Merged
Jurij89 merged 18 commits into
integration/2052-system-record-syncfrom
fix/2052-agent-profile-sync
Aug 9, 2026
Merged

feat(agent): add exact active System Record receiver#2202
Jurij89 merged 18 commits into
integration/2052-system-record-syncfrom
fix/2052-agent-profile-sync

Conversation

@Jurij89

@Jurij89 Jurij89 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add the first default-off Stack D receiver kernel for one already-admitted ordinary active Agent Profile inventory row, rebased on exact integration/2052-system-record-sync head d11f10b9f9fdf9e4fc8d1ae8859385cfb9a3cc2e.
  • Keep final current-bundle publication/seal acceptance as a boolean hook inside Core closure traversal on a defensive byte copy.
  • Parse the exact closure-retained bundle with Core's bounded canonical graphless storage-quad parser, which provides strict V10 UTF-8, line, order, duplicate, term, and fixed-point syntax only; the receiver separately proves authority, digest, signed byte/quad counts, seal, projection schema, and profile identity.
  • Build one immutable verified candidate-facts value containing the active envelope, receiver-derived and schema/identity-validated projection, rotated authority summary, and digest/count-bound owned-subject table before entering lifecycle preparation.
  • Use an explicit prepareCandidateApply phase: the lifecycle bridge finishes asynchronous preparation and returns authenticated monotonic timing plus an apply closure; the receiver rechecks cancellation and signed wall-clock freshness, clamps the deadline to min(existingDeadline, monotonicNow + remainingMs), and synchronously invokes that closure exactly once.
  • Keep prior outcomes, replacement proofs, and signed Unix timestamps out of the bridge contract, eliminating the replayable opaque-result/sentinel protocol while preserving the committed outcome after the point of no return.
  • Preserve fail-closed row/artifact/table/authority/freshness binding, per-kind byte caps before copies, active-envelope typing, dependency snapshotting, verifier mutation isolation, and cancellation handling.
  • Keep protocol registration, traversal scheduling, retries, reconciliation, timers, queues, runtime wiring, and activation out of this PR; current node behavior remains unchanged.

Related

Diagrams

Active profile verification and apply kernel

Before:

sequenceDiagram
    participant Coordinator
    participant Receiver
    participant Repository
    participant BundleVerifier
    participant Materializer
    Coordinator-->>Receiver: No callable active-row kernel
    Note over Receiver,Materializer: Repository, verifier, and materializer are not connected
Loading

After:

sequenceDiagram
    participant Coordinator
    participant Receiver
    participant Repository
    participant BundleVerifier
    participant CoreParser
    participant Materializer
    Coordinator->>Receiver: Already-admitted ordinary active row
    Receiver->>Repository: Snapshot and bind exact current head
    Receiver->>Receiver: Reject non-active or expired current head
    Receiver->>Repository: Resolve bounded authority closure and current bundle
    Receiver->>BundleVerifier: Accept exact current bundle once on a copy
    BundleVerifier-->>Receiver: Boolean acceptance
    Receiver->>CoreParser: Parse exact retained projection lines
    CoreParser-->>Receiver: Syntactically canonical storage-ready graphless quads
    Receiver->>Repository: Resolve and bind exact owned-subject table
    Receiver->>Materializer: Prepare verified candidate apply
    Materializer-->>Receiver: Existing deadline, fresh monotonic now, apply closure
    Receiver->>Receiver: Recheck cancellation and wall expiry; clamp deadline
    Receiver->>Materializer: Invoke apply once with clamped monotonic deadline
    Materializer-->>Receiver: Apply outcome
    Receiver-->>Coordinator: Preserve committed outcome after point of no return
Loading

The receiver remains unregistered and default-unused in production lifecycle code.

Files changed

File What
packages/agent/src/system-records/receiver-v1.ts Adds the active-row receiver, boolean closure bundle acceptance, Core-owned bounded syntactic projection parsing plus signed count, schema, and identity validation, unified verified candidate-facts builder, explicit prepared-apply phase, bounded artifact snapshots, active envelope typing, and lifecycle handoff.
packages/core/src/cg-shared-projection.ts Exposes parseCanonicalGraphlessProjectionStorageQuadsV1, a bounded syntactic canonical graphless parser whose explicit storage-quad type documents IRI normalization, literal lexical preservation, and the empty graph, with no authority, digest, count, seal, or schema proof; cg-shared verification consumes the same strict line walker.
packages/agent/test/system-record-receiver-v1.test.ts Covers exact verifier inputs, projection derivation/rejection, apply phasing, wall-to-monotonic deadline translation, freshness and cancellation boundaries, mutation isolation, authority lineage, owned-subject binding, bounded copies, and dependency capture.
packages/agent/test/support/agent-profile-receiver-v1-fixture.ts Holds shared publication, rotation, malformed signed-bundle, prepared-apply, and comparison fixtures.
packages/core/test/cg-shared-projection.test.ts Covers storage-quad parsing for literal and IRI objects plus graphful, noncanonical-order, and invalid-UTF-8 rejection.

Test plan

  • pnpm --filter @origintrail-official/dkg-core run build
  • pnpm --filter @origintrail-official/dkg-storage run build
  • pnpm --filter @origintrail-official/dkg-agent run build (includes Agent type tests and package-root gate)
  • pnpm --filter @origintrail-official/dkg-core run test:system-record-export (269 exact exports)
  • Core test/system-record-objects-v1.test.ts (33 passed, 1 intentionally skipped)
  • Core canonical projection suite (51/51)
  • Storage type-contract and package-export gates
  • Storage verified-replacement and materializer-lifecycle suites (133/133)
  • Focused receiver suite (37/37)
  • All Agent system-record receiver/producer/provider suites (116/116)
  • git diff --check
  • Confirm the branch contains no ignored, generated, deployment, or local-only files.

@Jurij89

Jurij89 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@otReviewAgent Please review the current head for merge readiness. This is the first default-unused Stack D receiver kernel; it does not register or activate sync, and its local resource/fail-closed gates plus live managed-ownership CI are green.

Comment thread packages/agent/src/system-records/receiver-v1.ts Outdated
Comment thread packages/agent/src/system-records/receiver-v1.ts
Comment thread packages/agent/test/system-record-receiver-v1.test.ts
Comment thread packages/agent/src/system-records/receiver-v1.ts
Comment thread packages/agent/src/system-records/receiver-v1.ts Outdated
Comment thread packages/agent/test/system-record-receiver-v1.test.ts Outdated
Comment thread packages/agent/src/system-records/receiver-v1.ts
Comment thread packages/agent/test/system-record-receiver-v1.test.ts
@Jurij89

Jurij89 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@otReviewAgent Please review current head f94b34d for convergence. The latest commit pins exact verifier head/bundle/signal inputs, exposes an active-head envelope at the candidate boundary, and verifies full multi-subject handoff; Agent build/type/package checks and 65/65 focused tests pass.

@Jurij89

Jurij89 commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@otReviewAgent Please review the current head after the empty retrigger commit; evaluate the exact active receiver kernel for convergence.

@Jurij89
Jurij89 force-pushed the fix/2052-agent-profile-sync branch from 3e5d036 to 7c79c98 Compare August 9, 2026 20:49
Comment thread packages/agent/src/system-records/receiver-v1.ts Outdated
Comment thread packages/agent/src/system-records/receiver-v1.ts Outdated
Comment thread packages/agent/test/system-record-receiver-v1.test.ts Outdated
Comment thread packages/agent/src/system-records/receiver-v1.ts
Comment thread packages/agent/test/system-record-receiver-v1.test.ts Outdated
Comment thread packages/core/src/cg-shared-projection.ts Outdated
Comment thread packages/agent/src/system-records/receiver-v1.ts
Comment thread packages/core/src/cg-shared-projection.ts
@Jurij89
Jurij89 merged commit a5c04c2 into integration/2052-system-record-sync Aug 9, 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