feat(ops): go 100% ACE API for the ACE-owned surface - #2
Draft
magiodev-cll wants to merge 5 commits into
Draft
Conversation
Production policy configuration is control-plane-driven, not raw onchain calls. Adds a plan/apply/verify client for the ACE Coordinator API (ace.api.chain.link/v1), ported from the semantics proven in the Caliber repo, with a desired-state manifest and onchain readback reconciliation: - scripts/lib/ace-api.ts: typed client (engine/extractor/target/protection endpoints, Apikey auth, pagination) + apply confirmations - scripts/ace-configuration.json: desired state mirroring the engine extractor association and registry writer protections deployAceCore wires onchain for tests; product/escrow wiring stays factory-owned - scripts/configure-ace.ts: validate (offline) | plan | apply | verify (API state vs onchain getExtractor/getPolicies readback); hardhat run takes no positional args, so the command is env-driven - README: control-plane configuration section Contract deployment (scripts/deploy.ts) and CCIP identity-sync tooling are unaffected; the API only manages configuration.
Hardhat now deploys only Commertize's own infra (extractor contracts, policy implementations, factory, token implementation); the PolicyEngine, identity/credential registries, policy instances and policy attachment are created and wired through the ACE Coordinator API (surface per the bundled OpenAPI doc), matching the Caliber control-plane pattern. - configure-ace.ts: full plan/apply/verify pipeline — extractors, engine (API-deployed), registries (API-deployed), implementations, policies, targets, protections — each polled until onchain status is created; apply persists the created addresses back into the manifest; verify reconciles against onchain readback - ace-configuration.json: v2 desired-state manifest + outputs write-back; policy config schemas flagged as platform-provided (GET /policy-implementations) - deploy.ts: two-phase own-infra deployer (DEPLOY_PHASE=extractors|factory), factory phase requires the API-created engine + RejectPolicy addresses - ace-api.ts: patch(), status polling; drop local-e2e/e2e-local (tests cover the stack via the harness); ace-core.ts is now an explicit test-only harness simulating the API end state - README + .env.example: control-plane flow, Beta caveats, env vars
The local-e2e script was removed with the move to API-driven ACE configuration; the unit suites already exercise the full stack through the local-node harness.
- ace-api: drop dead sameStrings/requireApplyConfirmation/patch/findPolicyEngine - configure-ace: halve validateManifest, remove unused converged flags, dedup the five write-then-resolve blocks into writeAndResolve, merge apply write-back + manifest persist, drop unused writeBack param - deploy: import invariant instead of redefining it, loop the manifest address writes
- isAddress/zeroAddress from viem instead of the hand-rolled regex and string constant; assert from node:assert instead of a reimplemented invariant (removes the checksum-agnostic address check too) - process.loadEnvFile replaces the bespoke .env parser (ace-api loadDotEnv) and the dotenv package fallback in hardhat.config - inline the single-use statusOf into waitForStatus; deploy.ts reuses readJson - remove the dotenv dependency (Node 22 native)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #1. Reconciles the sample with how ACE is actually operated offchain: everything ACE-owned (PolicyEngine, identity/credential registries, policy instances, policy attachment, extractor registration) is created and wired through the ACE Coordinator API (
ace.api.chain.link/v1, surface per the bundled OpenAPI doc), while hardhat deploys only Commertize's own infra contracts. Same split as the Caliber control-plane pattern.What changes
scripts/configure-ace.ts— fullvalidate | plan | apply | verifypipeline over the real API surface: extractors → PolicyEngine (API-deployed via CRE Connect signing) → registries (API-deployed) → policy implementations → policy instances → targets → protections. Every resource is polled until its onchain status iscreated;applypersists the created addresses back into the manifest (needed by the factory phase);verifyreconciles API state against onchain readback (getExtractor,getPolicies).scripts/ace-configuration.json— v2 desired-state manifest: 3 extractors (incl. our customAccountExtractor), 3 policy implementations, engine/registries/policies/targets desired state, and anoutputswrite-back block. Policy config schemas (policyImplementations[*].configSchema) are flagged as platform-provided (GET /policy-implementations) — fill from the live API before apply.scripts/deploy.ts— now own-infra only, two phases (DEPLOY_PHASE):extractors(stock + custom extractor contracts, 3 policy implementation contracts → manifest) andfactory(PropertyToken implementation + PropertyFactory wired to the API-created engine and RejectPolicy instance; fails fast if the manifest lacks them).scripts/lib/ace-api.ts— extended client:patch, per-chain status polling (statusOf,waitForStatus),Apikeyauth, pagination.scripts/local-e2e.ts+scripts/e2e-local.sh— superseded: the hardhat tests cover the stack viascripts/lib/ace-core.ts, now an explicit test-only harness that simulates the API's end state..env.example— all script env vars documented (ACE_API_KEY,ACE_CONFIG_*,DEPLOY_PHASE, CCIP/sync vars).deploy:extractors→config-ace:plan/apply→deploy:factory→config-ace:verify), identity/credential issuance via the IDV partner (SumSub/Persona) or your backend through the Identity Manager API, and the Beta caveats.Operation flow
Beta caveats (documented in README)
AccountExtractor) are beyond the Beta platform surface (ERC-20/ERC-3643 signatures only) — they work onchain, just not platform-manageable yet.Verification
pnpm config-ace:validatepasses (offline manifest check)plan/apply/verifyrequire a realACE_API_KEY+ org access against the live API — exercise on testnet once provisioned