Skip to content

refactor(agent): decompose dormant profile record stack - #2174

Merged
Jurij89 merged 12 commits into
integration/2052-system-record-syncfrom
refactor/2156-agent-profile-decomposition
Aug 8, 2026
Merged

refactor(agent): decompose dormant profile record stack#2174
Jurij89 merged 12 commits into
integration/2052-system-record-syncfrom
refactor/2156-agent-profile-decomposition

Conversation

@Jurij89

@Jurij89 Jurij89 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Centralizes the frozen Agent Profile V1 RDF subject, predicate, object-term, type, link, and derivation policy in one exhaustive internal Core descriptor with discriminated predicate variants shared by profile authoring and materialization validation, while exposing only stable terms and helper APIs.
  • Decomposes the dormant producer into explicit preparation, signing, inventory/closure, and install/commit stages with private narrow views over one immutable producer context, an explicitly named stable public API module, and one façade responsible for single-flight, lease, abort, and stage ordering.
  • Preserves the existing wire bytes, signatures, resource caps, CAS preconditions, producer deep-import exports, and install point-of-no-return semantics; this PR adds no lifecycle, timer, protocol, cache, scheduler, or activation work.
  • Splits the 1,521-line producer test into four concern-focused suites, preserves all 51 original cases, and adds a canonical artifact-traversal regression.

Related

Diagrams

Producer publication flow

Before:

sequenceDiagram
    participant Caller
    participant Producer
    participant Preparation
    participant Signers
    participant Inventory
    participant Store
    Caller->>Producer: complete(confirmed publication)
    Note over Producer,Preparation: preparation and authority checks are inlined
    Producer->>Store: snapshot and resolve prior authority
    Producer->>Signers: sign head and inventory root
    Note over Producer,Inventory: inventory and closure work is inlined
    Producer->>Store: reserve expected snapshot
    Producer->>Store: install verified projection
    Producer->>Store: commit advertisement
    Producer-->>Caller: publication result
Loading

After:

sequenceDiagram
    participant Caller
    participant Producer
    participant Preparation
    participant Signers
    participant Inventory
    participant Store
    Caller->>Producer: complete(confirmed publication)
    Producer->>Preparation: build exact authority and publication plan
    Preparation->>Store: snapshot and resolve prior authority
    Producer->>Signers: sign and verify exact head
    Producer->>Inventory: plan inventory, artifacts, and closure
    Inventory->>Store: resolve retained authority artifacts
    Producer->>Store: reserve expected snapshot
    Producer->>Store: install verified projection
    Producer->>Store: commit advertisement
    Producer-->>Caller: publication result
Loading

Profile schema ownership

Before:

sequenceDiagram
    participant Author
    participant Schema
    participant Verifier
    Author->>Author: construct RDF from local vocabulary and subject strings
    Note over Schema: predicate policy split across Core modules
    Verifier->>Verifier: validate with parallel predicate, type, term, and link tables
Loading

After:

sequenceDiagram
    participant Author
    participant Schema
    participant Verifier
    Author->>Schema: resolve canonical terms and derived subject shapes
    Schema-->>Author: frozen V1 policy
    Verifier->>Schema: resolve subject and predicate policy
    Schema-->>Verifier: term kind, type, link, binding, and derivation rules
Loading

Files changed

File What
packages/core/src/agent-profile-schema-model-v1.ts Adds the single immutable V1 schema descriptor and bounded lookup/derivation helpers.
packages/core/src/system-record-objects-v1.ts Delegates stable public policy helpers and canonical root matching without exporting the internal policy interpreter.
packages/core/src/agent-profile-projection-schema-v1.ts Validates term kinds, types, links, root bindings, and X25519 derivation from descriptor policy.
packages/core/test/system-record-policy-helpers-v1.test.ts Pins the policy matrix and behaviorally covers generic IRI, workspace-key, and revocation-root enforcement.
packages/core/test/system-record-package-export-v1.mjs Verifies stable schema terms remain available through the existing System Record barrel.
packages/agent/src/profile.ts Authors predicates and derived subjects from the canonical Core schema model.
packages/agent/src/system-records/agent-profile-producer-api-v1.ts Explicitly owns only stable producer, store, publication, signer, and lease API contracts.
packages/agent/src/system-records/agent-profile-producer-artifacts-v1-internal.ts Provides the one ordered publication-artifact traversal used by verification and store accounting; its package path is blocked.
packages/agent/src/system-records/agent-profile-producer-preparation-v1.ts Validates and defensively snapshots the canonical projection, identity, and owned subjects before the publication fence.
packages/agent/src/system-records/agent-profile-producer-signing-v1.ts Signs and verifies only the exact head/digest input with signer capabilities.
packages/agent/src/system-records/agent-profile-producer-inventory-v1.ts Colocates its artifact-resolution capability and private artifact flattening while planning/signing the COW inventory and verifying authority closure.
packages/agent/src/system-records/agent-profile-producer-commit-v1.ts Accepts only commit-required preparation/signing fields, colocates prepare/install capabilities, and preserves reserve/install/advertise ordering plus the point of no return.
packages/agent/src/system-records/agent-profile-producer-v1.ts Becomes the thin single-flight lease and ordered stage orchestrator over one immutable context while preserving the historical artifact-flattening named export.
packages/agent/test/system-record-agent-profile-producer-*-v1.test.ts Replaces the monolithic suite with publication, authority, validation, and lifecycle suites.
packages/agent/test/agent-profile-producer-phase-boundaries.typecheck.ts Proves phase DTOs and artifact-flattening helpers do not leak and raw profiles cannot cross the prepared-snapshot boundary.
packages/agent/package.json Explicitly whitelists the five historical public System Record deep modules and blocks every other current or future module with a wildcard fallback.
packages/agent/scripts/test-package-root.mjs Proves the historical System Record modules and flattening helper remain compatible while internal/future module paths fail with exact package-export rejection.

Test plan

  • pnpm --filter @origintrail-official/dkg-agent... build
    • Agent dependency closure, type tests, and package-root test pass.
  • pnpm --filter @origintrail-official/dkg-core test:system-record
    • 87 passed, 2 skipped.
  • pnpm --filter @origintrail-official/dkg-core test:system-record-export
    • System Record package export gate passes with 6 representative symbols.
  • pnpm exec vitest run test/system-record-agent-profile-producer-*-v1.test.ts test/system-record-provider-v1.test.ts test/profile-preparation-v1.test.ts --maxWorkers=1 --no-file-parallelism
    • 89/89 passed across the focused producer, provider, profile-preparation, signer, and façade suites; all 51 original producer cases remain, plus the canonical artifact-traversal regression.
  • pnpm exec vitest run test/system-record-verified-replacement-v1.test.ts test/system-record-next-state-v1.test.ts test/system-record-atomic-apply-executor-v1.test.ts --maxWorkers=1 --no-file-parallelism
    • 62/62 Storage consumer tests passed.
  • git diff --check
    • No whitespace errors.
  • Confirm no activation/config/protocol files, generated deployment metadata, ignored docs, or secrets are included.

Comment thread packages/core/src/agent-profile-schema-model-v1.ts Outdated
Comment thread packages/core/src/agent-profile-schema-model-v1.ts
Comment thread packages/agent/src/system-records/agent-profile-producer-inventory-v1.ts Outdated
Comment thread packages/agent/src/system-records/agent-profile-producer-v1.ts
Comment thread packages/agent/src/system-records/agent-profile-producer-preparation-v1.ts Outdated
Comment thread packages/core/src/system-record-objects-v1.ts Outdated
Comment thread packages/core/src/agent-profile-projection-schema-v1.ts
Comment thread packages/core/test/system-record-policy-helpers-v1.test.ts
Comment thread packages/agent/src/system-records/agent-profile-producer-preparation-v1.ts Outdated
Comment thread packages/agent/src/system-records/agent-profile-producer-v1.ts
Comment thread packages/agent/src/system-records/in-memory-agent-profile-publication-store-v1.ts Outdated
Comment thread packages/agent/package.json Outdated
Comment thread packages/agent/src/system-records/agent-profile-producer-v1.ts Outdated

@otReviewAgent otReviewAgent left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Agent completed this review and found no issues.

@Jurij89
Jurij89 merged commit 2f2bd81 into integration/2052-system-record-sync Aug 8, 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