Skip to content

Commit 4bb2920

Browse files
feat(scaffold): create:integration --dde generates a ready DDE/1 payment-gate template
One command now materialises a runnable bilateral-evidence scaffold for new projects: templates/integration-dde ships ten pinned DDE/1 records (dde-fixture/ + hashes.json over exact template bytes — the fixture is static, name-placeholder-free, so the pins hold in every generated project), a standalone zero-dep boundary engine (engine-dde.mjs, same F/E/B semantics, E5 honestly NOT_RUN), a one-command verifier (verify-dde.mjs), the release loop with both scenarios (payout-gate.mjs: HOLD on the shipped party REJECTED record; a settled transaction alone releases nothing), and 5 contract tests. Honesty is structural: the execution record is an OWNER-DECLARED placeholder with paymentSettled:false and a zero txHash — nothing in the scaffold can masquerade as a verified execution claim. The generator gains a --dde flag (default path byte-identical), and two new contract tests cover the generated file set, placeholder resolution, the honest execution placeholder — and verify the generated fixture against the REAL packages/delivery engine in-repo (the cross-check CI runs). Full suite 873/873. Generated with Codebuff 🤖 Co-Authored-By: Codebuff <noreply@codebuff.com>
1 parent e812702 commit 4bb2920

20 files changed

Lines changed: 1019 additions & 16 deletions

‎README.md‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,30 @@ The only thing that opens the gate is a party acceptance record resting on
214214
criterion evaluations. Signatures, receipts and settlement are admissible
215215
evidence — never a verdict.
216216

217+
### One-command scaffold for new projects
218+
219+
```bash
220+
node scripts/create-integration.mjs my-escrow-dapp --dde # from this repo
221+
```
222+
223+
Generates a working DDE/1 payment-gate scaffold under `./my-escrow-dapp/`:
224+
ten pinned evidence records (`dde-fixture/` + `hashes.json`), a standalone
225+
boundary engine (`engine-dde.mjs`, zero dependencies, CI-checked against the
226+
in-repo engine on the shipped fixture), a one-command verifier, the release
227+
loop with both scenarios, and 5 contract tests — runnable immediately:
228+
229+
```bash
230+
cd my-escrow-dapp
231+
node verify-dde.mjs # → VERIFIED · EXECUTION_EVIDENCE_ADMISSIBLE — CONFORMITY_UNDECIDED_BY_ENGINE
232+
node payout-gate.mjs # → HOLD (party REJECTED) — then swap in your ACCEPTED record to release
233+
node --test # 5/5 green
234+
```
235+
236+
The shipped fixture is honestly labeled (`SYNTHETIC`, `realDisputeExists:
237+
false`) and its execution record is an `OWNER-DECLARED` placeholder —
238+
`paymentSettled: false`, a zero txHash, provably settling nothing — so nothing
239+
in the scaffold can be mistaken for a verified execution claim.
240+
217241
### Two-line SDK integration
218242

219243
```js

‎scripts/create-integration.mjs‎

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
/**
22
* CoreGuard — create-coreguard-integration generator (plan-90d-repo §2.2).
33
*
4-
* node scripts/create-integration.mjs <name>
4+
* node scripts/create-integration.mjs <name> # Phase-1 guard scaffold
5+
* node scripts/create-integration.mjs <name> --dde # DDE/1 payment-gate scaffold
56
*
6-
* Materialises a standalone integration template under ./<name>/ containing
7-
* intent / policy / trace fixtures, a verifier script and a smoke test, using
8-
* the public @coreguard/sdk guard surface (authorize → verify → anchor).
7+
* Materialises a standalone integration template under ./<name>/ using the
8+
* public CoreGuard surfaces:
9+
*
10+
* default — templates/integration: intent/policy/trace fixtures + verifier
11+
* + smoke test over the @coreguard/sdk guard surface
12+
* (authorize → verify → anchor).
13+
* --dde — templates/integration-dde: a working bilateral evidence fixture
14+
* (ten DDE/1 records + SHA-256 pins), a standalone boundary engine,
15+
* a one-command verifier, and a payment gate whose release law is
16+
* engine VERIFIED **and** party ACCEPTED — a settled transaction
17+
* alone releases nothing.
918
*
1019
* The generated project is intentionally NOT part of this workspace: it
11-
* consumes `@coreguard/sdk` like any external integrator would
12-
* (`npm install @coreguard/sdk` inside the generated directory).
20+
* consumes CoreGuard the way an external integrator would.
1321
*/
1422

1523
import { cp, mkdir, readFile, readdir, writeFile } from "node:fs/promises";
@@ -26,8 +34,9 @@ const NAME_PLACEHOLDER = "{{NAME}}";
2634

2735
function usage() {
2836
console.error(
29-
"usage: node scripts/create-integration.mjs <name>\n" +
30-
" creates ./<name> from templates/integration (fixtures + verifier + tests)"
37+
"usage: node scripts/create-integration.mjs <name> [--dde]\n" +
38+
" default creates ./<name> from templates/integration (fixtures + verifier + tests)\n" +
39+
" --dde creates ./<name> from templates/integration-dde (evidence fixture + payment gate + tests)"
3140
);
3241
process.exit(1);
3342
}
@@ -55,9 +64,17 @@ async function walkAbsolute(absDir, destBase, name, entries) {
5564
}
5665

5766
async function main() {
58-
const name = process.argv[2];
67+
const args = process.argv.slice(2);
68+
const dde = args.includes("--dde");
69+
const name = args.find((a) => !a.startsWith("--"));
5970
if (!name || /[^a-z0-9._-]/i.test(name)) usage();
6071

72+
const sourceDir = dde ? join(root, "templates", "integration-dde") : templateDir;
73+
if (!existsSync(sourceDir)) {
74+
console.error(`create-integration: template missing: ${sourceDir}`);
75+
process.exit(1);
76+
}
77+
6178
const dest = resolve(process.cwd(), name);
6279
if (existsSync(dest)) {
6380
console.error(`create-integration: ${name} already exists — refusing to overwrite`);
@@ -66,14 +83,21 @@ async function main() {
6683

6784
await mkdir(dest, { recursive: true });
6885
const entries = [];
69-
await walkAbsolute(templateDir, dest, name, entries);
86+
await walkAbsolute(sourceDir, dest, name, entries);
7087

71-
console.log(`CoreGuard integration created at ./${name}`);
88+
console.log(`CoreGuard ${dde ? "DDE payment-gate" : "integration"} scaffold created at ./${name}`);
7289
console.log(` files: ${entries.length}`);
73-
console.log(` next: cd ${name} && npm install @coreguard/sdk`);
74-
console.log(` verify: node verify.mjs`);
75-
console.log(` demo: node example.mjs`);
76-
console.log(` tests: node --test`);
90+
if (dde) {
91+
console.log(` verify: node verify-dde.mjs # re-verify the evidence fixture (VERIFIED expected)`);
92+
console.log(` gate: node payout-gate.mjs # release/hold loop (held: party REJECTED in the fixture)`);
93+
console.log(` tests: node --test`);
94+
console.log(` next: replace the OWNER-DECLARED execution placeholder and the synthetic records with your real evidence`);
95+
} else {
96+
console.log(` next: cd ${name} && npm install @coreguard/sdk`);
97+
console.log(` verify: node verify.mjs`);
98+
console.log(` demo: node example.mjs`);
99+
console.log(` tests: node --test`);
100+
}
77101
}
78102

79103
if (process.argv[1] === fileURLToPath(import.meta.url)) {
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# {{NAME}} — CoreGuard DDE payment-gate scaffold
2+
3+
{{NAME}} is a Delivery & Dispute Evidence (DDE/1) integration scaffold. It embeds
4+
a working bilateral evidence fixture and a payment gate whose law is the DDE
5+
boundary itself: **execution verification does not decide delivery conformity.**
6+
Payment release requires a party-signed acceptance record resting on criterion
7+
evaluations — a settled transaction, by itself, releases nothing.
8+
9+
## Files
10+
11+
| file | purpose |
12+
| --- | --- |
13+
| `dde-fixture/` | the ten DDE/1 records + `hashes.json` (SHA-256 pins over exact record bytes) |
14+
| `verify-dde.mjs` | one-command re-verification: `node verify-dde.mjs` → full check table + exit code |
15+
| `payout-gate.mjs` | the release loop: verify → party acceptance → release / hold with named reasons |
16+
| `test/dde.test.js` | contract tests: `node --test` |
17+
18+
## Try it
19+
20+
```bash
21+
node verify-dde.mjs # → status=VERIFIED, decision=EXECUTION_EVIDENCE_ADMISSIBLE — CONFORMITY_UNDECIDED_BY_ENGINE
22+
node payout-gate.mjs # → release: gate satisfied
23+
node --test # contract tests green
24+
```
25+
26+
## The boundary this scaffold enforces
27+
28+
- `EXECUTION_EVIDENCE_ADMISSIBLE — CONFORMITY_UNDECIDED_BY_ENGINE` is the honest
29+
success shape: the evidence record is admissible, and the engine has *not*
30+
judged the delivery.
31+
- Payment release requires **both**: engine `VERIFIED` **and** a party-signed
32+
acceptance record resting on `CRITERIA_EVALUATION`. A settled transaction
33+
alone never satisfies the gate.
34+
- The engine never names a dispute winner: both parties' positions and remedies
35+
are preserved verbatim in the closed record.
36+
- Every report carries the `DDE-BOUNDARY` banner; quote it with any number you
37+
cite from a report.
38+
39+
## The fixture is a scaffold, honestly labeled
40+
41+
`origin: "SYNTHETIC"` on every record; `realDisputeExists: false`; both parties
42+
are deterministic template identities. Two layers are placeholders by design:
43+
44+
- `execution-attestation.json` is `OWNER-DECLARED`: an unset placeholder with
45+
`paymentSettled: false` and a zero txHash. Replace it with your real
46+
execution evidence before shipping — never describe the placeholder as
47+
verified.
48+
- `realSignatures: false`: the consent and intent signatures are deterministic
49+
scaffold values over the fixture's own keys. Swap in real EIP-712 signatures
50+
when your parties are real; `packages/delivery` replays them (check E5)
51+
the moment you supply an EVM adapter.
52+
53+
## Making it yours
54+
55+
1. Replace the delivery artifacts and acceptance criteria with your real
56+
deliverable and its testable criteria; re-pin `hashes.json` over the exact
57+
new record bytes.
58+
2. Fill in real parties, real authorization, and a real execution attestation.
59+
3. Wire `payout-gate.mjs` into your payment flow: release only when the gate
60+
says so, hold with the named reasons otherwise.
61+
62+
## Packages
63+
64+
The `@coreguard/delivery` engine (the boundary enforcement this scaffold
65+
exercises) currently ships from the [coreguard repository](https://github.com/EslaM-X/coreguard)
66+
(`packages/delivery`) — no npm package is published yet. Two ways to run this
67+
scaffold against the real engine:
68+
69+
- **In the coreguard workspace**: link this directory into the repo's
70+
`workspaces` and import from `@coreguard/delivery` directly.
71+
- **Standalone**: copy `packages/delivery/index.js` (zero dependencies,
72+
Node ≥ 18) next to your project and import it as a local module.
73+
74+
Until then the scaffold runs self-contained: its bundled `engine-dde.mjs`
75+
implements the same DDE/1 boundary for offline use and is CI-checked against
76+
the real engine.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"origin": "SYNTHETIC",
3+
"recordId": "DDE-SCAFFOLD-CRITERIA",
4+
"criteriaRef": "DDE-SCAFFOLD-CRITERIA",
5+
"agreementRef": "DDE-SCAFFOLD-AGREEMENT",
6+
"version": "1.0.0",
7+
"note": "Machine-inspectable acceptance criteria fixed before delivery. Conformity is judged by the parties against these criteria — never by the DDE engine. Replace with the real, testable criteria of your deliverable.",
8+
"criteria": [
9+
{
10+
"id": "C-SCOPE",
11+
"statement": "Delivery includes an artifact with id 'scaffold-delivery.md'.",
12+
"check": { "kind": "artifact-exists", "artifactId": "scaffold-delivery.md" }
13+
},
14+
{
15+
"id": "C-TIMELINE",
16+
"statement": "Delivery was submitted no later than the agreement deadline.",
17+
"check": { "kind": "submitted-before-deadline" }
18+
},
19+
{
20+
"id": "C-QUALITY",
21+
"statement": "Artifact 'scaffold-delivery.md' opens with a top-level markdown heading.",
22+
"check": { "kind": "artifact-prefix", "artifactId": "scaffold-delivery.md", "prefix": "# " }
23+
}
24+
],
25+
"provenance": "SYNTHETIC — scaffold criteria generated by coreguard templates/integration-dde; replace with your real acceptance criteria."
26+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"origin": "SYNTHETIC",
3+
"recordId": "DDE-SCAFFOLD-ACCEPTANCE",
4+
"acceptanceId": "DDE-SCAFFOLD-ACCEPTANCE",
5+
"criteriaRef": "DDE-SCAFFOLD-CRITERIA",
6+
"deliveryRef": "DDE-SCAFFOLD-DELIVERY",
7+
"verdict": "REJECTED",
8+
"basis": ["CRITERIA_EVALUATION"],
9+
"derivedFrom": "criteria",
10+
"evaluations": [
11+
{
12+
"criterionId": "C-SCOPE",
13+
"result": "PASS",
14+
"observed": "artifact 'scaffold-delivery.md' present in the delivery manifest"
15+
},
16+
{
17+
"criterionId": "C-TIMELINE",
18+
"result": "PASS",
19+
"observed": "submitted 2026-09-24T09:30:00Z <= deadline 2026-12-31T23:59:59Z"
20+
},
21+
{
22+
"criterionId": "C-QUALITY",
23+
"result": "FAIL",
24+
"observed": "'scaffold-delivery.md' states delivered-for-schema-exercise; the criterion as authored expects real deliverable content — the scaffold models a rejection"
25+
}
26+
],
27+
"signedBy": ["0x0000000000000000000000000000000000c1d002"],
28+
"recordedAtUtc": "2026-09-24T15:00:00Z",
29+
"note": "The rejection rests solely on the recorded criterion evaluations. It is a party act under DDE/1 — it is not derived from execution facts, and payment settlement plays no part in it. Replace with your real acceptance decision.",
30+
"provenance": "SYNTHETIC — scaffold acceptance record generated by coreguard templates/integration-dde; the modeled rejection exercises the criteria path."
31+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"origin": "SYNTHETIC",
3+
"recordId": "DDE-SCAFFOLD-AGREEMENT",
4+
"agreementId": "DDE-SCAFFOLD-AGREEMENT",
5+
"version": "1.0.0",
6+
"title": "CoreGuard DDE scaffold — bilateral delivery agreement",
7+
"client": {
8+
"role": "client (buyer of the deliverable)",
9+
"principalAddress": "0x0000000000000000000000000000000000c1d001",
10+
"agentAddress": "0x0000000000000000000000000000000000c1d002",
11+
"authority": "principal scopes the agent by an off-chain mandate for this agreement only"
12+
},
13+
"provider": {
14+
"role": "provider (produces and delivers the deliverable)",
15+
"principalAddress": "0x0000000000000000000000000000000000c1d004",
16+
"agentAddress": "0x0000000000000000000000000000000000c1d003",
17+
"authority": "agent signs delivery records within the agreed scope"
18+
},
19+
"scope": "One deliverable package for scaffold exercise. Replace with your real scope.",
20+
"compensationWei": "250000000000000000",
21+
"deadlineUtc": "2026-12-31T23:59:59Z",
22+
"agreedAtUtc": "2026-09-21T08:00:00Z",
23+
"provenance": "SYNTHETIC — scaffold agreement generated by coreguard templates/integration-dde; no real parties. Replace with your real agreement."
24+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"origin": "SYNTHETIC",
3+
"recordId": "DDE-SCAFFOLD-AUTH",
4+
"scheme": "EIP-712",
5+
"subject": "0x0000000000000000000000000000000000c1d002",
6+
"signer": "0x0000000000000000000000000000000000c1d002",
7+
"intent": {
8+
"agreementId": "DDE-SCAFFOLD-AGREEMENT",
9+
"clientAgent": "0x0000000000000000000000000000000000c1d002",
10+
"providerAgent": "0x0000000000000000000000000000000000c1d003",
11+
"maxValueWei": "250000000000000000",
12+
"deadlineUtc": "2026-12-31T23:59:59Z"
13+
},
14+
"intentHash": "0x40522188d9c80bcf2336fb8f1f4ea7b1ec62ccfe619e76affc21d14d58a88597",
15+
"signature": {
16+
"note": "SCAFFOLD PLACEHOLDER — not a replayable signature. Replace with a real EIP-712 signature over the declared intent (packages/delivery replays consent and intent signatures when an EVM adapter is supplied).",
17+
"r": "0x0000000000000000000000000000000000000000000000000000000000000000",
18+
"s": "0x0000000000000000000000000000000000000000000000000000000000000000",
19+
"v": 27
20+
},
21+
"domain": { "name": "CoreGuard DDE Delivery Intent", "version": "1", "chainId": "1116" },
22+
"signedAtUtc": "2026-09-21T09:00:00Z",
23+
"authorityNote": "The client agent signs the delivery intent within the principal's mandate. This scaffold record is NOT signed — replace with a real signed authorization before production use.",
24+
"provenance": "SYNTHETIC — scaffold authorization generated by coreguard templates/integration-dde; signature fields are placeholders, not evidence of consent."
25+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"origin": "SYNTHETIC",
3+
"recordId": "DDE-SCAFFOLD-CONSENT",
4+
"chainId": "1116",
5+
"fixtureRef": "0x39be5794f5212933adbd6e6d6bad82ac475adbffb2944a7b4dc0ce94ce69efb8",
6+
"disclosure": {
7+
"origin": "SYNTHETIC",
8+
"realDisputeExists": false,
9+
"realTransactionAnchor": false,
10+
"realSignatures": false,
11+
"signatureMeaning": "SCAFFOLD: signature fields are deterministic placeholder values over the fixture's own keys — not replayable, not evidence that any real party consented. Replace with real EIP-712 signatures over your real parties.",
12+
"secretsRemoved": true,
13+
"personalDataRemoved": true,
14+
"peoplesCourtConsent": "none — inclusion of a People's Court mapping implies no endorsement, procedure, or agreement by People's Court / Epistemic Labs"
15+
},
16+
"redactionGrants": [
17+
{
18+
"grantor": "0x0000000000000000000000000000000000c1d001",
19+
"fixtureRef": "0x39be5794f5212933adbd6e6d6bad82ac475adbffb2944a7b4dc0ce94ce69efb8",
20+
"scope": "SCAFFOLD: review of this template fixture within its owning project; all parties are template placeholders; no secrets and no personal data are included.",
21+
"signature": {
22+
"note": "SCAFFOLD PLACEHOLDER — replace with a real EIP-712 RedactionGrant signature (packages/delivery redactionGrantDigest defines the typed data).",
23+
"r": "0x0000000000000000000000000000000000000000000000000000000000000000",
24+
"s": "0x0000000000000000000000000000000000000000000000000000000000000000",
25+
"v": 27
26+
}
27+
},
28+
{
29+
"grantor": "0x0000000000000000000000000000000000c1d004",
30+
"fixtureRef": "0x39be5794f5212933adbd6e6d6bad82ac475adbffb2944a7b4dc0ce94ce69efb8",
31+
"scope": "SCAFFOLD: review of this template fixture within its owning project; all parties are template placeholders; no secrets and no personal data are included.",
32+
"signature": {
33+
"note": "SCAFFOLD PLACEHOLDER — replace with a real EIP-712 RedactionGrant signature (packages/delivery redactionGrantDigest defines the typed data).",
34+
"r": "0x0000000000000000000000000000000000000000000000000000000000000000",
35+
"s": "0x0000000000000000000000000000000000000000000000000000000000000000",
36+
"v": 27
37+
}
38+
}
39+
],
40+
"provenance": "SYNTHETIC — scaffold consent record generated by coreguard templates/integration-dde; signature fields are placeholders, not evidence of consent."
41+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"origin": "SYNTHETIC",
3+
"recordId": "DDE-SCAFFOLD-DELIVERY",
4+
"deliveryId": "DDE-SCAFFOLD-DELIVERY",
5+
"agreementRef": "DDE-SCAFFOLD-AGREEMENT",
6+
"executionRef": "DDE-SCAFFOLD-EXEC",
7+
"submittedAtUtc": "2026-09-24T09:30:00Z",
8+
"submittedBy": "0x0000000000000000000000000000000000c1d003",
9+
"artifacts": [
10+
{
11+
"id": "scaffold-delivery.md",
12+
"content": "# CoreGuard DDE scaffold — delivery artifact\n\n## Status\n\nDelivered for schema exercise. Replace this artifact with your real deliverable.\n\n## Contents\n\n- This file is the single scaffold artifact of the DDE template fixture.\n- Its SHA-256 pin below is REAL over these exact bytes.\n- The DDE engine re-hashes this content on every verification (check E3).\n",
13+
"sha256": "0x3c9c19d5fd68e2e44c8b45876a91f4190940836e55faa062108d0f053c57f433",
14+
"bytes": 357
15+
}
16+
],
17+
"provenance": "SYNTHETIC — artifact content modeled for the scaffold scenario; SHA-256 pins are real over the exact embedded bytes (single hash definition: packages/delivery artifactSha256)."
18+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"origin": "SYNTHETIC",
3+
"recordId": "DDE-SCAFFOLD-DISPUTE",
4+
"disputeId": "DDE-SCAFFOLD-DISPUTE",
5+
"acceptanceRef": "DDE-SCAFFOLD-ACCEPTANCE",
6+
"openedAtUtc": "2026-09-24T17:00:00Z",
7+
"recordClosesAtUtc": "2026-10-01T17:00:00Z",
8+
"closedAtUtc": null,
9+
"partyA": {
10+
"role": "provider",
11+
"agentAddress": "0x0000000000000000000000000000000000c1d003",
12+
"position": "The delivered artifact matches the agreed scaffold scope; the quality criterion as authored rejects a valid scaffold delivery.",
13+
"requestedRemedy": "NONE"
14+
},
15+
"partyB": {
16+
"role": "client",
17+
"agentAddress": "0x0000000000000000000000000000000000c1d002",
18+
"position": "The artifact states schema-exercise status; the criterion as authored is not satisfied — replace with a real deliverable and real criteria.",
19+
"requestedRemedy": "REWORK"
20+
},
21+
"engineAdjudication": "NONE — the DDE engine names no winner; it preserves both positions and the closed evidence record.",
22+
"provenance": "SYNTHETIC — a modeled disagreement for scaffold exercise; no real dispute exists between any parties."
23+
}

0 commit comments

Comments
 (0)