Skip to content

feat(model-matrix): content-agent model selection via .uf/model-matrix.yaml - #894

Merged
jflowers merged 40 commits into
unbound-force:mainfrom
jflowers:opsx/model-matrix-delegation
Nov 1, 2026
Merged

jflowers merged 40 commits into
unbound-force:mainfrom
jflowers:opsx/model-matrix-delegation

Conversation

@jflowers

@jflowers jflowers commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Capability-driven model selection for uf_delegate_command (issue #887), delivered as the repo-first slice of the model-matrix deployment:

  • Model matrix config pair — a tracked .uf/model-matrix.yaml declaring capability-named profiles (spec-authoring, code-writing, content-writing, mechanical), a packs: mapping (UF convention pack → capability), defaults: by task kind, agents: pins, and classifier: structure — model strings optional everywhere. A gitignored .uf/model-matrix.override.yaml carries per-developer model identities through a fail-closed whitelist (profiles.*.model, profiles.*.variant, classifier.llm.* only), mirroring the review-matrix pattern.
  • Deterministic selection precedence — uf_delegate_command gains model/variant, profile, and pack parameters resolved through a fixed chain: explicit model → explicit profile → explicit pack (validated) → agents: pin → static defaults: by task kind → classifier cascade → host model. A matrix-resolved model skips host introspection entirely; with no matrix present, delegation behaves exactly as before.
  • Classifier cascade — for implement and unknown task kinds: a hidden investigate-then-decide subagent engine, then an LLM engine (temperature 0, JSON response format, {env:VAR} apiKey interpolation, endpoint config only in the gitignored override), confidence-gated and cached by input hash — every failure mode falls back statically without blocking delegation.
  • Pack directive double duty — an explicit or classifier-selected pack both selects the model and renders the tool-authored directive to load .opencode/uf/packs/<pack>.md in the child prompt (golden-shape tested, fixed position).
  • Selection audit trail — every delegation records selection_source, resolved pack/capability/model, and classifier confidence in the success envelope and checkpoint data.
  • Meta-prompt convention pack (UF convention pack: meta-prompt authoring rules for spec/plan/tasks/command work (model-matrix-delegation) #888) — new .opencode/uf/packs/meta-prompt.md codifying spec/plan/tasks/command authoring conventions (MP-NNN rules).
  • Scaffold mirrors — the model-matrix.ts lib module, tracked matrix template, JSON-Schema registry (schemas/model-matrix/ + .uf/schemas/model-matrix/ + embedded copies), and the updated uf-workflow plugin and uf.unleash.md command mirrored byte-identical under internal/scaffold/assets/ with drift enforcement; the override file added to the managed gitignore block.
  • Docs — docs/configuration.md "Delegation Model Matrix" section, CHANGELOG entry with verification footer, AGENTS.md structural updates; documentation issues filed (repo docs: capability-driven delegation model selection (model-matrix-delegation) #893, website fix(speckit.specify): dirty-tree check before branch creation is prose only #358 per the Cross-Repo Documentation rule).

Hero-repo deployment via uf init (#889) is slice 2 and out of scope.

Closes #887
Closes #888
Closes #893

⚠️ Behind base: this branch is 6 commits behind main (the reviewer-capabilities-init-survival change, 7aea931e..1459ce4e). No rebase was performed; rebase before merge if branch protection requires an up-to-date branch.

How to Test

Both commands were green locally at verification commit 7611aef (Phase 8 gate):

make check        # golangci-lint, go test -race, build, coverage-gate, scaffold drift tests
make plugin-test  # .opencode/ plugin suite

make check exit 0; make plugin-test exit 0 — 1,645 tests passing across 50 files, 95.76% statements coverage against the 94% floor (model-matrix.ts at 99.76%).

Acceptance criteria AC1–AC10 from issue #887, each carrying a cited proof (recorded in the Phase 8 checkpoint):

  • AC1 — non-host model delegation: model-matrix-integration.test.ts:437 runs a delegated task on a non-host model configured via matrix + override (mocked child session).
  • AC2 — task-kind routing: plan/tasks resolve statically to spec-authoring (classifier never invoked); implement/unknown kinds reach the classifier cascade with static fallback (integration :478, :498, :534; unit model-matrix.test.ts:964, :1122).
  • AC3 — precedence overrides: explicit model wins (pack retained), profile beats pack, pack resolves through its mapped profile (integration :561, :595, :626; unit :818, :950).
  • AC4 — zero-config unchanged: missing matrix keeps today's behavior — host model, no classifier, no errors; host path preserves pre-change structural-failure semantics (integration :650, :863; unit :605).
  • AC5 — override whitelist: a non-whitelisted override key fails closed naming the whitelist, pre-spawn (integration :678; unit :327–:397).
  • AC6 — pack directive golden shape: exact rendering, fixed position, skill+pack coexistence order (integration :705).
  • AC7 — classifier never blocks: failed engine, timeout, below-threshold, and matrix-invalid pack all fall back statically with the reason recorded in the audit trail (integration :742, :770, :806, :823).
  • AC8 — audit trail: every resolveSelection path records selection_source (8-value enum; zero-config records host), landing in checkpoint data exactly as documented (integration :1039).
  • AC9 — gates green: make check exit 0; make plugin-test exit 0 with statements coverage at/above the 94% floor.
  • AC10 — docs: docs/configuration.md "Delegation Model Matrix" section (commit 46bf0fcc) and CHANGELOG entry under Unreleased → Added (commit ee1c0480).

How to Demo

  1. Add a gitignored .uf/model-matrix.override.yaml pinning profiles.spec-authoring.model to a provider/model identity you have credentials for.
  2. Run /uf.unleash on an OpenSpec branch and let it reach a plan or tasks step.
  3. The delegated child session runs on the matrix-selected model, and the delegation success envelope records selection_source: "default-kind" with the resolved pack/capability/model (also visible in the step's checkpoint data).

Key Files Changed

80 files, +13,338 / −161.

Core feature

  • .opencode/lib/model-matrix.ts (+1,736) — closed v1 schema, tristate loader, override whitelist/merge, resolveSelection precedence chain
  • .opencode/plugins/uf-workflow/index.ts (+519) — uf_delegate_command model/profile/pack parameters, selection, audit trail
  • .opencode/agents/model-matrix-classifier.md (+56) — hidden investigate-then-decide classifier subagent
  • .uf/model-matrix.yaml (+46), .gitignore — tracked starter matrix; gitignored per-developer override entry

Convention pack (#888)

  • .opencode/uf/packs/meta-prompt.md (+243) — MP-NNN spec/plan/tasks/command authoring conventions

Schema registry

  • schemas/model-matrix/ and .uf/schemas/model-matrix/ — v1.schema.json (+156), README (+125), 10 sample fixtures across valid/invalid families

Scaffold mirrors (drift-enforced)

  • internal/scaffold/assets/opencode/lib/model-matrix.ts, .../plugins/uf-workflow/index.ts, .../commands/uf.unleash.md, internal/scaffold/assets/uf/model-matrix.yaml, .../uf/schemas/model-matrix/v1.schema.json
  • internal/scaffold/scaffold.go, internal/scaffold/plugin_activation.go, internal/scaffold/scaffold_test.go (drift registration)

Tests (~3,900 lines)

  • .opencode/test/model-matrix.test.ts (+1,224), model-matrix-integration.test.ts (+1,127), model-matrix-classifier.test.ts (+930), model-matrix-schema.test.ts (+275), model-matrix-tracked.test.ts (+249), yaml-subset.test.ts (+74)
  • Helpers: .opencode/test/helpers/json-schema-subset.ts (+201), yaml-subset.ts (+123)

Docs & workflow artifacts

  • docs/configuration.md (+145) — "Delegation Model Matrix" section
  • CHANGELOG.md (+82), AGENTS.md, .opencode/commands/uf.unleash.md — model-selection guidance (UF-FR-001)
  • openspec/changes/model-matrix-delegation/ — proposal, design, spec deltas (model-matrix, scaffold, unleash), tasks (35/35 complete)
  • .uf/dewey/learnings/ — 16 workflow learnings (spec review, code review, retrospective)

Known Issues

Code review returned APPROVE WITH ADVISORIES (iteration 1, correlation 361f7b6b) — 9 non-blocking advisories, accepted with rationale:

  • [MEDIUM] Schema drift enforcement covers one of three copy edges — the embedded asset is drift-mapped to the .uf mirror but not to the root schemas/model-matrix/ registry edge that MM-FR-008's byte-identical wording implies.
  • [LOW] validateLlmEndpoint userinfo echoing — https-or-loopback scheme rule enforced, but userinfo-bearing URLs pass and the credential-bearing string can be echoed in validator error messages.
  • [LOW] Residual classifier prompt-injection surface — documented per the adversarial-input enumeration duty; a crafted spec/task text can bias classification, bounded by static fallback.
  • [LOW] specs/unleash/spec.md delta heading order — MODIFIED before ADDED; consistency deviation from the repo-wide ADDED → MODIFIED → REMOVED order (MP-013 does not mandate order).
  • [LOW] Agent-count claims don't reconcile — AGENTS.md "17 active" vs 16 non-hidden + 1 hidden agent; README says "18 agents".
  • [LOW] DelegateCommandData.selection_pack docstring — lists a nonexistent "profile's pack" source category.
  • [LOW] Fixture-family verdict tests — iterate fixture families without asserting non-emptiness (vacuous-pass risk if a family's only fixture is removed).
  • [LOW] meta-prompt.md pack is structurally unvalidated — name-skipped in pack validation, not scaffold-embedded, and the AGENTS.md-listing-vs-directory invariant is unpinned.
  • [LOW] Production Bun.YAML parse path unexercised — the suite runs through the fail-closed yaml-subset helper, Zod surface, and JSON Schema; the real runtime parser is covered only by that mitigation chain.

Spec review: APPROVE WITH ADVISORIES after 4 iterations (iteration-2/3 findings addressed in d5362dee and d0dccff0).


This PR was generated by /uf.finale (AI-assisted).

@jflowers jflowers left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Council Review: APPROVE WITH ADVISORIES

5/5 Divisor reviewers (adversary/heavy, architect, curator, guard, testing) return APPROVE WITH ADVISORIES on ee69f8de. CI is fully green at the head (11 pass, 6 condition-expected skips, 0 fail). Pre-flight: PASS — all local tools covered by passing CI.

Findings: 10 (1 MEDIUM, 9 LOW) — all non-blocking. The security design is layered and fail-closed (env-only apiKey interpolation, tracked-file credential rejection, closed-schema re-validation, bounded classifier injection surface). Zero-config delegation is preserved verbatim, and the scaffold mirrors are drift-enforced.

The strongest advisory is a test coverage gap: profile-carried variant propagation (profiles.*.variant → SelectionResult.variant → child-session variant) has no end-to-end assertion, so a silent regression would keep the suite green. The remaining advisories cover documentation precision (the pack ride-along rule in the precedence chain, resolved_parent_model semantics), convention-pack DRY extraction (model/variant regex triplicated, YAML parser stub quadruplicated), two residual-bounded classifier surfaces, and two further seam/fallthrough test rows.

Note: the branch is 6 commits behind main; rebase before merge if branch protection requires an up-to-date branch.

Dispatch artifact: .uf/artifacts/dispatch/54d34fed-263d-4d25-bb44-37e686f6992c.json (correlation 54d34fed).

This review was generated by /uf.review-pr (AI-assisted).

})
})

describe("resolveSelection precedence chain (MM-FR-003/MM-FR-004, design D2)", () => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MEDIUM] Profile-carried variant propagation has no test coverage (divisor-testing)

profiles.*.variant flows through three handoffs — capabilitySelection (lib :755), attemptClassifierSelection (lib :810), and the plugin's childVariant = selection.variant ?? undefined — yet no test asserts it. Every resolveSelection fixture uses variant-less profiles, and the only spawn-level variant assertion (AC3, variant: "fast") covers the explicit input path. A regression dropping profile.variant in capabilitySelection would be silent: the child runs without the configured variant while the entire suite stays green. Fix: unit rows with a variant-carrying profile through the explicit-profile/pack/agent-pin/default-kind/classifier paths (asserting selection.variant), plus one integration row where the override supplies profiles.code-writing.variant asserted at the spawn seam.

* @returns The parsed endpoint URL.
* @throws When the endpoint is not a valid URL or violates the scheme rule.
*/
function validateLlmEndpoint(endpoint: string): URL {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[LOW] validateLlmEndpoint error messages echo the raw endpoint string (divisor-adversary)

A credential-bearing URL (https://user:[email protected]/v1/chat/completions) that fails validation flows into the LLM engine's failure reason, then into SelectionResult.fallback_reason, which the uf-workflow plugin persists in checkpoint data and the delegation success envelope. Exposure is bounded — the endpoint is developer-configured in a gitignored file, the echo occurs only when validation fails (the endpoint is never used), and classifier.llm.apiKey is separately restricted to {env:VAR} interpolation with no value echo. Recommendation: sanitize before echoing — log url.origin + url.pathname, or strip url.username/url.password from the interpolated string.

.min(3)
.max(256)
.regex(
/^[A-Za-z0-9][A-Za-z0-9._-]*\/[A-Za-z0-9][A-Za-z0-9._@-]*(?:\/[A-Za-z0-9][A-Za-z0-9._@-]*)*$/,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[LOW] Provider/model identity regex triplicated across three modules (divisor-architect, CS-004)

The regex and its companion variant regex now exist in agent-executor.ts (pre-existing ModelSchema/VariantSchema), model-matrix.ts (ProfileModelSchema/ProfileVariantSchema), and DelegateCommandInputSchema here. default.md CS-004 [MUST] requires extraction when identical logic appears in more than two locations. The coupling is documented in prose but not enforced mechanically. Recommendation: export the pattern or schemas from a single module and reference it in the others, or add a cross-shape equality test. Non-blocking: bounded duplication with documented rationale.

and #888) and the cross-repo `unbound-force/website`
documentation issue (org constitution v1.4.0 Cross-Repo
Documentation rule; task 7.5).
- **Content coverage**: the model matrix is a configuration

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[LOW] Content-coverage disposition lacks a slice-2 re-evaluation trigger (divisor-curator)

The disposition recorded here — blog below threshold, tutorial satisfied by the docs/configuration.md reference — is scoped to the repo-first slice and names no re-evaluation point for slice 2 (#889, hero-repo deployment via uf init). Deploying the matrix and meta-prompt pack into every uf init-scaffolded hero repo expands the audience from this repository's operators to all uf consumers, which reopens the blog/tutorial significance thresholds. Consider naming slice 2 as the explicit trigger so the threshold question does not silently transfer to that change's own review.

Comment thread docs/configuration.md
1. explicit `model` parameter
2. explicit `profile` (capability) parameter
3. explicit `pack` parameter (validated: the pack file exists AND
has a matrix entry; the pack also renders a tool-generated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[LOW] Precedence docs omit the pack ride-along rule from MM-FR-003 (divisor-guard)

The precedence list documents seven first-match-wins steps but never states that a validated explicit pack still renders its tool-generated directive even when a higher-precedence model or profile parameter supplies the child model ("never silently dropped"). A reader could reasonably conclude that passing model together with pack ignores the pack — the opposite of the implemented, spec-mandated, and tested behavior. One sentence in this section (and optionally the model/pack parameter descriptions) closes the gap.

* empty documents parse to null; everything else is JSON (a superset of the
* YAML the fixtures use, matching the review-dispatch test convention).
*/
function testParser(text: string): unknown {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[LOW] JSON-backed YAML parser stub duplicated across four test files (divisor-testing, CS-004)

The stub (comment-stripping emptiness check + JSON.parse) appears in model-matrix.test.ts (testParser), model-matrix-classifier.test.ts, model-matrix-integration.test.ts (testParseYaml), and unleash-delegate.test.ts (testParseYaml), exceeding CS-004's "more than two locations MUST extract" rule. The stub is a pure function with no shared state, so extraction to .opencode/test/helpers/ (alongside yaml-subset.ts) preserves the isolation convention. The copies already drift: model-matrix.test.ts carries an undefined-variance parser row the others lack. Either extract a shared helper or record the per-file-stub exemption centrally in the convention pack.

* @param packs The sorted candidate pack names.
* @returns The spawn prompt text.
*/
function renderAgentEnginePrompt(request: ClassifierRequest, packs: readonly string[]): string {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[LOW] Residual prompt-injection surface in classifier engine prompts (divisor-adversary)

renderAgentEnginePrompt (:1503) and renderLlmEnginePrompt (:1526) embed the delegated task text verbatim, so instruction text embedded in a task can compete with the classification instruction and steer pack selection. Defense-in-depth is present: closed Zod response schema (PackName pattern, confidence 0.0-1.0), INVALID_PACK gate against matrix packs keys, 0.6 confidence threshold, hidden read-only subagent, and output confined to configured models/packs — never file paths, shell commands, or security-relevant flags. Recommendation: delimit the task text as untrusted data within the engine prompts (data/instruction separation) to shrink the surface further.

resolved_parent_variant: host.variant ?? null,
requested_model: input.model ?? null,
requested_variant: input.variant ?? null,
resolved_parent_model: childModel.combined,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[LOW] resolved_parent_model carries the child-run model without an interface doc update (divisor-architect)

For matrix- or explicitly-resolved selections, this assignment writes the model the child session runs on into resolved_parent_model/resolved_parent_variant, while the field name — and the unchanged InvocationProvenance documentation in agent-executor.ts — describes the parent session's resolved model. The call-site comment documents the new semantics (design D7) and selection_model carries the authoritative value, but a generic consumer of InvocationProvenance (HIC artifact tooling, model_mismatch logic) would misinterpret the field on these calls. Recommendation: update the InvocationProvenance JSDoc to state the delegate-tool semantics, or introduce resolved_child_model in a follow-up change.

}
})

it("should resolve plan and tasks statically, never consulting the classifier", () => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[LOW] resolveSelection step-5 fallthrough (defaults-less plan/tasks) has no test row (divisor-testing)

Plan/tasks checkpoint steps with a configured matrix whose defaults section lacks the kind (or is absent) resolve to hostSelection(null, null, null), but the plan/tasks tests use selectionMatrix, which carries defaults; the no-defaults host fallthrough is tested only via the deploy/step-6 path and the zero-params rows (identical return shape, different guard). A regression in the fallthrough would surface only in production. One row closes it: a minimal matrix without defaults + checkpoint_step: "plan" (and "tasks") → selection_source: "host", model null, fallback_reason null.

* D5, MM-FR-005): runs the hidden model-matrix-classifier subagent through
* the shared executeAgentSession session path with the invocation's
* parent-session context. The classifier child inherits the session model
* hierarchy — the spawn resolves the host model for its own child session,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[LOW] Production spawnClassifierAgentSession glue never executed by tests (divisor-testing)

The parent-session-context binding to resolveHostModel, the executeAgentSession invocation with the read-only provenance block, and the non-success → rejecting error envelope are only reached through the ModelMatrixSelectionDependencies.spawnClassifierAgent seam, which every test fakes. Unlike the accepted Bun.YAML-parse-path advisory, this function is Node-compatible and testable with the existing integration fakeClient harness. A wiring bug (e.g., wrong sessionID passed to resolveHostModel) would degrade silently — the classifier would always fall back to the static default while the suite stays green. One test invoking the real function through the fake client (success path; non-success rejection with the status-naming envelope) closes the gap.

Proposal, design (D1-D11), tasks (8 phases), and spec deltas
(model-matrix MM-FR-001..008, unleash MODIFIED + UF-FR-001,
scaffold SC-FR-007) for capability-driven model selection via
.uf/model-matrix.yaml. Originating issue unbound-force#887. Spec review:
APPROVE WITH ADVISORIES (correlation b64e86a8).
Task 1.1 of the model-matrix-delegation change. MP-NNN rule ids
consolidating spec/plan/tasks/command authoring conventions; repo-
local governance pack, excluded from scaffold assets
(knownNonEmbeddedFiles) and the coding-pack validator, following
the determinism.md precedent.
… loader (2.1)

Task 2.1 of the model-matrix-delegation change (design D1): closed
Zod v1 surface for .uf/model-matrix.yaml with unknown keys rejected
at every level (MM-FR-001), loadModelMatrix with injectable
readText/parseYaml/fileExists seams returning the absent/ok/invalid
tristate (MM-FR-004, D8), pack existence validation against
.opencode/uf/packs/ naming the offending keys, the frozen no-op
matrix for comments-only documents, and the SelectionResult audit
type (D7, MM-FR-007). Tests cover the task-2.1 subset of the 2.4
scenario list so the governance coverage floor holds at every
commit (95.55 percent statements / 88.78 percent branches against
the 94/85 floors); the override, precedence, and classifier
scenarios land with tasks 2.2-2.4.
Task 2.2 of the model-matrix-delegation change (design D4, MM-FR-002):
validateModelMatrixOverride constrained to the fail-closed whitelist
profiles.*.model, profiles.*.variant, classifier.llm.* with structural
classifier keys rejected; mergeOverride nested-path leaf merge with
null-model propagation as host fallback (absent paths fall through to
the base, mirroring the review-dispatch mergeOverride precedent);
merged-result re-validation through the identical closed schema; empty
and comments-only overrides as no-ops; every whitelist violation names
the whitelist. 62/62 unit tests pass with 100 percent statements
coverage on the module from this suite.
Fix all 30 findings from the model-matrix-delegation spec review
dispatch 613a2466 (REQUEST CHANGES, iteration 2), zero waivers:

- unleash delta: carry all 16 predecessor scenarios forward
  (14 dropped in the MODIFIED delta), allocate UF-FR-002 to the
  modified requirement with reserved-range header, add the
  UF-FR-001 prose-pin scenario and verbatim-model wording
- model-matrix delta: defaults.implement never short-circuits
  (classifier wins, static fallback), tracked-credential
  population rule, profile-count bounds scenarios, xref fix to
  UF-FR-002, comments-only single documented exception,
  classifier resilience defaults (45s/0.6/128), per-cascade-
  instance cache, request_timeout_ms key + 10s default,
  env-unset skip semantics, https-or-loopback endpoint rule
- scaffold delta: sibling-capability locations in the header,
  slice-1-verifiable mirror-import scenario
- tasks.md: MP-018 checkpoint note, task 1.1 ripple files,
  re-scoped 2.4, [P] corrections (MP-017), new tasks 5.6
  (DE-007 seam verification), 6.6 (UF-FR-001 pin), 7.4
  (AGENTS.md), 7.5 (website issue per constitution
  Cross-Repo Documentation)
- proposal.md: unbound-force#888 closure bookkeeping, docs-gate and
  content-coverage dispositions, impact ripple files
- design.md: D4/D5 timeout + endpoint harmonization, D5 cache
  instantiation scope, D8 comments-only exception, D9 exemption
  decisions, D10 ownership classification, open-question-2
  clarification
Unconditional validation of explicit profile/pack parameters
ahead of the precedence chain (MM-FR-003) with explicit-pack
retention for directive rendering; combined-parameter scenarios
across the model-matrix/unleash deltas, resolveSelection, and
tests; new task 2.4 (tracked-role population check) with 2.4/2.5
renumbered to 2.5/2.6; classifier permission deny block
(MM-FR-005); 50 MiB response-body cap (MM-FR-006); starter
plan/tasks conformance rule scoped to the tracked matrix
(MM-FR-001); mechanical capability reachability documented;
empty MODIFIED sections per MP-013; task 6.4 [P] removal;
task 7.3 three issue closures; meta-prompt.md Custom Rules
boilerplate de-phantomed.
…2.4)

MM-FR-001: a tracked .uf/model-matrix.yaml carrying any populated
classifier.llm value (endpoint, model, apiKey, request_timeout_ms)
fails load with an error naming .uf/model-matrix.override.yaml as
the remediation. The check runs against the tracked file before the
override merge (merged views legitimately populate those paths,
MM-FR-002), separately from Zod schema validation. Loader
rejection rows: each populated leaf fails load naming the override
file with no merged configuration produced; the same values via the
override still load; structure-only and comments-only tracked files
stay valid (MM-FR-004).
Boundary rows: profile-count 1 and 32 accepted (0 and 33 were
already pinned); agent-pin count bounded at 32 with an empty agents
map accepted — the task text's 0-pins-rejected wording was
unimplementable against the landed schema and the starter matrix
(iteration-4 advisory 5), so the landed 0-32 semantics are pinned
with the rationale recorded; classifier timeout caps at 1_800_000
and 180_000 (advisory 6 documents the caps the FR text omits).
Cascade-bypass rows for explicit profile and pack (advisory 7),
selection-level matrix-validity gating rows (advisory 8), and the
tracked-matrix extensibility scenario row (advisory 10). Header
attribution corrected to name tasks 2.4 and 2.5 and point to
model-matrix-classifier.test.ts for the cascade tests (advisory 9).
… seed (2.6)

Design D3, MM-FR-008: canonical schemas/model-matrix/v1.schema.json
(closed input, additionalProperties: false throughout, mirroring the
Zod surface — capability/pack/agent-pin name patterns, profile-count
1-32, agent-pin cap 32, classifier timeout caps) plus the
valid-starter-matrix seed fixture; the remaining fixtures land with
task 4.2. The harness (.opencode/test/model-matrix-schema.test.ts)
discovers every samples/ fixture by documented family prefix and
asserts identical verdicts against v1.schema.json and the Zod
surface: valid-* pass both; bare invalid-* fail both; invalid-xref-*
pin the intentional divergence (cross-reference rules are runtime
rules); invalid-loader-/loader-rejection-* pass both parse surfaces
and fail loadModelMatrix; invalid-override-* fail the whitelist. A
compact draft-2020-12 subset validator keeps the dependency
footprint pinned (zod + vitest only); self-verification probes prove
the validator rejects what Zod rejects before the 4.2 fixtures land.
…che (3.2)

Agent engine spawns the hidden subagent through an injected session-spawn
seam bounded by agent_timeout_ms (default 45s); LLM engine issues the
chat-completions POST with temperature 0, response_format json_object and
one 400-retry, AbortSignal request timeout (default 10s), 50 MiB unbuffered
body cap, {env:VAR} apiKey interpolation with literal-key rejection and
unset-variable skip, and https-or-loopback endpoint validation. First
matrix-valid above-threshold result wins; the result cache is keyed by
SHA-256(feature_dir + prompt + agent), capped at 128, per cascade instance.
Includes a one-line type-hygiene annotation on the phase-2 mergeOverride
llm walk (explicit Record<string, unknown>).
…3.3)

47 tests across bypass predicate, agent engine, LLM engine, failure
composition, and result cache — all through the injected spawnAgent/
fetch/readEnv/cache seams, no live subagent or network. Includes the
agent-file drift test pinning the subagent definition to the default
agent constant, deterministic 50 MiB unbuffered-cap rows (declared
content-length and streaming), and timeout rows at 20ms real timers.

Also hardens the LLM attempt: the request pipeline now races the timer
(the bound holds even for a signal-ignoring fetch seam), matching the
agent engine's race discipline; the pipeline moved to issueLlmRequest.

Full plugin suite: 1616 tests green; lib/model-matrix.ts at 99.52%
statements / 95.34% branches; suite coverage 95.84% / 89.46%.
…ft exclusion

Task 3.1 of the model-matrix-delegation change created the hidden
model-matrix-classifier subagent as canonical repo content. Per
SC-FR-007, its scaffold deployment is deferred to slice 2 (unbound-force#889),
so the file joins knownNonEmbeddedFiles rather than the embedded
asset FS, following the meta-prompt.md precedent (303746c).
Tracks the design D9 starter matrix at .uf/model-matrix.yaml: version 1,
the four starter capabilities with empty profiles (identities arrive via
the gitignored override), the meta-prompt/go/typescript/python/content
packs mapping, plan/tasks -> spec-authoring and implement ->
code-writing defaults, empty agents, and classifier structure only. The
tracked-file conformance test (model-matrix-tracked.test.ts) loads the
real file through loadModelMatrix with REAL pack-file existence probes
and asserts the pinned starter shape; the MM-FR-001 starter-mapping
scenarios pin that a drifted defaults.plan or defaults.implement
mapping fails the conformance check while still passing v1.schema.json
and loading cleanly -- the rule is a tracked-file obligation, not a
schema or loader constraint. Adds the fail-closed yaml-subset parse
helper (pinned zod+vitest footprint; Bun.YAML is Node-unavailable) with
self-verification probes, and completes the CS-004 extraction of the
json-schema-subset validator out of model-matrix-schema.test.ts.
…rix schema asset

Task 4.3 deployed the model-matrix v1 schema registry copy as a new
embedded scaffold asset (uf/schemas/model-matrix/v1.schema.json),
raising the embedded total 79->80 and the deployed base count 74->75
(with 1 devcontainer non-deploy and 4 activation-gated plugins).
Update the TestRunInit_FreshDir range comment and assertion to match.
The scaffold-level asset inventory test pins the exact asset list.
uf_delegate_command gains the model-selection precedence chain (UF-FR-002,
MM-FR-003): explicit model/variant > profile > pack > agent pin > task-kind
default > classifier cascade > host model. Selection runs after skill
resolution and before host introspection -- a matrix-resolved model skips
resolveHostModel entirely while host fallback preserves the pre-change
variant-fallback and structural-failure semantics verbatim. Input schema
adds model (provider/model identity), variant (model companion), profile
and pack (1-128 chars, empty and 129 rejected pre-spawn), all documented
with the precedence order and the selection/classification mutual
independence.

renderPackDirective renders the fixed-template pack instruction (never
inlined content) at the fixed position: command text, feature-dir
context, skill directive, pack directive, extra prompt. The audit trail
(D7, MM-FR-007) records selection_source on every delegation plus pack,
capability, model, confidence, and fallback_reason when valued -- in both
the checkpoint data and the success envelope.

Tests: integration suite (AC1-AC8, boundary rows, host-introspection-failure
bypass), seam verification (registration surface, documented output shape,
registry round-trip), and unleash-delegate/scratch-smoke/uf-workflow ripples.
Scaffold registration: model-matrix.ts joins both lib enumeration lists,
the review-plugin staging list, and the asset inventory; mirrors synced
byte-identically; fresh-dir count range [75-79] -> [76-80].

make check exit 0; plugin suite 1645/1645 at 95.76% statements.
…ng (7.3)

Documentation issue unbound-force#893 filed per the AGENTS.md documentation gate;
the proposal top comment now carries all three PR Closes clauses
(unbound-force#887, unbound-force#888, unbound-force#893).
…ifacts

- 16 learning files produced during the model-matrix-delegation
  unleash workflow (spec review, code review, retrospective)
- Topics: content pipeline, convention packs, OpenSpec deltas and
  delta review, spec authoring and traceability, test architecture
  and quality
- Staged per the commit-scope rule: learnings produced during a
  change's workflow belong in the feature PR

Assisted-by: glm-5
Generated with AI assistance (glm-5)
- 5 learning files from the first spec-review iteration of the
  model-matrix-delegation workflow (stashed on main Oct 31 while
  the feature tree was kept clean)
- Topics: documentation gate, golden tests, scaffold mirrors,
  spec workflow
- Staged per the commit-scope rule: learnings produced during a
  change's workflow belong in the feature PR

Assisted-by: glm-5
Generated with AI assistance (glm-5)
@jflowers
jflowers force-pushed the opsx/model-matrix-delegation branch from ee69f8d to 17dd689 Compare November 1, 2026 14:14
@jflowers
jflowers merged commit 207f552 into unbound-force:main Nov 1, 2026
15 checks passed
jflowers added a commit that referenced this pull request Nov 1, 2026
Six Dewey learnings produced during the model-matrix-delegation
retrospective (PR #894, merged) were left untracked on main.
This commits them per repo precedent (236367d, 9af7ffa,
PR #885).

- configuration-security-20261101T134625 -- layered fail-closed
  config-security pattern for credential-bearing overrides
- review-dispatch-20261101T134627 -- reading oversized manifest
  diff chunks via patch-file slicing and hunk arithmetic
- scaffold-mirrors-20261101T134630 -- complete eight-piece
  scaffold registration checklist for new shared lib modules
- content-pipeline-20261101T134632 -- scope content-coverage
  dispositions to the full delivery plan with named triggers
- model-matrix-20261101T134638 -- bypass predicates belong
  inside the engine entry point, not at call sites
- test-quality-20261101T134639 -- pin propagation assertions
  at the consumption seam for whitelisted override fields

Clearing the tree also unblocks tier routing for the #889
pipeline run (slice 2: deploy the model-matrix config surface
to hero repos via uf init).

Assisted-by: glm-5
Generated with AI assistance (glm-5)
@jflowers
jflowers deleted the opsx/model-matrix-delegation branch November 15, 2026 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant