Skip to content

feat: validate stored plan structure and gate autonomous launches on readiness - #80

Merged
chriswritescode-dev merged 3 commits into
mainfrom
feat/plan-structure-validation
Jul 31, 2026
Merged

feat: validate stored plan structure and gate autonomous launches on readiness#80
chriswritescode-dev merged 3 commits into
mainfrom
feat/plan-structure-validation

Conversation

@chriswritescode-dev

@chriswritescode-devchriswritescode-dev commented Jul 31, 2026

Copy link
Copy Markdown
Owner

Summary

Tightens stored-plan validation and rewires the architect prompts and autonomous launch path around a warning-free plan. Every plan-write/plan-edit now returns actionable structural warnings, and grouped (architect-auto) launches only fire when the stored plan passes readiness inspection.

Key changes

  • src/utils/plan-structure.ts — fence-aware scan; validates Objective before the first marker, exactly one canonical Loop Name: short-slug line, per-phase required subsections (Files/Edits/Acceptance Criteria/Verification) with empty detection, trailing Decisions/Conventions/Key Context blocks, absolute-path detection scoped to Files bodies, and section-cap overflow.
  • src/utils/markdown-fences.ts — proper backtick/tilde fence detection with matching delimiter and minimum length; opening line masked as inside.
  • src/utils/plan-execution.ts — canonical Loop Name declarations, fence-aware loop-name extraction, MAX_LOOP_NAME_LENGTH constant.
  • src/utils/architect-auto-output.tsinspectArchitectPlanReadiness derived from structure warnings.
  • src/tools/plan-authoring.ts — append writes report only the latest section; descriptions drop legacy forge-plan marker guidance.
  • src/agents/architect.ts + src/agents/architect-auto.ts — shared ARCHITECT_TOOL_EXCLUDES; architect-auto also denies execution/group/loop tools and question.
  • src/index.ts — concise architect system-reminder derived from PLAN_EXECUTION_LABELS; capture/launch/classifyArchitectFailure gate on stored-plan readiness.
  • src/prompts/agents/architect.md heavily reduced to a concise canonical workflow + stored-plan schema; architect-auto.md updated in parallel.
  • src/constants/loop.tsPLAN_AUTHORING_TOOL_NAMES comment updated.
  • Tests across plan-structure, plan-execution, markdown-fences, agents, config, plugin, group-orchestrator, plan-authoring, and architect-auto-output.
  • Version bump to 0.7.7; README and docs regenerated.

Notes

  • Verified locally: pnpm typecheck && pnpm lint && pnpm test && pnpm build all green (2807 tests passing).
  • Deferred review follow-up DR-a10b0693-001 (remote goal/plan launch acknowledgement) belongs to PR feat: add goal-brief launch flow with server-owned prompt and goal-authoring tools #79 (feature/goal-brief-launch) and is intentionally left untouched here; DR-a10b0693-002 is already closed. No refs/notes/pr-review findings are attached to this branch's commits.

Summary by CodeRabbit

  • New Features

    • Plans are now authored, validated, and executed from stored plan records.
    • Added autonomous planning with stricter read-only and execution permissions.
    • Enhanced validation for structure, required sections, paths, loop names, and fenced code.
    • Plan execution rejects missing or incomplete plans and revalidates queued plans.
  • Bug Fixes

    • Improved Markdown fence handling and loop-name detection.
  • Documentation

    • Updated planning, agent, tool, API, and troubleshooting guidance.
  • Chores

    • Updated version from 0.7.6 to 0.7.7.

Forge added 2 commits July 30, 2026 15:29
The plan-write/plan-edit/plan-read tools are now the canonical storage
path. Remove the legacy outer-marker fallback prose from the architect
prompts and the planner system reminder; the capture code path still
handles a wrapped plan silently if one ever appears.
@coderabbitai

coderabbitaiBot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e535f60e-d984-45d6-915e-0cf75d66fafc

📥 Commits

Reviewing files that changed from the base of the PR and between 07bc1f5 and b05566c.

📒 Files selected for processing (1)
  • docs/api/variables/VERSION.md

📝 Walkthrough

Walkthrough

Architect planning now persists structured plans in SQL, validates completeness and warnings, restricts autonomous execution tools, and gates loop or group dispatch on readiness. Prompts, documentation, parsing utilities, tests, and version metadata were updated accordingly.

Changes

Stored Plan Workflow

Layer / File(s)Summary
Architect planning contracts and tool restrictions
src/agents/*, src/prompts/agents/*, src/constants/loop.ts, src/index.ts, test/agents.test.ts, test/config.test.ts
Architect agents use read-only planning rules, shared exclusions, structured stored-plan schemas, and differentiated interactive or autonomous permissions.
Fence-aware plan parsing and structural validation
src/utils/markdown-fences.ts, src/utils/plan-execution.ts, src/utils/plan-structure.ts, src/utils/architect-auto-output.ts, test/utils/*, test/plan-*.test.ts, test/markdown-fences.test.ts
Plan validation recognizes Markdown fences, canonical loop names, required sections, repository-relative paths, content requirements, and readiness warnings.
Plan persistence and execution gating
src/tools/plan-authoring.ts, src/tools/loop.ts, src/index.ts, test/services/group-orchestrator.test.ts, test/tools/plan-authoring.test.ts, test/plugin.test.ts
Stored-plan capture, append reporting, loop launch, and queued group execution require complete, warning-free plans and revalidate before launch.
Workflow documentation and release metadata
README.md, docs/**/*.md, AGENTS.md, package.json, src/version.ts
Documentation describes SQL-backed plan workflows, agent restrictions, validation rules, legacy fallback behavior, updated source references, and version 0.7.7.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
participant Architect
participant PlanWrite
participant StoredPlan
participant Readiness
participant LoopDispatch
Architect->>PlanWrite: author structured plan sections
PlanWrite->>StoredPlan: persist plan in session storage
StoredPlan->>Readiness: inspect structure and warnings
Readiness-->>Architect: return readiness report
Architect->>LoopDispatch: request execution
LoopDispatch->>Readiness: revalidate stored plan
Readiness-->>LoopDispatch: allow or reject launch
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 33.33% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
Title check✅ PassedThe title clearly and concisely describes the PR's primary changes: stored-plan structure validation and readiness gating for autonomous launches.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/plan-structure-validation

Comment @coderabbitai help to get the list of available commands.

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
src/utils/plan-structure.ts (1)

154-167: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Clarify why fenced content counts as Objective body content.

objectiveContent filters by !isFenceBoundary only (not !inFence), so genuine text inside a fenced block still satisfies the "non-empty content" check — this mirrors collectHeadingBodies's deliberate inclusion of non-boundary fenced lines in a heading's body (used for Files path detection), but the two filters look inconsistent with scanUnfencedLines at a glance. A short comment here would prevent a future reader from mistaking this for a missed !inFence check (as I initially did before cross-checking against collectHeadingBodies).

✏️ Suggested clarifying comment
 const objectiveContent = scanLines(planText).filter(({ index, text, isFenceBoundary }) =>
index > objectiveHeading.index
&& index < objectiveBoundaryIndex
+ // Fenced content still counts as real body content here (only fence+ // boundary lines and structural markers/headings are excluded), matching+ // collectHeadingBodies's treatment of fenced Files content elsewhere.
&& !isFenceBoundary
&& text.length > 0,
)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/utils/plan-structure.ts` around lines 154 - 167, Add a concise clarifying
comment above the objectiveContent filter explaining that non-boundary lines
inside fenced blocks intentionally count as Objective body content, consistent
with collectHeadingBodies, while fence boundary lines remain excluded. Do not
change the existing !isFenceBoundary filtering or validation behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/api/variables/VERSION.md`:
- Around line 9-11: Update the generated VERSION API documentation to report
0.7.7 consistently with package.json and src/version.ts, replacing the stale
0.7.6 declaration and value while preserving the existing documentation
structure.
In `@src/agents/architect.ts`:
- Around line 4-14: Update ARCHITECT_TOOL_EXCLUDES to retain the existing
mutation tool names while deriving the plan-related exclusions from the shared
PLAN_AUTHORING_TOOL_NAMES constant. Remove the literal plan, plan_enter, and
plan_exit entries and compose the list using the canonical constant so it stays
aligned with generated permission denies.
---
Nitpick comments:
In `@src/utils/plan-structure.ts`:
- Around line 154-167: Add a concise clarifying comment above the
objectiveContent filter explaining that non-boundary lines inside fenced blocks
intentionally count as Objective body content, consistent with
collectHeadingBodies, while fence boundary lines remain excluded. Do not change
the existing !isFenceBoundary filtering or validation behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a68fd62d-792b-4424-b31b-667bac6a3223

📥 Commits

Reviewing files that changed from the base of the PR and between a10b069 and 07bc1f5.

📒 Files selected for processing (43)
  • AGENTS.md
  • README.md
  • docs/agents-and-commands.md
  • docs/api/README.md
  • docs/api/_media/agents-and-commands.md
  • docs/api/_media/architecture.md
  • docs/api/_media/tools.md
  • docs/api/functions/createForgePlugin.md
  • docs/api/functions/createParentSessionLookup.md
  • docs/api/functions/createSessionDirectoryLookup.md
  • docs/api/interfaces/CompactionConfig.md
  • docs/api/interfaces/CreateParentSessionLookupOptions.md
  • docs/api/interfaces/CreateSessionDirectoryLookupOptions.md
  • docs/api/interfaces/DashboardConfig.md
  • docs/api/interfaces/PluginConfig.md
  • docs/api/variables/VERSION.md
  • docs/api/variables/default.md
  • docs/architecture.md
  • docs/modules.md
  • docs/tools.md
  • package.json
  • src/agents/architect-auto.ts
  • src/agents/architect.ts
  • src/constants/loop.ts
  • src/index.ts
  • src/prompts/agents/architect-auto.md
  • src/prompts/agents/architect.md
  • src/tools/loop.ts
  • src/tools/plan-authoring.ts
  • src/utils/architect-auto-output.ts
  • src/utils/markdown-fences.ts
  • src/utils/plan-execution.ts
  • src/utils/plan-structure.ts
  • src/version.ts
  • test/agents.test.ts
  • test/config.test.ts
  • test/markdown-fences.test.ts
  • test/plan-execution.test.ts
  • test/plan-structure.test.ts
  • test/plugin.test.ts
  • test/services/group-orchestrator.test.ts
  • test/tools/plan-authoring.test.ts
  • test/utils/architect-auto-output.test.ts

Comment threaddocs/api/variables/VERSION.md Outdated
Comment on lines +4 to +14
export const ARCHITECT_TOOL_EXCLUDES = [
'apply_patch',
'edit',
'write',
'multiedit',
'patch',
'task',
'plan',
'plan_enter',
'plan_exit',
]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Derive plan-tool exclusions from PLAN_AUTHORING_TOOL_NAMES.

The literal plan, plan_enter, and plan_exit entries can drift from the canonical plan-authoring list and its generated permission denies. Retain the mutation exclusions, but compose the plan-related exclusions from the shared constant.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/agents/architect.ts` around lines 4 - 14, Update ARCHITECT_TOOL_EXCLUDES
to retain the existing mutation tool names while deriving the plan-related
exclusions from the shared PLAN_AUTHORING_TOOL_NAMES constant. Remove the
literal plan, plan_enter, and plan_exit entries and compose the list using the
canonical constant so it stays aligned with generated permission denies.

Source: Coding guidelines

@chriswritescode-dev
chriswritescode-dev merged commit 8ae20f3 into mainJul 31, 2026
1 of 2 checks passed
@chriswritescode-dev
chriswritescode-dev deleted the feat/plan-structure-validation branch August 2, 2026 04:57
Sign up for freeto 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.

1 participant

@chriswritescode-dev