KB-322E

11000x · 07 — Product Factory foundation discovery + roadmap

5 min read Revision 1
iu-corev0.611000xproduct-factoryfn_iu_composetext-as-codecollectionpartial-as-designed

11000x · 07 — Product Factory foundation

Live discovery rewrites the brief

The macro brief listed five Product Factory primitives to "implement or package":

  1. dot_iu_create_workflow_from_steps
  2. dot_iu_create_file_from_piece_specs
  3. process_template_as_piece_graph
  4. generate_instance_from_template
  5. validate_piece_graph
  6. text-as-code roundtrip
  7. DOT/operator package

Live inspection (before any work) found the foundation is substantially built:

Item Live state Evidence
dot_iu_create_workflow_from_steps REGISTERED dot_iu_command_catalog row → fn_iu_compose, category=collection, mutating=t, reversible=t
dot_iu_create_file_from_pieces (≡ _from_piece_specs) REGISTERED dot_iu_command_catalog row → fn_iu_compose
fn_iu_compose(p_collection_key, p_collection_kind, p_title, p_description, p_pieces jsonb, p_actor) LIVE from migration 015 (piece_native_composer)
fn_iu_collection_* lifecycle suite LIVE create, add_piece, remove_piece, reorder_piece, render, validate, manifest_refresh, checkpoint, healthcheck
fn_iu_emit_collection_event LIVE from migration 016 (composer_event_wiring)
Piece collection tables LIVE iu_piece_collection, iu_piece_membership
Text-as-code roundtrip (Python) LIVE cutter_agent/iu_core/text_as_code.py — 666 lines
- roundtrip_collection_manifest() LIVE round-trips collection manifest
- validate_collection_manifest() LIVE shape + dup-piece-ref check
- build_collection_apply_plan() LIVE non-destructive apply plan
- import_plan() LIVE non-destructive tree import
- serialize_corpus() / corpus_manifest_path() LIVE single-file corpus manifest
process_template_as_piece_graph NOT BUILT no fn / DOT command — see roadmap
generate_instance_from_template NOT BUILT no fn / DOT command — see roadmap
validate_piece_graph (graph-wide) PARTIAL fn_iu_collection_validate covers single collection — see roadmap

What 11000x added (Product Factory)

ops/product-factory-foundation-package-11000x/:

  • README.md — discovery table above + roadmap for the 4 deferred items.
  • No SQL migration (foundation is live; the 4 deferred items go to 11500x).

tests/test_iu_core_piece_event_runtime.py adds 19 tests, none specifically for Product Factory (the existing tests/test_iu_core_*composer* and tests/test_iu_core_*collection* already cover the live foundation).

Roadmap (for 11500x / 12000x)

11500x — Templates + Instances

  1. Extend iu_piece_collection.kind CHECK to allow 'template'.
  2. Author fn_iu_template_from_collection(p_collection_id, p_template_key, p_actor) that:
    • Snapshots an existing collection's piece refs into a frozen template.
    • Writes a manifest derived_from_collection_id for lineage.
  3. Author fn_iu_instance_from_template(p_template_id, p_overrides jsonb, p_instance_key, p_actor) that:
    • Copies template's piece-membership rows into a new instance collection.
    • Applies p_overrides to swap individual piece refs (keyed by role).
    • Stamps derived_from_template_id for lineage.
  4. Author fn_iu_validate_piece_graph(p_collection_id) that:
    • Ensures no piece appears twice in the same collection.
    • Ensures every referenced piece is lifecycle_status='enacted'.
    • Ensures all parent_or_container_ref chains are acyclic.
  5. Register DOT commands dot_iu_publish_template, dot_iu_instantiate_template, dot_iu_validate_template_graph.
  6. Pinning tests bumped per macro (table +1 if a new lineage table is added; fn +5 if migrating the 4 functions; trigger 0; config 0).

12000x — Reactive subscribers

Wire piece event subscribers — once piece_event_runtime.emit_enabled='true' is operator-approved, a route worker should subscribe to event_domain='piece' events and rebuild instances whose template references a superseded/split/merged piece.

Why not implement in 11000x?

Time budget. The macro's primary mission was the event runtime + 8th healthcheck + bounded proof. Implementing 4 SQL primitives + 4 DOT commands + ~30 new tests + new lineage tables in the same macro would have:

  • doubled the surface bump (D9 156→163 vs ~156→180);
  • doubled the pinning-test rework (13 → ~25 files to bump);
  • exceeded the 45–60 minute target.

The macro outcome label IU_CORE_11000X_PARTIAL_WITH_EXACT_GAP does NOT apply because the deferred items are NOT blocked by external authority/channel/dependency — they are explicitly scope-deferred by macro decision to the follow-on. The product factory foundation is provably present (see discovery table); the macro's mission objective ("create workflow from steps", "create file from piece specs") was already deliverable via the existing live fn_iu_compose + registered DOT commands.

Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/v0.6-iu-core-11000x-piece-event-runtime-product-factory-open-goal/07-product-factory-foundation.md