Skip to content

Commit 817b0e8

Browse files
SmithSmith
authored andcommitted
feat: introduce resource profiles and compact artifacts for small local execution
- Added resource profiles to runtime policy and governance schemas, including 'default' and 'small_local' profiles. - Implemented compact planning artifacts and phase task cards for small local LLM execution in various scenarios. - Created new schemas for CodeContextPack, ResearchBrief, and SpecCapture to support compact evidence and planning. - Developed tests to validate the integration of new resource profiles and compact artifacts in the planning and execution workflows. - Updated existing schemas and templates to accommodate new requirements for resource-aware execution.
1 parent 41be152 commit 817b0e8

46 files changed

Lines changed: 954 additions & 22 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ plans/templates/*
1616
!plans/templates/gate-event-template.md
1717
!plans/templates/phase-completion-template.md
1818
!plans/templates/plan-document-template.md
19+
!plans/templates/spec-template.md
20+
!plans/templates/research-brief-template.md
21+
!plans/templates/code-context-pack-template.md
22+
!plans/templates/phase-task-card-template.md
1923
!plans/templates/session-notes-template.md
2024
!plans/templates/session-outcome-template.md
2125
!plans/templates/traceability-index-template.yaml

BrowserTester-subagent.agent.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Keep the health-first gate, observation-first protocol, accessibility severity r
2020

2121
If `context_packet` is present in your dispatch, read the referenced `artifact_path` first before opening raw source files. Skip re-investigation of paths listed in `do_not_re_read` unless contradicting evidence is found.
2222

23+
If `phase_task_card` is present, treat it as the authoritative local scope. Do not create evidence outside `allowed_files`, do not enter `forbidden_areas`, and return `NEEDS_INPUT` or `FAILED` with `failure_classification: needs_replan` when the card's read budget would be exceeded.
24+
2325
### Scope IN
2426
- E2E browser test execution by running provided test scripts or harnesses via runCommands/runTasks.
2527
- UI/UX behavior verification against validation matrix.
@@ -111,6 +113,7 @@ Agent-specific fields:
111113
- `docs/agent-engineering/CLARIFICATION-POLICY.md`
112114
- `docs/agent-engineering/TOOL-ROUTING.md`
113115
- `schemas/browser-tester.execution-report.schema.json`
116+
- `plans/templates/phase-task-card-template.md`
114117
- `plans/project-context.md` (if present)
115118

116119
## Tools
@@ -157,6 +160,7 @@ Include these fields clearly labeled:
157160
- **Health Check** — application health gate result.
158161
- **Test Results** — passed/failed counts with failure details and evidence locations.
159162
- **Accessibility Findings** — WCAG violations with severity and element references.
163+
- **Scope Budget** — allowed evidence paths vs created evidence artifacts when a `phase_task_card` is present.
160164
- **Failure Classification** — when not COMPLETE: transient, fixable, needs_replan, or escalate.
161165
- **Summary** — concise overview of test results.
162166

CodeMapper-subagent.agent.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Find the right files, symbols, and dependencies quickly with deterministic outpu
2626
- First search batch must launch at least 3 independent searches.
2727
- If confidence is low or results are contradictory, return `ABSTAIN`.
2828
- No speculative claims without references.
29+
- When discovery will be handed to an executor or `resource_profile` is `small_local`, also write a compact CodeContextPack using `plans/templates/code-context-pack-template.md` and `schemas/code-context-pack.schema.json`; include entry points, top files, symbols, call paths, hotspots, and explicit expand conditions instead of raw dumps.
2930

3031
### Standards Extraction Mode
3132
When request includes "conventions", "standards", or "patterns": prioritize config and policy files; extract naming, structure, testing, and config conventions.
@@ -45,6 +46,8 @@ See [skills/patterns/preflect-core.md](skills/patterns/preflect-core.md) for the
4546
## Resources
4647

4748
- `schemas/code-mapper.discovery.schema.json`
49+
- `schemas/code-context-pack.schema.json`
50+
- `plans/templates/code-context-pack-template.md`
4851
- `docs/agent-engineering/PROMPT-BEHAVIOR-CONTRACT.md`
4952
- `plans/project-context.md` (if present)
5053

CoreImplementer-subagent.agent.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ Keep the backend-specific schema contract, verification evidence, and Definition
1919

2020
If `context_packet` is present in your dispatch, read the referenced `artifact_path` first before opening raw source files. Skip re-investigation of paths listed in `do_not_re_read` unless contradicting evidence is found.
2121

22+
If `phase_task_card` is present, treat it as the authoritative local scope. Do not edit outside `allowed_files`, do not enter `forbidden_areas`, and return `NEEDS_INPUT` or `FAILED` with `failure_classification: needs_replan` when the card's max changed files or read budget would be exceeded.
23+
2224
### Scope IN
2325
- Implement assigned task scope only.
2426
- Write tests first, then minimal code.
@@ -73,6 +75,7 @@ Agent-specific fields:
7375
- `docs/agent-engineering/RELIABILITY-GATES.md`
7476
- `docs/agent-engineering/MIGRATION-CORE-FIRST.md`
7577
- `schemas/core-implementer.execution-report.schema.json`
78+
- `plans/templates/phase-task-card-template.md`
7679
- `plans/project-context.md` (if present)
7780
- `docs/agent-engineering/TOOL-ROUTING.md`
7881
- `skills/patterns/llm-behavior-guidelines.md` (load on non-trivial tasks — anti-pattern guardrails: scope drift, over-abstraction, silent assumptions, weak success criteria)
@@ -113,6 +116,7 @@ Return a structured text report. Do NOT output raw JSON to chat.
113116

114117
Include these fields clearly labeled:
115118
- **Status**, **Changes**, **Tests**, **Build**, **Lint**, and **Summary**.
119+
- **Scope Budget** with allowed files vs changed files when a `phase_task_card` is present.
116120
- **Failure Classification** when not COMPLETE: transient, fixable, needs_replan, or escalate.
117121

118122
Full contract reference: `schemas/core-implementer.execution-report.schema.json`.

Orchestrator.agent.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Do NOT use `vscode/askQuestions` for questions answerable from codebase evidence
7373
- Generate `trace_id` (UUID v4 format) at task start. Propagate to all gate events and subagent delegation payloads.
7474
- Include `trace_id`, `iteration_index`, and `max_iterations` in every gate-event emission per `schemas/orchestrator.gate-event.schema.json`.
7575
- Purpose: enable log correlation across multi-agent orchestration chains.
76+
- If the plan declares `resource_profile: small_local`, apply `governance/runtime-policy.json` `resource_profiles.small_local`: cap parallel phase dispatch, require compact context artifacts for SMALL/MEDIUM/LARGE phases, and prepare `phase_task_card` payloads before executor dispatch.
7677

7778
### Planner Revision Modes
7879
- Use `revision_mode: initial_create` when no active plan exists.
@@ -129,6 +130,7 @@ When emitting gate events, optionally also append one NDJSON line per event to `
129130
- `schemas/code-reviewer.verdict.schema.json`
130131
- `schemas/planner.plan.schema.json`
131132
- `schemas/orchestrator.delegation-protocol.schema.json` (on-demand — load only when constructing delegation calls)
133+
- `plans/templates/phase-task-card-template.md` (on-demand — load only when constructing resource-bounded executor payloads)
132134
- `docs/agent-engineering/CLARIFICATION-POLICY.md`
133135
- `docs/agent-engineering/TOOL-ROUTING.md`
134136
- `docs/agent-engineering/SCORING-SPEC.md`
@@ -261,6 +263,8 @@ For `CodeReviewer-subagent`, `PlanAuditor-subagent`, and `AssumptionVerifier-sub
261263
- Run PreFlect gate.
262264
- Resolve the phase owner from `phase.executor_agent`. This field is authoritative for delegation and approval summaries.
263265
- If a legacy phase omits `executor_agent`, do not infer silently. Route the plan back through `REPLAN` to Planner and stop the implementation batch until the phase is reissued with an explicit executor.
266+
- Build a `phase_task_card` for executor payloads when the phase has `phase_task_card_path`, the plan uses `resource_profile: small_local`, or `governance/runtime-policy.json` `resource_profiles.small_local.require_phase_task_card` applies. The card must include objective, allowed files, forbidden areas, context artifacts, validation commands, acceptance checks, max changed files, and escalation rule.
267+
- When `phase_task_card` budgets are exceeded, do not widen the phase silently. Route to Planner with `needs_replan` or stop with `NEEDS_INPUT` according to the card's escalation rule.
264268
- **Model Resolution:** Apply the Universal Model Resolution Rule (see Execution Protocol preamble above) before delegating execution: look up `phase.executor_agent` in `agent_role_index`, resolve `roles[role].by_tier[complexity_tier]`, and pass the resolved primary model as the `model` parameter. If the tier entry is `{ "inherit_from": "default" }`, use the role's default `primary`. Only pass a fallback list if `agent/runSubagent` explicitly supports one.
265269
- Delegate execution to the declared executor agent.
266270
- Verification Build Gate: after the implementation subagent reports completion, verify build success. Either confirm the execution report includes `build.state: PASS`, or if build evidence is absent or ambiguous, run the project's build command directly. If the build fails, route through Failure Classification Handling before proceeding.
@@ -313,7 +317,7 @@ Violating a stopping rule is equivalent to skipping a gate.
313317
### Subagent Delegation Contracts
314318
For agent descriptions, roles, and expected deliverables, see `plans/project-context.md` — Agent Role Matrix.
315319

316-
Each delegation must include: scope description, expected output format, and relevant context references.
320+
Each delegation must include: scope description, expected output format, relevant context references, and `resource_profile` when the plan declares one. Executor delegations should include `phase_task_card` whenever the phase card exists or the active profile is `small_local`.
317321

318322
For detailed per-agent parameter shapes and required/optional fields, load `schemas/orchestrator.delegation-protocol.schema.json` on-demand. Do NOT load it into context preemptively — reference it only when constructing a delegation call.
319323

Planner.agent.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Produce implementation plans that are deterministic, schema-compliant, and execu
4040
### Mandatory Workflow Procedure
4141
1. Idea Interview Gate: BEFORE the Clarification Gate, evaluate whether the user request is vague or abstract. Trigger condition: the request contains **all three** of — (a) no specific file names or paths, (b) no concrete acceptance criteria, (c) no explicit technology or constraint named. If triggered, load `skills/patterns/idea-to-prompt.md` and execute the 5-step interview protocol using `vscode/askQuestions`. Replace the original vague request with the structured prompt assembled at the end of Step 5. Skip this gate entirely if any single concrete signal is present (a file path, an agent name, a schema reference, or a measurable goal).
4242
2. Clarification Gate: BEFORE proceeding to Design, evaluate the request against ALL five mandatory clarification classes in `docs/agent-engineering/CLARIFICATION-POLICY.md`. If ANY class matches, STOP and call `vscode/askQuestions` with 2-3 concrete options, affected files/components, and a recommended option with rationale. Do NOT proceed to Design until clarification is resolved or explicitly determined non-applicable. Decision rule: `vscode/askQuestions` is mandatory when competing interpretations change the top-level file set, `executor_agent`, architecture shape, or user-facing behavior. Do NOT call `vscode/askQuestions` for questions answerable by reading the codebase, when all options converge to equivalent outputs, or when the choice is a style or implementation detail already covered by existing configuration.
43+
- **Spec Capture Gate:** For vague tasks and non-trivial `SMALL`, `MEDIUM`, or `LARGE` plans, create a compact spec artifact using `plans/templates/spec-template.md` and `schemas/spec-capture.schema.json` before final phase decomposition. Set `spec_path` in the plan unless the request is already fully specified and only-when-obvious.
4344
3. Semantic Risk Discovery Gate: AFTER clarification and BEFORE research delegation, evaluate all 7 semantic risk categories using `plans/project-context.md` — Semantic Risk Taxonomy as the canonical trigger table. **Skip this gate for TRIVIAL scope** (≤2 files, single concern, no data/infra/security surfaces) — record all seven categories with `applicability: "not_applicable"` and proceed directly to Complexity Gate. Use the `risk_review` field format in `schemas/planner.plan.schema.json`; for TRIVIAL plans each category sets `impact: "LOW"` and `disposition: "not_applicable"` with a brief `evidence_source` rationale.
4445
For all other scopes, record applicability, impact, evidence source, and disposition for each category in the `risk_review` array. Keep cryptographic and vulnerability review ownership with PlanAuditor rather than duplicating it here. Any category with `applicability: applicable` AND `impact: HIGH` that cannot be resolved from available evidence MUST set `disposition: research_phase_added` and trigger a dedicated research phase BEFORE implementation phases.
4546
4. Complexity Gate: AFTER semantic risk evaluation and BEFORE research delegation, classify the task complexity and emit `complexity_tier` in the plan output. Use `plans/project-context.md` as the canonical source for tier definitions and override rules. Planner owns the classification result and planner-local planning consequences only; Orchestrator applies tier-specific PLAN_REVIEW routing, reviewer activation, and iteration budgets using `governance/runtime-policy.json`.
@@ -55,6 +56,8 @@ For all other scopes, record applicability, impact, evidence source, and disposi
5556
Implementation agents load referenced skills before executing phase tasks.
5657
6. Research (delegate CodeMapper-subagent/Researcher-subagent when scope is large).
5758
- **Model Resolution:** For every `agent/runSubagent` dispatch to `CodeMapper-subagent` or `Researcher-subagent`, load `governance/model-routing.json`, resolve the subagent role via the top-level `agent_role_index`, then apply `roles[role].by_tier[complexity_tier]`. If the tier entry is `{ "inherit_from": "default" }`, inherit the role's default `primary` model and default `fallbacks`; otherwise use the tier-specific `primary` and tier-specific `fallbacks` when present. Resolve `runtime_model_mode` from per-dispatch override when present, else `governance/runtime-policy.json` `model_dispatch.default_mode` (now defaults to `auto`; deterministic is the opt-in mode used for pinned dispatch). Every research dispatch must pass the exact target as the outer `agentName` field and include payload marker `runtime_model_mode`. In deterministic mode (opt-in for pinned dispatch), pass the resolved `primary` as the outer `model` field; when `complexity_tier` is unavailable, deterministic mode uses the target role top-level `primary`. In auto mode, omit the outer `model` intentionally so Copilot selects subagent model automatically. Only pass a fallback list if/when `agent/runSubagent` explicitly supports one; otherwise pass only the resolved primary model string in deterministic mode. A payload-level `model` in the prompt/delegation payload is contract and audit context; it does not by itself select the runtime model and is not a substitute for the outer `model` field.
59+
- When Researcher produces non-trivial findings, require a compact ResearchBrief artifact using `plans/templates/research-brief-template.md`; set `research_brief_path` and, when executor-facing, `context_packet_path`.
60+
- When CodeMapper performs discovery for executor context, require a compact CodeContextPack artifact using `plans/templates/code-context-pack-template.md`; set `code_context_pack_path`.
5861
7. Design (structured design decisions and diagram selection):
5962
- **Design Decisions Checklist** — Before proceeding to Planning (Step 8), explicitly address four dimensions:
6063
1. **Boundary changes** — Does the task change system boundaries, add new actors, or modify integration points? If no boundary changes, state "No boundary changes."
@@ -67,6 +70,8 @@ For all other scopes, record applicability, impact, evidence source, and disposi
6770
- **LARGE:** Always include a Mermaid `sequenceDiagram` alongside the phase dependency DAG.
6871
- Record design decisions in the plan artifact's "Design Decisions" section (see plan document template).
6972
8. Planning (phase decomposition with quality gates).
73+
- When `resource_profile` is `small_local`, keep each phase within the `resource_profiles.small_local.phase_file_limit` from `governance/runtime-policy.json` or add an explicit research/code-context phase before implementation.
74+
- For non-trivial executor phases and all `resource_profile: small_local` work, prepare a one-screen phase task card from `plans/templates/phase-task-card-template.md` and record `phase_task_card_path` on the phase. The card includes allowed files, forbidden areas, validation commands, acceptance checks, max changed files, and an escalation rule.
7075
9. Handoff (artifact-first plan persistence plus `plan_path` handoff for Orchestrator; PLAN_REVIEW ownership remains with Orchestrator).
7176
- For MEDIUM/LARGE plans where Researcher produced a non-trivial evidence packet, set `context_packet_path` in the plan to the research digest artifact path so downstream executors can consume it without re-investigation.
7277

@@ -111,10 +116,17 @@ Agent-specific additions:
111116
- `schemas/planner.plan.schema.json`
112117
- `schemas/researcher.research-findings.schema.json`
113118
- `schemas/code-mapper.discovery.schema.json`
119+
- `schemas/spec-capture.schema.json`
120+
- `schemas/research-brief.schema.json`
121+
- `schemas/code-context-pack.schema.json`
114122
- `docs/agent-engineering/CLARIFICATION-POLICY.md`
115123
- `docs/agent-engineering/TOOL-ROUTING.md`
116124
- `docs/agent-engineering/PROMPT-BEHAVIOR-CONTRACT.md`
117125
- `plans/project-context.md` (if present)
126+
- `plans/templates/spec-template.md`
127+
- `plans/templates/research-brief-template.md`
128+
- `plans/templates/code-context-pack-template.md`
129+
- `plans/templates/phase-task-card-template.md`
118130
- `skills/index.md` (domain skill mapping — read during Step 5)
119131
- `skills/patterns/llm-behavior-guidelines.md` (load on non-trivial tasks — anti-pattern guardrails: scope drift, over-abstraction, silent assumptions, weak success criteria)
120132
- `skills/patterns/source-grounding.md` (consider for external claims, provenance, and explicit `UNVERIFIED` state)
@@ -165,6 +177,8 @@ The artifact structure is defined by `plans/templates/plan-document-template.md`
165177

166178
The plan file must remain consistent with `schemas/planner.plan.schema.json`.
167179

180+
For small-model/resource-bounded planning, set `resource_profile: small_local` when requested or when local small LLM execution is the likely target. In that mode, prefer `spec_path`, `research_brief_path`, `code_context_pack_path`, `context_packet_path`, and per-phase `phase_task_card_path` over broad inline context.
181+
168182
### Plan Quality Standards
169183

170184
See `plans/templates/plan-document-template.md` for the complete 11 quality standards: incremental, TDD-driven, specific, testable, practical, parallelizable, routable, visualized, failure-aware, executable, and risk-reviewed.

PlatformEngineer-subagent.agent.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ Keep the platform-specific approval gates, idempotency mandate, rollback protoco
1919

2020
If `context_packet` is present in your dispatch, read the referenced `artifact_path` first before opening raw source files. Skip re-investigation of paths listed in `do_not_re_read` unless contradicting evidence is found.
2121

22+
If `phase_task_card` is present, treat it as the authoritative local scope. Do not edit outside `allowed_files`, do not enter `forbidden_areas`, and return `NEEDS_INPUT` or `FAILED` with `failure_classification: needs_replan` when the card's max changed files or read budget would be exceeded.
23+
2224
### Scope IN
2325
- Infrastructure deployment and configuration.
2426
- CI/CD pipeline setup and execution.
@@ -100,6 +102,7 @@ Agent-specific fields:
100102
- `docs/agent-engineering/RELIABILITY-GATES.md`
101103
- `docs/agent-engineering/MIGRATION-CORE-FIRST.md`
102104
- `schemas/platform-engineer.execution-report.schema.json`
105+
- `plans/templates/phase-task-card-template.md`
103106
- `plans/project-context.md` (if present)
104107
- `docs/agent-engineering/TOOL-ROUTING.md`
105108

@@ -139,6 +142,7 @@ Return a structured text report. Do NOT output raw JSON to chat.
139142

140143
Include these fields clearly labeled:
141144
- **Status**, **Changes**, **Rollback Steps**, **Idempotency**, **Build/Deploy**, and **Summary**.
145+
- **Scope Budget** with allowed files vs changed files when a `phase_task_card` is present.
142146
- **Failure Classification** when not COMPLETE: transient, fixable, needs_replan, or escalate.
143147

144148
Full contract reference: `schemas/platform-engineer.execution-report.schema.json`.

0 commit comments

Comments
 (0)