12000x · 05 — Phase F · Template+Instance proof (shared piece graph, identical manifest digest)</title> <parameter name="tags">["iu-core","v0.6","12000x","phase-f","template-instance","piece-graph","manifest-digest","pass"]
12000x · 05 — Phase F · Template + Instance proof (shared piece graph)
Goal
Prove brief items #10 (process_template_as_piece_graph) and #11 (generate_instance_from_template) using existing primitives only. Treat Phase D workflow as the template, then ask fn_iu_compose to build a new collection that references the same 7 piece iu_ids in the same order under a new collection_key. No new piece minting; full lineage carried by iu_id identity.
SQL
WITH template AS (
SELECT id AS tpl_id, manifest_digest AS tpl_digest
FROM iu_piece_collection WHERE collection_key='iu_core.12000x.workflow.invoice-approval'
)
SELECT public.fn_iu_compose(
'iu_core.12000x.workflow.invoice-approval.instance-001','workflow',
'Invoice approval — Q2 2026 Acme Corp instance',
format('Instance generated from template_collection_id=%s template_digest=%s', tpl_id, tpl_digest),
(SELECT jsonb_agg(jsonb_build_object('role','step','iu_id', pm.iu_id) ORDER BY pm.piece_order)
FROM iu_piece_membership pm
WHERE pm.collection_id=template.tpl_id AND pm.membership_status='active'),
'iu-core-12000x')
FROM template;
This is the FIRST live production exerciser of fn_iu_compose's {iu_id:<uuid>} branch (vs the {new_piece:{…}} branch used in D/E).
Live response
{
"ok": true,
"collection_id": "7c1b58b4-98fd-4d61-b59c-52b690d624a8",
"pieces_minted": 0,
"collection_key": "iu_core.12000x.workflow.invoice-approval.instance-001",
"collection_kind": "workflow",
"minted_unit_ids": [],
"pieces_attached": 7
}
pieces_minted=0, pieces_attached=7 — exact contract.
F.1 — Instance row + lineage
| id | manifest_digest | description |
|---|---|---|
| 7c1b58b4-98fd-4d61-b59c-52b690d624a8 | 0d1da72850c71618a759cf08709f3825 | Instance generated from template_collection_id=84115abf-… digest=0d1da7… |
description carries lineage. 13000x candidate: promote to dedicated source_collection_id uuid FK + relation_kind text column.
F.2 — Instance validates
{"ok": true, "errors": [], "warnings": [], "piece_count": 7}
F.3 — Instance render byte-equivalent to template
| piece_order | piece_role | canonical_address |
|---|---|---|
| 0..6 | step | iu_core/12000x/wf/invoice/01-receive .. 07-notify |
F.4 — Piece-graph identity (headline)
| tpl_pieces | inst_pieces | shared_pieces | tpl_only | inst_only |
|---|---|---|---|---|
| 7 | 7 | 7 | 0 | 0 |
Set-theoretic identity: every template piece is in the instance and vice versa, ZERO divergence. The instance is not a copy — it is a second view onto the same DAG.
F.5 — Template digest = Instance digest (the formal proof)
template_digest = 0d1da72850c71618a759cf08709f3825
instance_digest = 0d1da72850c71618a759cf08709f3825
Formal proof that pieces are the primitive design unit. The manifest digest is computed over the piece graph (ordered iu_ids + roles + collection_kind), not over the collection's identity, key, title, or description. Two collections with the same piece graph share the same digest. Downstream consumers (Qdrant indexer, text-as-code exporter, audit-ledger anchor) see them as the same content artefact regardless of access path.
F.6 — v_iu_collection_manifest cross-section
14 rows total (7 per collection); each row references the same iu_id set under two different collection_keys.
Pass criteria
- Instance fn_iu_compose accepted the {iu_id:<uuid>} branch
- pieces_minted=0 (no duplication) and pieces_attached=7
- Instance validates ok
- Instance renders byte-equivalent to template
- Set-identity: shared=7, tpl_only=0, inst_only=0
- Template digest = Instance digest (0d1da72850c71618a759cf08709f3825)
- Description carries template_collection_id lineage
- Post-ROLLBACK: zero leftover collections
PHASE F PASS — Template/Instance Product Factory pattern proven without new substrate.
Carry-forward (13000x candidate)
Promote description lineage to dedicated source_collection_id uuid FK + optional relation_kind text column (instance_of, forked_from, derivative_of). Author-mode only; not blocking this PASS.