Skip to content

Commit 584dd5f

Browse files
V48: Purge settle/delivery concept leaks from synthesis
Synthesis never passes settlementBoundary (even null) into reading telemetry/parity/rehearsal. Finish stores reviewUpload / reviewReadiness — never deliveryMechanism. Terminology: Settlement = BTD-BTC + system finalities; Delivery = settled read AssetPack PR ship; both settle-only.
1 parent 3596581 commit 584dd5f

13 files changed

Lines changed: 123 additions & 147 deletions

packages/api/src/routes/asset-pack-pipeline.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,11 +1041,11 @@ export const POST = traceRoute('/executions', async (request: NextRequest) => {
10411041
(execution as any).get?.('implementation', 'assetPackSynthesisArtifacts') ||
10421042
writtenAssets ||
10431043
undefined;
1044-
// Synthesis completion path: never project settleDelivery / settle PR.
1045-
// Buyer-repo settle surfaces come only from settle-asset-pack-pipeline runs.
1046-
const deliveryMechanism =
1047-
(execution as any).get?.('finish/asset_pack_completion', 'deliveryMechanism') ||
1044+
// Synthesis completion path: review readiness only — never Delivery/Settlement.
1045+
const reviewReadiness =
1046+
(execution as any).get?.('finish/asset_pack_completion', 'reviewReadiness') ||
10481047
undefined;
1048+
const deliveryMechanism = reviewReadiness; // legacy alias for older readers
10491049
const settleDelivery = undefined;
10501050
const read =
10511051
(execution as any).get?.('finish/asset_pack_completion', 'read') ||
Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,39 @@
1-
# Settlement / delivery ownership law
1+
# Settlement & Delivery ownership law
22

3-
## Exclusive owner
3+
## Exclusive definitions (settle-asset-pack-pipeline only)
44

5-
**`execution-pipeline-simple-settle-asset-pack`** (settle-asset-pack-pipeline) is the
6-
**only** product pipeline that may:
5+
| Term | Meaning | Owner |
6+
| --- | --- | --- |
7+
| **Settlement** | BTD–BTC payment observation + Bitcode System finalities (rights, ledger, read licenses) | **settle-asset-pack-pipeline only** |
8+
| **Delivery** | **Settled** Synthesized **Read** AssetPack(s) shipped as **buyer-repo PRs** | **settle-asset-pack-pipeline only** |
79

8-
- Observe BTC payment / finality
9-
- Build settlement rights / BTD unlock
10-
- Open or record buyer-repo **shippable** PRs
11-
- Emit **`settleDelivery`**, **`shippable`**, delivery unlock, settlement replay
10+
Neither word, nor their result surfaces (`settleDelivery`, `shippable`, delivery unlock, settlement rights boundary), may appear as synthesis algorithm outputs or Finish review-store names.
1211

1312
## Synthesis (deposit + read SDIVF)
1413

15-
`execution-pipeline-sdivf-synthesize-deposits-asset-packs` and
16-
`execution-pipeline-sdivf-synthesize-reads-asset-packs` (and shared synthesis
17-
postprocess/Finish) **must not**:
14+
**May** produce:
1815

19-
| Forbidden on synthesis | OK on synthesis |
20-
| --- | --- |
21-
| `settleDelivery` | `selectionEnvelope` / `options` |
22-
| `shippable` / buyer PR URL | `assetPackSynthesisArtifacts` |
23-
| Settlement rights delivery boundary | Source-safe **preview** / fee quote (selection UI) |
24-
| Delivery unlock after payment | `deliveryMechanismTemplate` (catalog only) |
25-
| Kind `settle_delivery` | Kind `deposit_options` / `read_options` / `asset_pack_synthesis` |
26-
27-
## Shared library modules
16+
- Selection envelopes / options for `/deposits` or `/reads`
17+
- Synthesis artifacts (`assetPackSynthesisArtifacts`, measurements, patches)
18+
- Source-safe **preview** + fee quote for selection UI
19+
- Finish **review upload** / **review readiness** (user review on Bitcode — not Delivery)
2820

29-
`asset-pack-settlement-rights-delivery.ts` (and related BTD/BTC statement helpers)
30-
live under `domain` as a **library** for the settle pipeline and host settle
31-
staging. They are **not** part of the synthesis algorithm.
21+
**Must not** produce or project:
3222

33-
- **May import:** settle pipeline, host settle path after purchase
34-
- **Must not import/call from:** synthesis preprocess, synthesis postprocess,
35-
deposit/read Finish agents, deposit/read phase runners
23+
| Forbidden | Why |
24+
| --- | --- |
25+
| `settlementBoundary` args (including `null`) on reading telemetry/parity/rehearsal | Even null is a concept leak into synthesis |
26+
| `settleDelivery`, `shippable`, PR URL | Delivery = settle only |
27+
| Settlement rights unlock / delivery unlock | Settlement + Delivery = settle only |
28+
| Finish fields named “delivery” for review upload | Use `reviewUpload` / `reviewReadiness` |
3629

3730
## Hand-off
3831

39-
Read synthesis finishes with options for `/reads` selection and
40-
`nextPipeline: settle-asset-pack-pipeline`.
41-
Deposit synthesis finishes with options for `/deposits` review.
42-
**A separate settle run** performs payment + delivery.
32+
1. **Deposit synthesis** → options for depositor review → (later) deposit admission
33+
2. **Read synthesis** → options for reader review → purchase → **separate settle run**
34+
3. **Settle run** → Settlement (BTD-BTC + system finalities) → Delivery (PR of settled read pack)
35+
36+
## Library modules
37+
38+
`asset-pack-settlement-rights-delivery.ts` remains under domain as a **settle-pipeline library**.
39+
Synthesis preprocess/postprocess/Finish must never call or project it.

packages/asset-packs-pipelines/domain/src/__tests__/deposit-agent-store-contract.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -501,11 +501,11 @@ describe('deposit agent context/store contract', () => {
501501
// The exact Finish store keys — on the SHARED execution (cross-phase law),
502502
// where postprocess and the run-level surfaces resolve them.
503503
expect(shared.get('finish', 'uploadForReview')).toMatchObject({
504-
deliveryMechanism: 'bitcode-review-upload',
504+
kind: 'bitcode-review-upload',
505505
review: { surface: '/deposits', reviewFor: 'deposit-admission' },
506506
options,
507507
});
508-
expect(shared.get('finish', 'deliveryMechanism')).toBe('bitcode-review-upload');
508+
expect(shared.get('finish', 'reviewUpload')).toBe('bitcode-review-upload');
509509
});
510510

511511
it('read mode: uploads the implementation synthesis artifacts for /reads purchase review', async () => {

packages/asset-packs-pipelines/domain/src/__tests__/finish-completion.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ describe('finish AssetPack completion evidence', () => {
3636
expect((result as any).shippable).toBeUndefined();
3737
expect((result.deliveryMechanism as any)?.pullRequest).toBeUndefined();
3838
expect(result.summary).toContain('octocat/Spoon-Knife');
39-
expect(result.deliveryMechanism?.readiness).toMatchObject({
39+
expect(result.reviewReadiness?.readiness).toMatchObject({
4040
status: 'pending-user-review',
4141
});
42-
expect(result.deliveryMechanism?.summary).toContain('octocat/Spoon-Knife');
42+
expect(result.reviewReadiness?.summary).toContain('octocat/Spoon-Knife');
4343
expect(result.assetPackSynthesisArtifacts?.summary).toContain('octocat/Spoon-Knife');
44+
expect((result as any).deliveryMechanism).toBeUndefined();
4445
});
4546

4647
it('ignores settle shippable on the EE — synthesis never emits settle surfaces', async () => {

packages/asset-packs-pipelines/domain/src/__tests__/finish-upload-for-review.test.ts

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
// @ts-nocheck
22
/**
3-
* Finish law (V48 Gate 3): BOTH synthesis modes finish by uploading the
4-
* synthesized AssetPack artifacts to Bitcode for USER review — deposit before
5-
* Depository admission, read before purchase. Opening a pull request is NOT
6-
* part of synthesis (PR/settlement delivery is reserved for the future Gate-6
7-
* SettleAssetPack pipeline).
8-
*
9-
* Pins the upload-for-review agent's behavior: mode-appropriate review surface,
10-
* 'bitcode-review-upload' delivery mechanism (never a PR shape), resolution of
11-
* the Implementation stores from ANCESTOR nodes (node-local get + ancestors-only
12-
* findUp), input spreading, and the finish stores it writes.
3+
* Finish: store synthesized artifacts for USER review (not Delivery).
4+
* Delivery = settle PR ship of settled read packs only.
135
*/
146
import { Execution } from '@bitcode/execution-generics';
157
import runUploadAssetPacksForReviewAgent from '../agents/finish/upload-asset-packs-for-review-agent';
@@ -21,47 +13,45 @@ const DEPOSIT_OPTIONS = [
2113
];
2214

2315
describe('upload-asset-packs-for-review Finish agent', () => {
24-
it('deposit: uploads the synthesized options for /deposits admission review (no PR fields)', async () => {
16+
it('deposit: stores synthesized options for /deposits review (no Delivery/PR)', async () => {
2517
const root = new Execution('pipeline:finish-upload-deposit');
2618
storeSynthesizeAssetPacksMode(root, 'deposit');
2719
root.store('implementation', 'options', DEPOSIT_OPTIONS);
2820
root.store('implementation', 'summary', 'Two measured deposit options.');
2921

30-
// Finish runs on a descendant node; the stores resolve via the upward walk.
3122
const finishNode = root.child('seq-3').child('seq-0');
3223
const input = { carried: 'from-validation' };
3324
const result = await runUploadAssetPacksForReviewAgent(input, finishNode);
3425

3526
expect(result).toMatchObject({
3627
success: true,
37-
carried: 'from-validation', // input is spread through
38-
deliveryMechanism: 'bitcode-review-upload',
28+
carried: 'from-validation',
29+
kind: 'bitcode-review-upload',
3930
review: {
4031
surface: '/deposits',
4132
reviewFor: 'deposit-admission',
4233
decision: 'pending-user-review',
4334
},
4435
options: DEPOSIT_OPTIONS,
4536
sourceSummary: 'Two measured deposit options.',
46-
summary: 'Synthesized AssetPacks uploaded to Bitcode for deposit review.',
37+
summary: 'Synthesized AssetPacks stored for deposit review on Bitcode.',
4738
});
4839

49-
// Never a pull-request shippable.
5040
expect(result).not.toHaveProperty('prUrl');
5141
expect(result).not.toHaveProperty('pullRequest');
42+
expect(result).not.toHaveProperty('deliveryMechanism');
43+
expect(result).not.toHaveProperty('settleDelivery');
5244

53-
// The upload is recorded on the SHARED (root) execution for downstream
54-
// completion (cross-phase store-visibility law) — the finish node still
55-
// resolves it via the upward walk.
5645
expect(root.get('finish', 'uploadForReview')).toMatchObject({
57-
deliveryMechanism: 'bitcode-review-upload',
46+
kind: 'bitcode-review-upload',
5847
review: { reviewFor: 'deposit-admission' },
5948
});
60-
expect(root.get('finish', 'deliveryMechanism')).toBe('bitcode-review-upload');
61-
expect(finishNode.findUp('finish', 'deliveryMechanism')).toBe('bitcode-review-upload');
49+
expect(root.get('finish', 'reviewUpload')).toBe('bitcode-review-upload');
50+
expect(finishNode.findUp('finish', 'reviewUpload')).toBe('bitcode-review-upload');
51+
expect(root.get('finish', 'deliveryMechanism')).toBeUndefined();
6252
});
6353

64-
it('read: uploads the synthesis artifacts for /reads purchase review', async () => {
54+
it('read: stores synthesis artifacts for /reads review (not Delivery)', async () => {
6555
const root = new Execution('pipeline:finish-upload-read');
6656
storeSynthesizeAssetPacksMode(root, 'read');
6757
const artifacts = {
@@ -73,15 +63,16 @@ describe('upload-asset-packs-for-review Finish agent', () => {
7363
const result = await runUploadAssetPacksForReviewAgent({}, root.child('seq-3'));
7464

7565
expect(result).toMatchObject({
76-
deliveryMechanism: 'bitcode-review-upload',
66+
kind: 'bitcode-review-upload',
7767
review: {
7868
surface: '/reads',
7969
reviewFor: 'purchase',
8070
decision: 'pending-user-review',
8171
},
8272
artifacts,
83-
summary: 'Synthesized AssetPacks uploaded to Bitcode for read review.',
73+
summary: 'Synthesized AssetPacks stored for read review on Bitcode.',
8474
});
75+
expect(result).not.toHaveProperty('deliveryMechanism');
8576
});
8677

8778
it('defaults to the read lens when no mode was stored', async () => {

packages/asset-packs-pipelines/domain/src/__tests__/upload-asset-packs-for-review.test.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ describe('runUploadAssetPacksForReviewAgent', () => {
3636
const result = await runUploadAssetPacksForReviewAgent({ runId: 'run-1' }, finishExec);
3737

3838
expect(result.success).toBe(true);
39-
expect(result.deliveryMechanism).toBe('bitcode-review-upload');
39+
expect(result.kind).toBe('bitcode-review-upload');
40+
expect(result).not.toHaveProperty('deliveryMechanism');
4041
expect(result.review).toEqual({
4142
surface: '/deposits',
4243
reviewFor: 'deposit-admission',
@@ -45,20 +46,20 @@ describe('runUploadAssetPacksForReviewAgent', () => {
4546
expect(result.options).toBe(OPTIONS); // the synthesized options ride in the upload record
4647
expect(result.assetPack).toEqual({ repository: { fullName: 'org/repo' } });
4748
expect(result.sourceSummary).toBe('Synthesized 1 measured deposit AssetPack patch(es).');
48-
expect(result.summary).toBe('Synthesized AssetPacks uploaded to Bitcode for deposit review.');
49+
expect(result.summary).toBe('Synthesized AssetPacks stored for deposit review on Bitcode.');
4950
// The runner spreads its input into its result (Finish output chain).
5051
expect(result.runId).toBe('run-1');
5152

5253
// Cross-phase law: the upload record is stored on the SHARED (root)
5354
// execution — where postprocess and the run-level surfaces resolve it —
5455
// not on the isolated Finish sibling.
5556
expect(outer.get('finish', 'uploadForReview')).toMatchObject({
56-
deliveryMechanism: 'bitcode-review-upload',
57+
kind: 'bitcode-review-upload',
5758
review: { surface: '/deposits', reviewFor: 'deposit-admission' },
5859
});
59-
expect(outer.get('finish', 'deliveryMechanism')).toBe('bitcode-review-upload');
60+
expect(outer.get('finish', 'reviewUpload')).toBe('bitcode-review-upload');
6061
// Still resolvable from the Finish subtree via the upward walk.
61-
expect(finishExec.findUp('finish', 'deliveryMechanism')).toBe('bitcode-review-upload');
62+
expect(finishExec.findUp('finish', 'reviewUpload')).toBe('bitcode-review-upload');
6263
});
6364

6465
it('read mode: uploads for /reads purchase review and carries the synthesis artifacts', async () => {
@@ -76,7 +77,8 @@ describe('runUploadAssetPacksForReviewAgent', () => {
7677
decision: 'pending-user-review',
7778
});
7879
expect(result.artifacts).toBe(artifacts);
79-
expect(result.summary).toBe('Synthesized AssetPacks uploaded to Bitcode for read review.');
80+
expect(result.kind).toBe('bitcode-review-upload');
81+
expect(result.summary).toBe('Synthesized AssetPacks stored for read review on Bitcode.');
8082
});
8183

8284
it('defaults to read review when no mode was stored', async () => {
@@ -105,7 +107,7 @@ describe('runUploadAssetPacksForReviewAgent', () => {
105107
}
106108
// The upload decision is the user's, pending — never an auto-opened PR.
107109
expect(stored.review.decision).toBe('pending-user-review');
108-
expect(outer.get('finish', 'deliveryMechanism')).toBe('bitcode-review-upload');
110+
expect(outer.get('finish', 'reviewUpload')).toBe('bitcode-review-upload');
109111
});
110112
});
111113

packages/asset-packs-pipelines/domain/src/agents/finish/asset-pack-completion-agent.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ const AssetPackSynthesisArtifactsSchema = WrittenAssetsSchema.extend({
2727
reviewNotes: z.array(z.string()).optional(),
2828
});
2929

30-
/** Review readiness only — no pullRequest (settle exclusive). */
31-
const DeliveryMechanismSchema = z.object({
30+
/** User-review readiness only — never pullRequest / delivery (settle exclusive). */
31+
const ReviewReadinessSchema = z.object({
3232
summary: z.string().nullable().optional(),
3333
readiness: z
3434
.object({
@@ -44,13 +44,13 @@ const DeliveryMechanismSchema = z.object({
4444
export const AssetPackCompletionOutputSchema = z.object({
4545
/**
4646
* Synthesis completion summary (markdown). Primary Finish evidence for SDIVF.
47-
* Settlement (settleDelivery / buyer PR) is exclusive to settle-asset-pack-pipeline
48-
* and is never authored or passed through by synthesis Finish.
47+
* Settlement = BTD-BTC + Bitcode System finalities (settle pipeline only).
48+
* Delivery = settled read AssetPack PR ship (settle pipeline only).
4949
*/
5050
summary: z.string().optional(),
5151
assetPackSynthesisArtifacts: AssetPackSynthesisArtifactsSchema.optional(),
5252
writtenAssets: WrittenAssetsSchema.optional(),
53-
deliveryMechanism: DeliveryMechanismSchema.optional(),
53+
reviewReadiness: ReviewReadinessSchema.optional(),
5454
read: z.string().optional(),
5555
writtenAssetType: z.string().optional(),
5656
processingStats: z.object({
@@ -100,7 +100,7 @@ const AssetPackCompletionAgent = factoryAgentWithSingleStep<any, AssetPackComple
100100
(execution as any).prompt?.setSpecificExecution(
101101
'specific_execution:output:shape',
102102
(
103-
'Output JSON with keys: summary, assetPackSynthesisArtifacts{fileChanges,summary,proofEvidence?,reviewNotes?}, writtenAssets{fileChanges,summary}, deliveryMechanism{summary,readiness}, processingStats{…}, repoSnapshot{org,repo,branch,commit}. Never settleDelivery / settlePassThrough / buyer-repo PR — those are settle-asset-pack-pipeline only. SDIVF Finish closes synthesis evidence only.'
103+
'Output JSON with keys: summary, assetPackSynthesisArtifacts{}, writtenAssets{}, reviewReadiness{summary,readiness}, processingStats{…}, repoSnapshot{}. Never settlement, delivery, settleDelivery, or buyer-repo PR — those are settle-asset-pack-pipeline only (BTD-BTC finality + PR ship of settled read packs).'
104104
) as unknown as PromptPart
105105
);
106106
} catch {}
@@ -223,8 +223,8 @@ const AssetPackCompletionAgent = factoryAgentWithSingleStep<any, AssetPackComple
223223
: {
224224
...writtenAssets,
225225
};
226-
// Review readiness only — never pullRequest / settleDelivery / shippable.
227-
const deliveryMechanism = {
226+
// User-review readiness only — never pullRequest / settleDelivery / shippable / Delivery.
227+
const reviewReadiness = {
228228
summary,
229229
readiness: deliveryReadiness,
230230
};
@@ -233,7 +233,7 @@ const AssetPackCompletionAgent = factoryAgentWithSingleStep<any, AssetPackComple
233233
summary,
234234
assetPackSynthesisArtifacts,
235235
writtenAssets,
236-
deliveryMechanism,
236+
reviewReadiness,
237237
read: read || undefined,
238238
writtenAssetType: dtype || undefined,
239239
processingStats,
@@ -246,7 +246,7 @@ const AssetPackCompletionAgent = factoryAgentWithSingleStep<any, AssetPackComple
246246
(execution as any).store?.('finish/asset_pack_completion', 'summary', summary as any);
247247
(execution as any).store?.('finish/asset_pack_completion', 'assetPackSynthesisArtifacts', assetPackSynthesisArtifacts as any);
248248
(execution as any).store?.('finish/asset_pack_completion', 'writtenAssets', writtenAssets as any);
249-
(execution as any).store?.('finish/asset_pack_completion', 'deliveryMechanism', deliveryMechanism as any);
249+
(execution as any).store?.('finish/asset_pack_completion', 'reviewReadiness', reviewReadiness as any);
250250
(execution as any).store?.('finish/asset_pack_completion', 'read', read || undefined);
251251
(execution as any).store?.('finish/asset_pack_completion', 'writtenAssetType', dtype || undefined);
252252
(execution as any).store?.('finish/asset_pack_completion', 'processingStats', processingStats as any);

packages/asset-packs-pipelines/domain/src/agents/finish/deposit-store-artifacts-agent.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,10 @@ export default async function runDepositStoreArtifactsAgent(input: any, executio
124124
};
125125

126126
storeCrossPhaseArtifact(execution, 'finish', 'storedArtifacts', artifactBundle);
127-
// Review-admission upload only — not SettleAssetPacks destination delivery
128-
// (PR/settlement deliver agents run during settlement procedures).
127+
// User-review store only — not Delivery (PR ship is settle-pipeline exclusive).
129128
storeCrossPhaseArtifact(execution, 'finish', 'uploadForReview', {
130129
success: true,
131-
deliveryMechanism: 'bitcode-review-upload',
130+
kind: 'bitcode-review-upload',
132131
review: {
133132
surface: '/deposits',
134133
reviewFor: 'deposit-admission',
@@ -138,7 +137,7 @@ export default async function runDepositStoreArtifactsAgent(input: any, executio
138137
artifacts: artifactBundle,
139138
summary: `Stored ${assetPacks.length} AssetPack artifact(s) for deposit review.`,
140139
});
141-
storeCrossPhaseArtifact(execution, 'finish', 'deliveryMechanism', 'bitcode-review-upload');
140+
storeCrossPhaseArtifact(execution, 'finish', 'reviewUpload', 'bitcode-review-upload');
142141

143142
// Durable write hook (Supabase / DB) — Host/dispatch injects deposit:persistArtifacts.
144143
let persistResult: { ok: boolean; mode: string; detail?: string } = {

0 commit comments

Comments
 (0)