12000x · 09 — Lessons + carry-forward (5 lessons; 9 carry-forward items; 3 memory entries proposed)</title> <parameter name="tags">["iu-core","v0.6","12000x","lessons","carry-forward","13000x-roadmap","memory-candidates"]
12000x · 09 — Lessons + carry-forward
Lessons (new this macro)
L1 — Live discovery before authoring is non-negotiable
The 11000x brief said five Product Factory primitives "remain to implement" and listed them as 12000x work. Live discovery in dot_iu_command_catalog, pg_proc, and cutter_agent/iu_core/*.py showed THE SUBSTRATE IS ALREADY SHIPPED. Running the brief verbatim would have produced redundant code that fights existing FK/CHECK invariants.
Rule: read \df, \d, dot_iu_command_catalog, and the Python module surface BEFORE drafting a migration. The brief is a hypothesis, not ground truth.
L2 — In-tx gate-toggle is a clean reversibility pattern
The composer (iu_core.composer_enabled) and event-emit (piece_event_runtime.emit_enabled) gates default to false in production. Inside BEGIN/ROLLBACK, UPDATE dot_config SET value='true' WHERE key=… flips them for the duration of the TX and the ROLLBACK reverts the row, leaving durable state untouched.
Rule: use the gate-toggle-in-tx pattern when a brief says "exercise the substrate without affecting production." Pair it with post-rollback durability check on the affected tables AND on the gate values themselves.
L3 — fn_iu_compose already supports both branches: {new_piece:{…}} and {iu_id:<uuid>}
11000x docs emphasized the new_piece branch (mint+attach). The iu_id branch (reuse-existing) was inside the same function body but had no live exerciser. Phase F is the first production-shape proof — it is the mechanism for generate_instance_from_template.
Rule: don't write a new "instance" function. Use the existing iu_id branch — already governed by composer gate + birth-gate + manifest-refresh pipeline.
L4 — Manifest digest is keyed on the piece graph
Phase F headline: template digest = instance digest. The hash function ignores collection_key, title, description. Two collections with the same (piece_order, iu_id, piece_role, collection_kind) sequence are IDENTICAL content artefacts by digest, even if they belong to different business products.
Rule: when indexing collections downstream (Qdrant, audit, text-as-code ledger), key on manifest_digest to dedupe across instances; key on collection_key to distinguish business identity. Both, not either.
L5 — Birth gate L1 PILOT-ONLY warnings are pre-existing noise
fn_iu_birth_gate_layer1 emits "P-pub1/P-pub2 missing — production sẽ BLOCK" warnings on every design_doc_section IU create. Function still returns; IU is created. Not 12000x defects but they pollute transcripts (14 emissions in Phase D alone).
Rule: triage in 13000x — either silence under a "pilot OK" config or replace with a single summary line per macro. Not blocking this PASS.
Carry-forward to 13000x
Substrate (author-mode candidates, not blockers)
- iu_piece_collection.source_collection_id uuid FK + relation_kind text — promote description-based template lineage proven in Phase F to a queryable FK.
- source_axis_kind += 'instance' — distinguish in-place compositions from template-derived ones.
- Manifest-digest-keyed text-as-code ledger —
iu_collection_text_as_code_anchor(manifest_digest text PK, latest_path, first_seen_at, last_seen_at)so byte-identical roundtrip (Phase 07) becomes durably indexable.
Execution proofs (gated)
- End-to-end durable apply of propose_collection_import result — currently APPLY_IS_DESTRUCTIVE=False; build durable applier behind a third gate (text_as_code.apply_enabled=false default).
- Live mode for piece events — piece_event_runtime.dry_run_only=false in bounded BEGIN/ROLLBACK to confirm delivery seam carries actual piece events past in-tx outbox.
- Mac-host PILOT-noise triage — see L5.
Constitution-preserving operations
- PR #669 merge — owned by frontend/DevOps; do not merge from a macro.
- Retention enable — earliest eligible ~2026-06-22 (see feedback_authority_discovery_real_verify).
- Nuxt deploy — owned externally.
Carry-forward to AgentData memory layer
Three new memory entries proposed:
- feedback_in_tx_gate_toggle_reversibility — pattern from L2.
- feedback_manifest_digest_keyed_on_piece_graph — property from L4.
- feedback_compose_iu_id_branch_is_instance_mechanism — L3.
Cross-references
- 11000x baseline: [[project_dot_iu_cutter_v0_6_iu_core_11000x_piece_event_runtime_product_factory]]
- 10000x defect re-verified by live INSERT round-trip (G.F): [[feedback_event_outbox_check_vs_registry_drift]]
- Trigger-over-fn-rewrite design respected: [[feedback_trigger_emit_over_fn_rewrite]]
- Healthcheck SQL parity rule: [[feedback_healthcheck_sql_must_match_db_check]]