Skip to content

anvil Phase 9 — Audit Honesty + Phase 7 Cleanup + Doc Agents

Goal: Close out the deferred audit-honesty items from PR #49, finish the Phase 7 LLM-augmentation cleanup, add two new plugin-owned documentation agents (marketplace-scribe for marketplace-level docs and docs-scribe for plugin docs), and refresh marketplace + plugin documentation. Ship as v1.9.0.

Language: Python (plugin source) + Markdown (skills, agents, docs) Crew: fakoli-crew v2.0.1 (parallel waves, critic gates between waves) Branch: feat/anvil-phase-9 Working dir: ~/path/to/fakoli-plugins


Context

PR #49 (Phase 8 — bidirectional sync, v1.8.0) merged with 2 deferred CONSIDER items from the critic and several SHOULD FIX items logged but not fixed. The deferred items concern audit-event honesty — the sync engine currently emits sync.pull.completed for branches where the local state was not actually updated (the resolution was deferred to the next pass). This makes the JSONL audit log lie about what happened. Phase 9 closes that loop.

Phase 7 also left three small cleanup items: the RecordedLLMProvider test double ignores max_tokens/temperature when computing its record key (so two recorded responses that differ only in those args silently collide), the brainstorm skill detection is fuzzy, and the expand --use-llm command has no --format prd UX for pasting back into prd.md.

The user additionally requested two new plugin-owned documentation agents: - marketplace-scribe — keeps marketplace-level artifacts in sync (.claude-plugin/marketplace.json, registry/*.json, root README.md plugin table) whenever the plugin's manifest or surface changes. - docs-scribe — keeps the plugin's own docs/ folder fresh: audits cross-references between docs, ensures CHANGELOG.md and plugin.json.description match the code's actual shape, and flags stale references.

These agents are created in this phase; they become invocable as subagent types in future sessions (Claude Code discovers agents at session start).


Tasks

T1 — Audit current sync.* emissions for honesty gaps

Intent: Read every site in bin/src/anvil/cli/sync.py that calls _emit_audit and produce a table of (call site, action string, conditions under which it fires, what was actually mutated). Flag every site where the action string claims a mutation that did not happen.

Acceptance: - Table written to docs/plans/agent-scout-honesty-status.md covering all sync.* and task.synced_from_remote emission sites. - Each row marks HONEST or DISHONEST with one-line reason. - Explicit list of the deferred branches PR #49 flagged: local_wins, remote_wins, prompt_local, prompt_remote, prompt_manual. - Explicit identification of the local_moved-only path that collapses to in_sync when it should be local_ahead. - No code changes.

Scope (read-only): - plugins/anvil/bin/src/anvil/cli/sync.py - plugins/anvil/bin/src/anvil/state/payloads.py - plugins/anvil/bin/src/anvil/sync/reconciliation.py

Agent: fakoli-crew:scout Verify: Status file exists and table covers every _emit_audit call site (grep confirmation). Depends on: (none)


T2 — Audit Phase 7 deferred cleanup items

Intent: Confirm the current state of three Phase 7 deferrals and produce concrete patch points.

Acceptance: - Status file docs/plans/agent-scout-phase7-status.md documents: - C2: Exact location of RecordedLLMProvider.record_key and whether it currently hashes max_tokens / temperature. Recommendation: extend the canonical key. - C3: Current detection logic in plugins/anvil/skills/brainstorm/SKILL.md for the fakoli-flow:brainstorm bridge. Recommendation: tighten to explicit claude plugin list check. - C4: Current expand CLI surface in plugins/anvil/bin/src/anvil/cli/plan.py. Recommendation: add --format {text,prd} flag where prd emits ready-to-paste markdown blocks. - No code changes.

Scope (read-only): - plugins/anvil/bin/src/anvil/planning/llm.py - plugins/anvil/skills/brainstorm/SKILL.md - plugins/anvil/bin/src/anvil/cli/plan.py

Agent: fakoli-crew:scout Verify: Status file exists; all three sections have file:line citations. Depends on: (none)


T3 — Design SyncAuditPayload discriminated union

Intent: Replace the single all-optional SyncAuditPayload with a discriminated union (one concrete subclass per sync.* action), so unknown fields and field/action mismatches fail Pydantic validation instead of being silently accepted.

Acceptance: - New per-action models in bin/src/anvil/state/payloads.py: - SyncPushStartedPayload, SyncPushCompletedPayload, SyncPushDeferredPayload, SyncPushFailedPayload - SyncPullStartedPayload, SyncPullCompletedPayload, SyncPullDeferredPayload, SyncPullFailedPayload - SyncReconciliationStartedPayload, SyncReconciliationCompletedPayload - Each subclass declares only the fields its action actually carries (extra="forbid"). - Backwards-compat alias SyncAuditPayload = Annotated[Union[...], Field(discriminator="action")] kept so existing callers do not have to change at import time. - Mapping table ACTION_TO_PAYLOAD exported.

Scope: - plugins/anvil/bin/src/anvil/state/payloads.py (edit only the SyncAudit section)

Agent: fakoli-crew:guido Verify: uv run python -c "from anvil.state.payloads import SyncPushDeferredPayload; SyncPushDeferredPayload(action='sync.push.deferred')" succeeds; passing an unknown field raises ValidationError. Depends on: T1


T4 — Create marketplace-scribe and docs-scribe agent specs

Intent: Add two new plugin-owned agent .md files to plugins/anvil/agents/ following the existing pattern (frontmatter name/description/tools/color/model, system prompt, deference rules).

Acceptance: - plugins/anvil/agents/marketplace-scribe.md: - Frontmatter: name: marketplace-scribe, color: cyan, model: opus, tools restricted to Read, Write, Edit, Bash, Glob, Grep. - Description with 3 trigger examples (per fakoli-crew style). - System prompt: owns .claude-plugin/marketplace.json, root README.md plugins table, registry/*.json. Fires after any version bump, agent add/remove, or skill add/remove in the plugin. Defers to fakoli-crew:keeper when not in an anvil context. - plugins/anvil/agents/docs-scribe.md: - Frontmatter: name: docs-scribe, color: purple, model: opus, tools restricted to Read, Write, Edit, Glob, Grep. - Description with 3 trigger examples. - System prompt: owns the plugin's docs/ folder, CHANGELOG.md, and .claude-plugin/plugin.json's description field. Audits cross-references between docs (broken [[...]], mismatched section anchors). Fires after any schema change, new CLI command, new agent, or completed phase. Defers to fakoli-crew:herald for general README work; takes over plugin-internal docs. - Both files match the existing length and depth of agents/state-keeper.md.

Scope: - plugins/anvil/agents/marketplace-scribe.md (new) - plugins/anvil/agents/docs-scribe.md (new)

Agent: fakoli-crew:smith Verify: Both files exist, frontmatter parses, color values don't collide with existing anvil agents (planner=blue, critic=red, sentinel=green, state-keeper=teal). Depends on: (none)


T5 — Implement audit honesty fixes + multi-provider config

Intent: Wire the audit-honesty corrections identified in T1 plus the new discriminated payloads from T3. Also add the multi-provider config schema in .anvil/config.yaml so users can declare which providers sync should iterate.

Acceptance: - cli/sync.py: - Deferred branches (local_wins, remote_wins, prompt_* that did NOT mutate local state) now emit sync.pull.deferred instead of sync.pull.completed. - local_wins and remote_wins paths that DO mutate emit sync.pull.completed with new resolution: *_applied audit value (these are the immediate-apply variants). - local_moved-only path (when local task has changed but remote has not) sets mapping sync_state="local_ahead", not "in_sync", and emits sync.push.pending audit hint. - state/payloads.py already updated in T3. - config.py parses optional top-level sync: block with providers: [github_issues, linear, ...] key; CLI default falls back to sorted(PROVIDER_REGISTRY) when key absent. - Every existing test still passes after the action-string changes (update fixtures, not assertions about reality).

Scope: - plugins/anvil/bin/src/anvil/cli/sync.py - plugins/anvil/bin/src/anvil/config.py - plugins/anvil/bin/src/anvil/state/sqlite.py (add _handle_sync_pull_deferred if not already a no-op) - plugins/anvil/tests/test_cli_sync.py (update fixtures, add 4–6 new tests)

Agent: fakoli-crew:welder Verify: cd plugins/anvil/bin && uv run pytest tests/test_cli_sync.py -v Depends on: T1, T3


T6 — Implement Phase 7 cleanup

Intent: Close C2, C3, C4 from Phase 7.

Acceptance: - C2 (record_key): RecordedLLMProvider.record_key(system, user, *, max_tokens=4096, temperature=0.0) includes both tuning args in its canonical hash input. Existing tests updated to pass the new args; one new test confirms two responses keyed by different max_tokens do not collide. - C3 (brainstorm detection): skills/brainstorm/SKILL.md updated with explicit detection block: "Run claude plugin list 2>/dev/null | grep fakoli-flow — if present, bridge by invoking /fakoli-flow:brainstorm as a sub-skill; if absent, proceed with the local brainstorm flow." No more fuzzy "if fakoli-flow seems available" prose. - C4 (--format prd): anvil expand TASK_ID --use-llm --format prd emits proposed sub-tasks as ready-to-paste ### TXxx markdown blocks matching docs/prd-template.md exactly. Default --format text keeps the current human-readable output. One new test per format.

Scope: - plugins/anvil/bin/src/anvil/planning/llm.py - plugins/anvil/skills/brainstorm/SKILL.md - plugins/anvil/bin/src/anvil/cli/plan.py - plugins/anvil/tests/test_llm.py (extend) - plugins/anvil/tests/test_cli_plan.py (or wherever expand is tested)

Agent: fakoli-crew:welder Verify: cd plugins/anvil/bin && uv run pytest tests/test_llm.py tests/test_cli_plan.py -v Depends on: T2


T7 — Documentation refresh

Intent: Update existing plugin docs to reflect Phase 9 changes; create the canonical docs/phase-9-backlog.md per the user's prior directive; refresh marketplace-level artifacts via the new marketplace-scribe discipline (done here by fakoli-crew:keeper since the new agent is created but not yet session-discoverable).

Acceptance: - New file plugins/anvil/docs/phase-9-backlog.md lists the remaining v0.x items (Linear/Monday/Jira providers, webhook-based sync, immediate-apply _applied further hardening, etc.) AND the carry-forward tech-debt items from docs/tech-debt-backlog.md. - plugins/anvil/docs/github-sync.md updated: new "Audit honesty" section explaining sync.pull.deferred semantics and the local_ahead mapping state. - plugins/anvil/docs/sync-providers.md updated: new section "Per-provider configuration" describing the sync.providers config key. - plugins/anvil/docs/llm.md updated: corrected RecordedLLMProvider.record_key signature; expand --format prd example. - plugins/anvil/docs/tech-debt-backlog.md — mark Phase 8 items DONE (those that shipped in PR #49); cross-reference items moved to phase-9-backlog.md. - plugins/anvil/CHANGELOG.md — full [1.9.0] — 2026-05-25 entry. - plugins/anvil/.claude-plugin/plugin.json — "version": "1.9.0". - plugins/anvil/bin/pyproject.toml — version = "1.9.0". - plugins/anvil/bin/src/anvil/__init__.py — __version__ = "1.9.0". - plugins/anvil/README.md — version badge updated; agent table includes the 2 new agents. - Root .claude-plugin/marketplace.json + registry/*.json regenerated by running scripts/generate-index.sh.

Scope: - 8 doc/manifest files listed above + scripts run.

Agent: fakoli-crew:keeper (acting in the marketplace-scribe + docs-scribe roles for this phase since the new agents are only just being created and not yet session-discoverable) Verify: All files exist with new content; bash scripts/generate-index.sh --check succeeds. Depends on: T4, T5, T6


Wave Assignment

Computed from the Depends-on graph:

Wave 1 (parallel, scout/smith only — no code mutations to existing modules):
  T1 — scout: audit sync.* emissions
  T2 — scout: audit Phase 7 deferrals
  T4 — smith: create marketplace-scribe + docs-scribe agent specs

Wave 2 (parallel, guido):
  T3 — guido: SyncAuditPayload discriminated union (depends on T1)

Wave 3 (parallel, welder — different file sets):
  T5 — welder: audit honesty fixes + multi-provider config (depends on T1, T3)
  T6 — welder: Phase 7 cleanup (depends on T2)

Wave 4 (sequential, keeper):
  T7 — keeper: docs + version bump + marketplace regen (depends on T4, T5, T6)

Wave 5 (parallel, critic):
  critic: review all changes
  sentinel: full test suite + acceptance criteria scorecard

Total tasks: 7 (plus critic + sentinel) Total waves: 5 (4 work + 1 review). T4 is in Wave 1 because it touches only new files (no dependency on the audit results).


Acceptance criteria (rollup, for sentinel)

  1. All 7 task acceptance criteria verified individually.
  2. Full pytest suite passes (cd plugins/anvil/bin && uv run pytest -v).
  3. ruff + mypy clean (cd plugins/anvil/bin && uv run ruff check . && uv run mypy src/anvil).
  4. New agents pass plugin validation (bash scripts/generate-index.sh --check).
  5. Test count: at least 935 (PR #49 baseline) + new tests from T5/T6 = ~950+.
  6. No sync.pull.completed emitted on a deferred branch (grep cli/sync.py confirms guard).
  7. No sync_state="in_sync" set on a local_moved-only pull (grep cli/sync.py confirms).
  8. RecordedLLMProvider.record_key("a", "b", max_tokens=100, temperature=0.0) != record_key("a", "b", max_tokens=200, temperature=0.0) (collision regression test).
  9. marketplace-scribe.md and docs-scribe.md exist with valid frontmatter.
  10. plugin.json.version == "1.9.0" in plugin manifest, pyproject, init.py, and marketplace.json (all four sources in sync).