Skip to content

feat: artifact lifecycle system — protected zones, 19 lifecycle tools, validators - #13

Open
azrod wants to merge 24 commits into
mainfrom
feature/artifact-lifecycle-refonte
Open

azrod wants to merge 24 commits into
mainfrom
feature/artifact-lifecycle-refonte

Conversation

@azrod

@azrod azrod commented Sep 21, 2026

Copy link
Copy Markdown
Owner

Summary

Implements the artifact lifecycle refonte described in issue #12.

What changed

  • Protected zones — tool.execute.before hook blocks direct read/edit/write/bash/glob/grep access to docs/specs/, docs/exec-plans/, docs/briefs/. All access goes through lifecycle tools.
  • 19 lifecycle tools — replaces the 5 old tools (project_state, mark_block_done, complete_plan, register_spec, check_artifacts) with domain-specific tools:
    • Specs: spec_get/create/update/validate/list/delete
    • Plans: plan_get/create/update/validate/block_done/list/delete
    • Briefs: brief_get/create/update/list/delete
    • Global: project_state (refactored — specs + active plans only, no briefs)
  • 3 new agents — spec-validator (auto on spec_create/update), plan-validator (auto on plan_create), spec-reviewer (in review-manager pool)
  • Team-lead prompt — new Spec Protocol section, lifecycle tool references updated throughout
  • 92 tests — 0 fail (up from ~28)
  • Full doc update — AGENTS.md, README.md, CHANGELOG.md, website/

Closes #12

…, validators

- Add tool.execute.before hook blocking direct read/edit/write/bash/glob/grep
  on docs/specs/, docs/exec-plans/, docs/briefs/ (tools/artifact-guard.js)
- Replace 5 old lifecycle tools with 19 new domain-specific tools:
  spec_get/create/update/validate/list/delete,
  plan_get/create/update/validate/block_done/list/delete,
  brief_get/create/update/list/delete, project_state
- Add spec-validator, plan-validator, spec-reviewer agents
- Update team-lead prompt with Spec Protocol, new lifecycle tool references
- Expand test suite to 92 tests (0 fail)
- Update all docs: AGENTS.md, README.md, CHANGELOG.md, website/

Closes #12
Direct read access to docs/exec-plans/ is blocked by artifact-guard.
plan-validator must use lifecycle tools to access plans.
…ce detection

- spec-reviewer now detects when a delivery contradicts an existing spec
- New SPEC_VIOLATION verdict triggers immediate escalation to user
- team-lead prompt updated: SPEC_VIOLATION treated as BLOCKED (user decides)
- Update website docs: review-cluster and agents index reflect 4 verdicts
…-mode

- Add spec_format() and plan_format() lifecycle tools — return canonical
  format inline so agents always know expected structure before calling
  spec_create or plan_create
- Add spec-writer agent (temperature 0.3) — workflow: spec_format →
  spec_list → explore → spec_create → spec_validate, max 2 retry on reject
- Gardener dual-mode: Bootstrap (< 3 active specs, delegates to spec-writer)
  and Maintenance (existing behavior preserved)
- Add spec_format/plan_format to team-lead, gardener, spec-writer permissions
- Update specs: lifecycle-tools, gardener-agent
- 106 tests, 0 fail
- Maintenance mode: spawn explore agents, compile Gardener Report,
  return findings to team-lead. Never edits files or opens PRs.
- Bootstrap mode: unchanged — delegates to spec-writer sequentially
- Remove question, gh pr create, plan_list, plan_get, edit, write from permissions
- Add task (explore + spec-writer only), glob to permissions
- Remove QUALITY_SCORE.md from scope entirely
- Update gardener-agent spec, docs, website, CHANGELOG
- Update 4 drifted specs: lifecycle-tools (20 tools), team-lead-delegation
  (14 agents), planning-agent (lifecycle tool permissions), review-cluster
  (task restriction documented)
- Create 4 missing specs: spec-validator-agent, plan-validator-agent,
  spec-reviewer-agent, spec-writer-agent
- Fix stale docs: docs/index.md (20 tools + 4 new agents), docs/architecture.md
  (hook name, compress-only, 15 agent files), AGENTS.md (gardener description)
- Fix stale website pages: getting-started (20 tools), index (15 agents),
  architecture (bug-finder + researcher mode: all)
- Harmonize frontmatter/body status in 6 specs (draft/stable → implemented)
- Fix lifecycle tool count 19 → 20 across all docs
- Note 2 harness candidates in CHANGELOG
- Update 4 drifted specs: lifecycle-tools, team-lead-delegation,
  planning-agent, review-cluster
- Create 4 new agent specs: spec-validator, plan-validator,
  spec-reviewer, spec-writer
- Fix stale docs: docs/index.md, docs/architecture.md, AGENTS.md,
  website/getting-started, website/index, website/architecture
- Fix frontmatter/body divergence in 6 spec files (draft → implemented)
- Correct tool count 19 → 20 across all docs and prompts
- Remove doc-only skip-review shortcut from agents/prompt.md
@azrod

azrod commented Sep 22, 2026

Copy link
Copy Markdown
Owner Author

Summary of all changes

This PR implements a complete overhaul of the artifact lifecycle system, plus several follow-up improvements. Here's everything that landed:

🔒 Protected zones (artifact guard)

Direct read/edit/write/bash/glob/grep access to docs/specs/, docs/exec-plans/, and docs/briefs/ is now blocked by a tool.execute.before hook for all agents except via lifecycle tools. The guard lives in tools/artifact-guard.js and is fully unit-tested.

🛠️ 20 lifecycle tools (replacing 5)

The old project_state, mark_block_done, complete_plan, register_spec, check_artifacts are gone. Replaced by 20 domain-specific tools:

  • Specs (6): spec_get, spec_create, spec_update, spec_validate, spec_list, spec_delete
  • Plans (7): plan_get, plan_create, plan_update, plan_validate, plan_block_done, plan_list, plan_delete
  • Briefs (5): brief_get, brief_create, brief_update, brief_list, brief_delete
  • Format (2): spec_format, plan_format — return the canonical format for specs/plans so agents don't have to guess
  • Global (1): project_state — refactored to return active specs + plans with unchecked blocks only, no briefs

🤖 3 new validator/reviewer agents

  • spec-validator — auto-triggered on spec_create/spec_update. Returns APPROVED or REJECTED with a concrete reason. Temperature 0.1, silent.
  • plan-validator — auto-triggered on plan_create. Verifies functional objective present, blocks atomic, "Done when" criteria verifiable. Temperature 0.1, silent.
  • spec-reviewer — integrated into the review-manager pool. Returns one of 4 verdicts: NO_ACTION_NEEDED, SPEC_CREATE_NEEDED, SPEC_UPDATE_NEEDED, or SPEC_VIOLATION (blocker — escalated to user immediately).

✍️ spec-writer agent

New spec-writer agent specialized in writing high-quality specs. Workflow: spec_format() → spec_list() (dedup check) → codebase exploration → spec_create() → spec_validate() with up to 2 correction retries. Temperature 0.3. Used by the gardener in Bootstrap mode.

🌱 Gardener refonte (v2)

Maintenance mode is now a pure audit orchestrator — it spawns explore agents, compiles a structured Gardener Report (4 sections: Drifted specs → Stale docs → Recurring patterns → Recommended actions), and returns findings to the team-lead. It never edits files or opens PRs directly.

Bootstrap mode (< 3 active specs) delegates to spec-writer sequentially with LLM-as-a-judge evaluation after each spec.

Permissions updated: removed question, gh pr create, plan_list, plan_get, edit, write. Added task (filtered to explore + spec-writer only) and glob.

📋 Team-lead prompt updates

  • New Spec Protocol section: when to create specs, the 3-step workflow (at planning → before implementation → at completion)
  • Brainstorm Protocol: uses brief_list() instead of project_state() for brief detection
  • Gardener Protocol: dual-mode documentation with handling table
  • Removed the "doc-only → skip review" shortcut (reviews are now always required)
  • spec-reviewer verdict handling: SPEC_VIOLATION escalates immediately to user

🧪 Tests

92 → 106 tests, 0 fail. Covers all 20 lifecycle tools, artifact guard (read/edit/write/bash/glob/grep), edge cases (path traversal, multiple matches, idempotence, empty directories).

📚 Docs & specs sync (post-gardener-report)

  • 4 specs updated: lifecycle-tools, team-lead-delegation, planning-agent, review-cluster
  • 4 new specs created: spec-validator-agent, plan-validator-agent, spec-reviewer-agent, spec-writer-agent
  • Frontmatter/body divergence fixed in 6 spec files
  • Tool count corrected 19 → 20 across all docs, prompts, and website pages

- Add plan-reviewer orchestrator with light/deep review modes
- Add plan-functional-reviewer, plan-technical-reviewer, plan-code-reviewer
- Remove plan-validator agent (replaced by plan-reviewer cluster)
- Add hint field to plan_create, plan_update, spec_create, spec_update
- Update all docs, specs, and website to reflect new architecture
- Update CHANGELOG
@azrod

azrod commented Sep 22, 2026

Copy link
Copy Markdown
Owner Author

New commit — plan-reviewer cluster

What changed

New plan-reviewer cluster (replaces plan-validator)

The plan-validator (LLM structural linter) is replaced by an agent cluster modeled on the review-manager:

Agent Role Mode
plan-reviewer Orchestrator — asks for review depth, spawns sub-reviewers in parallel, arbitrates verdicts light + deep
plan-functional-reviewer Checks plan coherence against functional specs light + deep
plan-technical-reviewer Checks plan coherence against technical/architectural specs light + deep
plan-code-reviewer Checks block feasibility against the existing codebase (targeted exploration only) deep only

Review levels:

  • light — spec coherence only (functional + technical)
  • deep — spec coherence + code feasibility

Verdict: APPROVED / CHANGES_REQUESTED / BLOCKED (aligned with review-manager)

The mechanical plan_validate tool is unchanged — it still runs the structural linting check (sections present, valid blocks, etc.)


Hints on lifecycle tools

plan_create, plan_update, spec_create, and spec_update now return a hint field — a contextual suggestion to relay to the user to run a validation review once they are done building their plan/spec. No more false auto-trigger promise.


tool.execute.after investigation

We investigated whether OpenCode allows a lifecycle tool to automatically spawn an agent via the tool.execute.after hook. The answer: technically possible (the hook can mutate the output returned to the LLM), but blocking and complex. The chosen approach (enriching the output with a hint) is simpler, more predictable, and avoids race conditions.

- Extract GLOBAL_AGENTS_CONTENT, SUBAGENT_DEFS, mergePermissions,
  loadAgentPrompt, and registerSubagent into config/agents.js
- Extract the 20 lifecycle tool handlers into tools/registry.js
  behind a buildToolRegistry(projectRoot, paths) factory function
- Remove dead skill-loading code (spec-writer skill hook was never
  supported by OpenCode's plugin API)
- Remove legacy agent-write-dirs-exist entry from AGENTS.md
- index.js reduced from 961 to ~140 lines — pure orchestration only
- All 106 tests pass
@azrod

azrod commented Sep 23, 2026

Copy link
Copy Markdown
Owner Author

Refactor: split index.js into focused modules

Split the monolithic index.js (961 lines) into three focused modules:

File Responsibility
config/agents.js Agent definitions — GLOBAL_AGENTS_CONTENT, SUBAGENT_DEFS, mergePermissions, loadAgentPrompt, registerSubagent
tools/registry.js Lifecycle tool handlers — buildToolRegistry(projectRoot, paths) factory returning all 20 tools
index.js Pure orchestration — imports, TeamLeadPlugin factory, export (~140 lines)

Cleanup included:

  • Removed dead skill-loading code (spec-writer skill hook was never supported by OpenCode's plugin API)
  • Removed legacy agent-write-dirs-exist entry from AGENTS.md

All 106 tests pass.

Update all docs and specs to reflect that @opencode-ai/plugin moves
from peerDependency to a runtime dependency, with a CI carve-out in
the zero-deps check.
Remove the old plan-validator agent (prompt + spec) and replace it
with the plan-reviewer cluster spec covering plan-reviewer,
plan-functional-reviewer, plan-technical-reviewer, and
plan-code-reviewer. Update all cross-references in team-lead-delegation
and review-cluster specs.
…hidden migration

Update AGENTS.md, README, internal docs, website, and remaining specs
to reflect:
- config/agents.js holds SUBAGENT_DEFS (was index.js)
- tools/registry.js registers the 21 lifecycle tools
- silent flag replaced by hidden across agent config tables
- 21 lifecycle tools count (was 20)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Briefs et exec-plans dans le repo : bonne idée à court terme, bruit à long terme ?

1 participant