Repository navigation
Description
Codify intent-level orchestration (Router Pattern) as determinism rules DE-005/DE-006
Related: #716 (shipped precedent), #757 and #664 (in-flight applications), #659 (token-reduction epic), openspec/changes/determinism-codification/ (created DE-001..DE-004).
Summary
The determinism governance layer currently codifies step-level extraction (DE-001: a mechanical step becomes a tool) but not sequence-level collapse. The Router Pattern — "instead of giving the agent a library of tools and asking it to chain them, let the agent output a single intent; deterministic code in the wrapper maps that intent to the required sequence of tool calls" — is the next level of the same principle, and the repo is already applying it opportunistically (uf_unleash_branch_gate, uf_unleash_detect_resume, uf_delegate_command, dispatch_review_runs). This issue codifies the pattern in the two authoring/review-time governance files so it is enforced, not just practiced.
Files (both repo-local governance artifacts — not scaffold assets; exclusions confirmed at internal/scaffold/scaffold_test.go:2212-2214 and internal/schemas/packvalidator_test.go:188-196):
.opencode/uf/packs/determinism.md(review rules, loaded by review dispatch).opencode/skills/determinism-first/SKILL.md(authoring-time classification check)
Why this is not a new principle
Constitution Principle VI already says deterministic procedures MUST execute in tools rather than be re-reasoned from prose. An agent that chains five tool calls by reading instruction prose is re-reasoning a deterministic procedure from prose — the constitution's wording already covers sequences. DE-005 is the pack-level spelling-out of that coverage, exactly as DE-001 was for single steps. No constitution amendment is required (and none should be attempted in this change).
Constraints discovered (do not violate)
- Rule IDs are stable identifiers. DE-001..DE-004 are referenced by
openspec/changes/determinism-codification/(spec deltas pin ID/severity pairs), the activecommand-prose-pilotchange (DE-002/003/004 citations),CHANGELOG.md, and SKILL.md. New rules MUST append as DE-005/DE-006 in a new terminal section — no renumbering, no mid-document insertion that would break the ID == document-order invariant. - Cross-layer wording consistency (learning
governance-20261014T151535): multi-layer codification must keep MUST-rule wording aligned across layers, and cross-layer wording diffing must be an explicit spec-review step. See "Layer consistency decision" below. - DE-002 arrow notation (learning
determinism-20261015T150715): any preserved output-format examples at decision points useCall <tool> with <input> → {consumed fields}notation.
Implementation
1. .opencode/uf/packs/determinism.md
Version bump: version: 1.0.0 → version: 1.1.0 (additive rules).
Existing prose updates (only these — no existing rule text conflicts with the pattern, so nothing else is removed):
- Severity-mapping sentence (currently "Violations of the [MUST] rules (DE-001, DE-003) are CRITICAL findings; the [SHOULD] rules (DE-002, DE-004) are guidance...") becomes "(DE-001, DE-003, DE-005)" and "(DE-002, DE-004, DE-006)".
- The intro paragraph (lines 12-16) stays as-is — "deterministic procedures MUST execute in tools rather than be re-reasoned from prose" already covers sequence-level collapse; do not add a softening or narrowing qualifier.
New terminal section (after ## Efficiency Evidence):
---
## Intent-Level Orchestration
Sequence-level collapse, known externally as the Router Pattern: the
agent outputs a single intent, and deterministic tool code maps it to
the required sequence of calls. Shipped precedent:
`uf_unleash_branch_gate`, `uf_unleash_detect_resume`,
`uf_delegate_command`, `dispatch_review_runs`.
- **DE-005** [MUST] A fixed sequence of tool calls with no judgment
between steps — each next call and its arguments fully determined
by the previous call's structured result — is itself mechanical
instruction and MUST be collapsed into a single intent-level tool.
The agent expresses the intent and passes judgment products
(composed text, human gate decisions) as parameters; ordering,
batching, retry, failure-stop, and branching on structured results
belong to the tool. Instructing an agent to chain tools through a
judgment-free sequence is a DE-001-class violation.
- **DE-006** [SHOULD] Intent-level tools SHOULD keep judgment at
their boundary: judgment products arrive as validated parameters,
and routing decisions (verdict mapping, severity sorting,
exit-variant selection) execute inside the tool as constants or
pure functions. A tool whose contract requires the agent to
pre-compute its internal routing re-introduces the orchestration
DE-005 removes.2. .opencode/skills/determinism-first/SKILL.md
Existing prose updates:
- Frontmatter
description:Classify work as deterministic or judgment-based before writing. Route fixed procedures through executable tools instead of improvised prose output.→Classify work as deterministic or judgment-based before writing. Route fixed procedures and judgment-free tool chains through executable tools instead of improvised prose output.(keeps the first sentence byte-identical so skill-selection matching is unaffected). - "Classify Before Writing" twice-test paragraph: append one sentence —
The same test applies one level up: a fixed sequence of tool calls with no judgment between steps is itself deterministic.— so classification is complete before the sections below. - Mechanical-procedures bullet list ("Parsing structured input... Enumeration loops..."): add two bullets —
Orchestration of tool chains (ordering, batching, retry, failure-stop)andBranching on structured results via lookup tables (verdict mapping, severity sorting). - Numbered procedure ("When a deterministic step is needed: 1. Find an existing tool... 2. ...extract... 3. Prescribed output MUST be tool-rendered..."): add step 4 —
If the tool now sits in a judgment-free chain of calls, collapse the chain into a single intent-level tool; pass judgment products (composed text, gate decisions) as parameters. - "Related Enforcement":
Review rules DE-001 through DE-004→Review rules DE-001 through DE-006.
New section between "Deterministic Steps Belong in Tools" and "Judgment Belongs in Prose" (the chain rule is the bridge between them; no IDs involved, so mid-document insertion is safe):
## Chains Without Judgment Collapse Too
Extraction does not stop at single steps. When a fixed sequence of
tool calls has no judgment between steps — each next call and its
arguments fully determined by the previous call's structured result —
the sequence is itself a deterministic step. Collapse it into one
intent-level tool whose code performs the chaining.
The twice-test applies one level up: if a competent agent executing
the chain between two judgment points produces the same calls in the
same order both times, the chain belongs in code. Re-reading and
re-sequencing ten tool calls on every run costs the same scarce
context as ten steps of prose choreography.
Judgment stays at the boundary: composed content and human gate
decisions arrive as tool parameters; branching on structured results
(verdict mapping, severity sorting, exit-variant selection, batch
scheduling, failure-stop) happens inside the tool. Shipped
precedent: `uf_delegate_command` (command file read → prompt
assembly → child session spawn → artifact verification →
checkpoint) and `dispatch_review_runs` (plan → evidence → fan-out →
consolidate → artifact).Layer consistency decision (required before merge)
Per learning governance-20261014T151535, codifying a rule in the pack + skill while leaving sibling layers silent risks citable strictness divergence. Layer status under this change:
| Layer | Status |
|---|---|
Constitution Principle VI (.specify/memory/constitution.md) |
Already covers sequences ("deterministic procedures MUST execute in tools"); no edit |
determinism.md pack |
DE-005/DE-006 added (this issue) |
determinism-first skill |
Chain-collapse section added (this issue) |
AGENTS.md determinism-gate Behavioral Rule |
Enumerates categories: "(parsing, existence checks, git choreography, output template rendering, enumeration loops)" — does not name tool-chain orchestration |
Decision for jflowers: (a) append tool-chain orchestration to the AGENTS.md category list in the same change (one-category append, keeps layers aligned, closes the divergence the learning warns about), or (b) leave AGENTS.md alone and accept that the pack is the stricter/more specific layer (the constitution's supremacy resolves conflicts upward, and DE-005 does not contradict AGENTS.md — it extends it). Recommendation: (a), as a separate commit within the same PR so it can be dropped independently.
What is explicitly NOT in scope
- Constitution amendment (Principle VI already covers it; amendments are a separate process)
- Migrating existing command prose to comply with DE-005 — per the pack's own migration rule, existing prose migrates opportunistically at review time, not retroactively. uf.unleash Step 6: collapse per-task implement lifecycle into intent-level tool (Router Pattern) #757 and Create post_github_review plugin tool for shared PR review posting mechanics #664 are the tracked migrations.
- Any scaffold-asset or plugin-code changes (no code changes; both files are excluded from scaffold drift tests)
Verification
make test # drift tests confirm the repo-local exclusions still hold
go test ./internal/schemas/... ./internal/scaffold/...No make plugin-test needed (no TypeScript changes).
Acceptance criteria
-
determinism.mdat version 1.1.0 with DE-005 [MUST] / DE-006 [SHOULD] in a new terminal "Intent-Level Orchestration" section; severity-mapping sentence updated; DE-001..DE-004 text byte-unchanged - SKILL.md gains the chain-collapse section plus the five enumerated prose updates; frontmatter description keeps its first sentence byte-identical
- AGENTS.md layer decision recorded (option a or b) with rationale
- DE-004 evidence in the change record: before/after line and token counts for both files
-
make testgreen; no other files modified - OpenSpec change (
opsx/branch) per the determinism-codification precedent — lightweight, prose-only
Spec workflow
OpenSpec tier (single repo, prose-only, < 3 stories): opsx/router-pattern-codification. Model the proposal on openspec/changes/determinism-codification/ (which created these files) — its spec delta pinned rule IDs and severity pairs, so the new change's delta should pin DE-005/DE-006 the same way.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
docs(openspec): codify Router Pattern as DE-005/DE-006 (issue #758)