KeiSeiKit-1.0/skills/compose-solution/phase-5-architecture.md
Parfii-bot 5c2dc98d54 feat(compose-solution): meta-orchestrator skill for 7-phase artefact creation
Adds a pure-click meta-composer that converts a free-text task description
into the right durable KeiSeiKit artefact — agent, skill, hook, rule, or
block — by composing existing primitives:

- Phase 1 intake (one free-text DESC + target-type click)
- Phase 2 wave-based decomposition (delegates to /research for heavy tasks)
- Phase 3 prior-art grep sweep across _blocks/, _manifests/, skills/,
  _bridges/, hooks/ + optional PROJECT-E + external docs
- Phase 4 gap analysis (AskUserQuestion multi-select)
- Phase 5 math-first architecture proposal (derive-first, "what is
  unnecessary" pass, Constructor-Pattern check)
- Phase 6 block augmentation — drafts + persists new _blocks/<slug>.md
  on user click; kit gets smarter each session
- Phase 7 recipe assembly — branches by type, hands off to /new-agent
  (agent) or /escalate-recurrence (hook / rule)

Split into SKILL.md (121-LOC index) + seven phase-*.md files (each <160
LOC) to stay under the 500-LOC/file Constructor-Pattern limit. Minimum 6
AskUserQuestion calls per session enforced by the pipeline; every
referenced block / skill / manifest / bridge path verified to exist on
disk before commit (RULE 0.4 — no fabricated references).

Writes only to _blocks/<slug>.md and skills/<slug>/SKILL.md;
handoffs to /new-agent and /escalate-recurrence own their own files.
2026-04-21 18:22:00 +08:00

2.3 KiB

Phase 5 — Architecture proposal (math-first)

Compose the architecture by following _blocks/rule-math-first.md.

5a — Expression first

One to three lines describing which primitives combine, in which order, with which invariants. Use this shape:

artefact = compose(block_A, block_B, ..., block_N)
where block_* ∈ {_blocks/, newly drafted, skills/, _manifests/}
invariant: <one-line, e.g. "every cube <200 LOC, every handoff verified">

5b — What is UNNECESSARY?

For each block listed, justify why it's in. If a block can be removed without losing the user's goal — remove it. Derive-first: explicit claim "this is the minimal decomposition, nothing removable". Follow the checklist from _blocks/rule-math-first.md:

  • Learned parameters / free knobs? WHY? Determined by input?
  • Separate blocks for similar concerns? WHY? Can a single block cover both?
  • Gate / wrapper layers? WHY? Is a direct reference enough?

5c — Constructor Pattern check

Each output cube must be single-concern, file < 200 LOC, function < 30 LOC. If the proposed assembly violates this, split before proceeding.

5d — Count

Show the numbers explicitly in the preview:

  • New files: N
  • Edits to existing files: M
  • Total lines of markdown to be written: L

5e — Preview + confirm

Preview as plain text in chat, then:

{
  "questions": [
    {
      "question": "Architecture OK?",
      "header": "Architecture",
      "multiSelect": false,
      "options": [
        {"label": "Confirm",              "description": "Proceed to Phase 6 block augmentation (if any gaps) then Phase 7 assembly"},
        {"label": "Revise component N",   "description": "One component's decomposition or reuse choice is wrong — reply with one free-text line"},
        {"label": "Remove something",     "description": "You see a block that's not strictly necessary — reply which one"},
        {"label": "Abort",                "description": "Stop — nothing gets written"}
      ]
    }
  ]
}

On Revise / Remove → ONE free-text prompt, regenerate the architecture, re-preview.

Verify-criterion

  • User clicked Confirm.
  • The expression (5a) is present and < 3 lines.
  • The "what is unnecessary" pass (5b) has been applied and is visible in the preview.
  • Constructor Pattern check (5c) passed.