You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Implement structurally enforced agent checkpoints and verification gates #133
Implementation Plan: Structurally Enforced Agent Checkpoints and Verification Gates
After reviewing the existing codebase, I've put together a phased implementation plan. The current infrastructure (composite action, gateway sidecar, session/worktree managers) provides a solid foundation for building the multi-agent pipeline.
Phase 1: Contract Schema and Validation (Foundation)
Goal: Establish the structured contract format that will govern all subsequent agent interactions.
1.1 Define Contract JSON Schema
Create .egg/schemas/contract.schema.json with JSON Schema validation
Define the contract structure as specified in the issue:
Action parses this output and updates contract accordingly
Deliverables:
Reviewer system prompt and rules
Action role support (inputs, env vars)
Review prompt builder script
Reviewer output parsing and contract update logic
Phase 3: Pipeline Workflow (sdlc-pipeline.yml)
Goal: Build the GitHub Actions workflow that orchestrates the multi-stage pipeline.
3.1 Workflow Structure
Location:.github/workflows/sdlc-pipeline.yml
Triggers:
workflow_dispatch with issue number input
Issue labeled egg-automate
3.2 Stage Jobs
Each stage follows the worker → reviewer → (loop or advance) pattern:
jobs:
setup:
# Initialize contract file from issue# Create working branchrefine-issue:
needs: setup# Worker: Analyze and refine issue → structured acceptance criteria# Reviewer: Validate refinement is complete and unambiguous# Loop up to N times, then escalateplan:
needs: refine-issue# Worker: Create phased implementation plan# Reviewer: Validate plan covers all criteria# Optional: HITL approval gateimplement:
needs: plan# Matrix job: one iteration per phase in contract# Each iteration: Worker → Reviewer → update contract# Circuit breaker enforcement between iterationscreate-pr:
needs: implement# Worker: Create PR with full description# Reviewer: Final diff review# Always HITL: human merges
3.3 State Passing Between Jobs
Contract JSON file committed to branch after each stage
Each job reads contract, performs work, commits updated contract
Use actions/checkout with the working branch between jobs
3.4 Prompt Builder Scripts
action/build-refine-prompt.sh — For issue refinement stage
action/build-plan-prompt.sh — For planning stage
action/build-implement-prompt.sh — For implementation (per-phase)
action/build-pr-prompt.sh — For PR creation
Deliverables:
sdlc-pipeline.yml workflow file
Stage-specific prompt builder scripts
Contract state management between jobs
Job dependency and failure handling
Phase 4: Circuit Breaker and Escalation
Goal: Implement the spinning wheel detection and human escalation paths.
4.1 Circuit Breaker Logic
Location:shared/egg_contracts/circuit_breaker.py
Track review cycle count per phase in contract
Track total cycles across all phases
Configurable thresholds (default: 3 per phase, 10 total)
4.2 Escalation Actions
action/escalate.sh — Generic escalation script
Escalation modes:
Label issue: Add needs-human-refinement or needs-human-decision
Draft PR: Create draft PR with context for human review
Slack notification: Optional, if configured
Issue comment: Post detailed context of what's blocking
4.3 HITL Approval Gates
Configurable checkpoints where pipeline pauses for human input
Resume mechanism: Human adds comment or label to continue
Integrate with existing on-mention.yml pattern for @mention responses
Deliverables:
Circuit breaker implementation with configurable thresholds
Escalation script and GitHub actions
HITL approval gate mechanism
Resume workflow logic
Phase 5: Integration and Testing
Goal: End-to-end testing and refinement of the full pipeline.
5.1 Test Fixtures
Create test issues with varying complexity
Mock contract files for unit testing
Integration test workflow that runs pipeline on test repo
5.2 Documentation
Update docs/index.md with pipeline documentation
ADR for multi-agent pipeline architecture
Runbook for troubleshooting common pipeline failures
Phases 1-2 can be developed in relative isolation with unit tests. Phase 3 depends on 1-2 but can start once contract library is stable. Phases 4-5 are refinements that can be developed incrementally.
Estimated Scope Per Phase
Phase
New Files
Modified Files
Est. LOC
1
5-6
0
~800
2
3-4
2-3
~600
3
5-6
1-2
~1200
4
2-3
3-4
~500
5
3-4
2-3
~400
Total: ~3500 LOC across ~25 files
Key Design Decisions
Why JSON contracts over markdown?
Agents are less likely to inappropriately edit structured JSON
Plan Review: Structurally Enforced Agent Checkpoints
I've reviewed the implementation plan against the issue requirements and the existing codebase. Overall, the plan is well-structured and demonstrates good understanding of the existing infrastructure. Here's my assessment:
✅ Strengths
1. Correct Infrastructure Understanding
The plan correctly identifies and builds upon:
Composite action (action/) as the execution engine
Gateway sidecar's credential isolation and policy enforcement
Existing on-mention.yml patterns for HITL checkpoints
2. Phased Approach
Breaking the work into 5 phases with clear dependencies is the right approach. Each phase is scoped appropriately (~500-1200 LOC) and can be independently validated.
3. Role-Based Field Access
The design to enforce write permissions at the CLI level (EGG_AGENT_ROLE env var) is sound. This provides structural enforcement beyond prompt instructions.
4. Contract CLI Design
Providing explicit commands (egg-contract update-phase-commits vs egg-contract mark-phase-passed) with role enforcement is a clean approach that makes violations obvious.
⚠️ Areas for Clarification
1. Contract File Location
The issue specifies .egg/contracts/{issue-number}.json but the plan doesn't explicitly confirm this. The plan should specify:
Where contract files live in the repo
Whether they're committed to the working branch or main
How they're cleaned up after PR merge
2. Reviewer Output Parsing
Phase 2 mentions "Action parses this output and updates contract accordingly" but doesn't detail how the reviewer's structured output gets captured. Options:
Parse stdout from Claude Code
Reviewer writes to a temp file that the action reads
Reviewer calls egg-contract CLI directly
The CLI approach (reviewer calls egg-contract mark-phase-passed) seems cleaner than parsing stdout, but this should be explicit.
3. Stage Prompt Construction
Phase 3 lists prompt builder scripts (build-refine-prompt.sh, build-plan-prompt.sh, etc.) but doesn't detail what context each provides. For example:
build-implement-prompt.sh needs to include the specific phase from the contract
build-review-prompt.sh needs to include the diff, the acceptance criteria, and the phase requirements
Suggest documenting the inputs and outputs for each prompt builder.
4. Matrix Job for Implementation
The plan mentions "Matrix job: one iteration per phase in contract" but GitHub Actions matrix jobs run in parallel by default. The implementation needs to either:
Use a sequential job chain (one job per phase with needs:)
Use a dynamic matrix with sequential execution
Use a single job with a loop
This architectural decision affects the workflow structure significantly.
🔴 Potential Gaps
1. Contract Schema Enforcement at Commit Time
The issue emphasizes "verification runs in its own context window." The plan mentions role-based CLI access, but doesn't address what happens if the implementing agent directly edits the contract JSON file via git add instead of using the CLI.
Suggestion: Add a pre-commit hook or CI check that validates contract JSON:
Schema validity
Field modifications only by authorized role (based on commit author or branch convention)
Integration with existing notification library (notifications.slack_notify)
3. Resume After HITL
The plan mentions "Resume mechanism: Human adds comment or label to continue" but doesn't detail:
How the workflow detects the resume trigger
Whether it restarts from scratch or continues from checkpoint
How the contract state is preserved across workflow runs
The existing on-mention.yml pattern could handle this, but the integration needs to be explicit.
4. Test Strategy
Phase 5 mentions "Integration test suite" but doesn't detail:
How to test worker → reviewer handoff without running actual Claude
Mock strategies for contract CLI testing
End-to-end test isolation (separate test repo?)
📝 Responses to Open Questions
Q1: HITL at planning stage - always require sign-off?
Recommend: Configurable, default to optional. Add an input require-plan-approval: true|false to the workflow. For high-risk repos or large features, enable it. For routine work, allow auto-advance.
Q2: Branch naming - per-phase or single branch?
Recommend: Single branch (egg-{issue}) with commits per phase. Reasons:
Simpler PR management (one PR per issue)
Phases are sequential, not parallel
Contract file tracks progress within the branch
Easier human review of aggregated changes
Q3: Parallel phases?
Recommend: Strictly sequential for MVP. Reasons:
Phases often have implicit dependencies (phase 2 might touch files phase 1 created)
Simpler state management
Can add parallelism later if needed
Q4: Reviewer model?
Recommend: Same model for MVP. Reasons:
Consistent quality of review
Simpler configuration
Can optimize later with usage data
✅ Suggested Additions to Plan
Phase 1.5: Pre-commit Validation
Add a git pre-commit hook or CI workflow step that validates contract modifications came through the CLI, not direct edits.
Phase 3.5: Resume Workflow
Add a separate workflow or job that handles HITL resume triggers (label added, comment with approval keyword).
Documentation in Phase 2
Include a docs/guides/sdlc-pipeline.md deliverable that documents the pipeline stages, contract schema, and troubleshooting.
Summary
The plan is ready to proceed with the clarifications noted above. I recommend:
Address the "Contract file location" and "Matrix job" architectural decisions before Phase 1
Add pre-commit validation for contract integrity in Phase 1
Clarify reviewer output mechanism in Phase 2
Document resume-after-HITL workflow in Phase 4
Verdict: Plan is sound, proceed with Phase 1 after addressing architectural clarifications.
@james-in-a-box let's add a bit more context on planning here. I want to create a planning/task system that is enforced by this methodology. I want to have a collection of tasks that are implemented by one agent (implementer) and marked as complete by another agent (reviewer). I want to make sure that the implementer has no ability to mark tasks as complete. That must be done by the reviewer as part of the review cycle (which happens autonomously). Similarly, when decisions are marked as human in the loop, I want to only allow humans to make those decisions and mark them as decided. This can be something as simple as clicking on a checkbox on bot comments.
Issue Description Updated: Enhanced Planning/Task System
I've updated the issue description to add comprehensive detail on the planning/task system with structural enforcement. Here's a summary of the key additions:
New: Part 2 - Task Collection and Role-Based Enforcement
Added a detailed task collection system with structural separation of concerns:
Role
Can Modify
Cannot Modify
Implementer
commits[], notes
status, passes, verified
Reviewer
status, passes, review_feedback[]
commits[], task definitions
Human
All fields
(unrestricted)
Key features:
Contract CLI (egg-contract) enforces role-based field access via EGG_AGENT_ROLE environment variable
Pre-commit hook validates contract modifications respect role ownership
Tasks stored in structured JSON at .egg/contracts/{issue-number}.json
Full audit log tracks all modifications with actor, timestamp, and action
New: Part 3 - Human-in-the-Loop Decision System
Added a GitHub checkbox-based HITL decision system:
HITL decisions rendered as checkboxes in bot comments
Activity
Expand async quality section with #133 and #134 insights
jwbron commentedon Feb 6, 2026
@james-in-a-box go ahead and put together a plan for this and add it to this issue
james-in-a-box commentedon Feb 6, 2026
Implementation Plan: Structurally Enforced Agent Checkpoints and Verification Gates
After reviewing the existing codebase, I've put together a phased implementation plan. The current infrastructure (composite action, gateway sidecar, session/worktree managers) provides a solid foundation for building the multi-agent pipeline.
Phase 1: Contract Schema and Validation (Foundation)
Goal: Establish the structured contract format that will govern all subsequent agent interactions.
1.1 Define Contract JSON Schema
.egg/schemas/contract.schema.jsonwith JSON Schema validation1.2 Create Contract Library
shared/egg_contracts/schema.py— JSON Schema loading and validationcontract.py— Contract dataclass with typed fieldsroles.py— Role-based field access (WORKER vs REVIEWER)transitions.py— Valid state transition logic1.3 Contract CLI Tool
sandbox/egg_lib/contract_cli.pyegg-contract read— Read current contract stateegg-contract update-phase-commits— Worker: add commit to phaseegg-contract mark-phase-passed— Reviewer only: update pass statusegg-contract check-circuit-breaker— Check if escalation neededEGG_AGENT_ROLEenv var)Deliverables:
Phase 2: Review Agent Infrastructure
Goal: Create the reviewer agent capability with separate prompts and enforcement.
2.1 Reviewer System Prompt
sandbox/.claude/reviewer-rules.md2.2 Action Enhancements for Reviewer Mode
roleinput toaction/action.yml(worker | reviewer)action/entrypoint.shto:EGG_AGENT_ROLEenvironment variableaction/build-review-prompt.shfor constructing reviewer prompts2.3 Reviewer Output Protocol
{ "verdict": "pass" | "fail", "phase_id": "phase-1", "feedback": ["Comment 1", "Comment 2"], "criteria_evaluated": [{"id": "ac-1", "passed": true}] }Deliverables:
Phase 3: Pipeline Workflow (sdlc-pipeline.yml)
Goal: Build the GitHub Actions workflow that orchestrates the multi-stage pipeline.
3.1 Workflow Structure
.github/workflows/sdlc-pipeline.ymlworkflow_dispatchwith issue number inputegg-automate3.2 Stage Jobs
Each stage follows the worker → reviewer → (loop or advance) pattern:
3.3 State Passing Between Jobs
actions/checkoutwith the working branch between jobs3.4 Prompt Builder Scripts
action/build-refine-prompt.sh— For issue refinement stageaction/build-plan-prompt.sh— For planning stageaction/build-implement-prompt.sh— For implementation (per-phase)action/build-pr-prompt.sh— For PR creationDeliverables:
sdlc-pipeline.ymlworkflow filePhase 4: Circuit Breaker and Escalation
Goal: Implement the spinning wheel detection and human escalation paths.
4.1 Circuit Breaker Logic
shared/egg_contracts/circuit_breaker.py4.2 Escalation Actions
action/escalate.sh— Generic escalation scriptneeds-human-refinementorneeds-human-decision4.3 HITL Approval Gates
on-mention.ymlpattern for @mention responsesDeliverables:
Phase 5: Integration and Testing
Goal: End-to-end testing and refinement of the full pipeline.
5.1 Test Fixtures
5.2 Documentation
docs/index.mdwith pipeline documentation5.3 Observability
Deliverables:
Implementation Order and Dependencies
Phases 1-2 can be developed in relative isolation with unit tests.
Phase 3 depends on 1-2 but can start once contract library is stable.
Phases 4-5 are refinements that can be developed incrementally.
Estimated Scope Per Phase
Total: ~3500 LOC across ~25 files
Key Design Decisions
Why JSON contracts over markdown?
Why separate agent invocations per stage?
Why reviewer can't implement?
Why commit gates between phases?
Open Questions for Discussion
HITL at planning stage: Should plan approval always require human sign-off, or should it be configurable (auto-advance for small issues)?
Branch naming: Should pipeline create
egg-sdlc-{issue}-{phase}branches per phase, or a singleegg-{issue}branch with commits per phase?Parallel phases: Some phases might be independent. Should pipeline support parallel phase execution, or strictly sequential?
Reviewer model: Should reviewer use a different/smaller model (e.g., Haiku for fast review cycles), or same model as worker?
Let me know if you'd like me to proceed with implementation, starting with Phase 1, or if you'd like to discuss any aspects of this plan first.
— Authored by egg
james-in-a-box commentedon Feb 6, 2026
egg finished successfully. View run logs
jwbron commentedon Feb 6, 2026
@james-in-a-box review this plan
james-in-a-box commentedon Feb 6, 2026
Plan Review: Structurally Enforced Agent Checkpoints
I've reviewed the implementation plan against the issue requirements and the existing codebase. Overall, the plan is well-structured and demonstrates good understanding of the existing infrastructure. Here's my assessment:
✅ Strengths
1. Correct Infrastructure Understanding
The plan correctly identifies and builds upon:
action/) as the execution engineon-mention.ymlpatterns for HITL checkpointsshared/egg_config,shared/egg_logging)2. Phased Approach
Breaking the work into 5 phases with clear dependencies is the right approach. Each phase is scoped appropriately (~500-1200 LOC) and can be independently validated.
3. Role-Based Field Access
The design to enforce write permissions at the CLI level (
EGG_AGENT_ROLEenv var) is sound. This provides structural enforcement beyond prompt instructions.4. Contract CLI Design
Providing explicit commands (
egg-contract update-phase-commitsvsegg-contract mark-phase-passed) with role enforcement is a clean approach that makes violations obvious.1. Contract File Location
The issue specifies
.egg/contracts/{issue-number}.jsonbut the plan doesn't explicitly confirm this. The plan should specify:2. Reviewer Output Parsing
Phase 2 mentions "Action parses this output and updates contract accordingly" but doesn't detail how the reviewer's structured output gets captured. Options:
egg-contractCLI directlyThe CLI approach (reviewer calls
egg-contract mark-phase-passed) seems cleaner than parsing stdout, but this should be explicit.3. Stage Prompt Construction
Phase 3 lists prompt builder scripts (
build-refine-prompt.sh,build-plan-prompt.sh, etc.) but doesn't detail what context each provides. For example:build-implement-prompt.shneeds to include the specific phase from the contractbuild-review-prompt.shneeds to include the diff, the acceptance criteria, and the phase requirementsSuggest documenting the inputs and outputs for each prompt builder.
4. Matrix Job for Implementation
The plan mentions "Matrix job: one iteration per phase in contract" but GitHub Actions matrix jobs run in parallel by default. The implementation needs to either:
needs:)This architectural decision affects the workflow structure significantly.
🔴 Potential Gaps
1. Contract Schema Enforcement at Commit Time
The issue emphasizes "verification runs in its own context window." The plan mentions role-based CLI access, but doesn't address what happens if the implementing agent directly edits the contract JSON file via
git addinstead of using the CLI.Suggestion: Add a pre-commit hook or CI check that validates contract JSON:
2. Escalation Notification Mechanism
Phase 4 lists escalation actions (labels, draft PR, Slack, issue comments) but doesn't specify:
notifications.slack_notify)3. Resume After HITL
The plan mentions "Resume mechanism: Human adds comment or label to continue" but doesn't detail:
The existing
on-mention.ymlpattern could handle this, but the integration needs to be explicit.4. Test Strategy
Phase 5 mentions "Integration test suite" but doesn't detail:
📝 Responses to Open Questions
Q1: HITL at planning stage - always require sign-off?
Recommend: Configurable, default to optional. Add an input
require-plan-approval: true|falseto the workflow. For high-risk repos or large features, enable it. For routine work, allow auto-advance.Q2: Branch naming - per-phase or single branch?
Recommend: Single branch (
egg-{issue}) with commits per phase. Reasons:Q3: Parallel phases?
Recommend: Strictly sequential for MVP. Reasons:
Q4: Reviewer model?
Recommend: Same model for MVP. Reasons:
✅ Suggested Additions to Plan
Phase 1.5: Pre-commit Validation
Add a git pre-commit hook or CI workflow step that validates contract modifications came through the CLI, not direct edits.
Phase 3.5: Resume Workflow
Add a separate workflow or job that handles HITL resume triggers (label added, comment with approval keyword).
Documentation in Phase 2
Include a
docs/guides/sdlc-pipeline.mddeliverable that documents the pipeline stages, contract schema, and troubleshooting.Summary
The plan is ready to proceed with the clarifications noted above. I recommend:
Verdict: Plan is sound, proceed with Phase 1 after addressing architectural clarifications.
— Authored by egg
james-in-a-box commentedon Feb 6, 2026
egg finished successfully. View run logs
jwbron commentedon Feb 6, 2026
@james-in-a-box address the above feedback
james-in-a-box commentedon Feb 6, 2026
egg finished successfully. View run logs
jwbron commentedon Feb 6, 2026
@james-in-a-box address the above feedback and update the description
james-in-a-box commentedon Feb 6, 2026
egg finished successfully. View run logs
jwbron commentedon Feb 6, 2026
@james-in-a-box let's add a bit more context on planning here. I want to create a planning/task system that is enforced by this methodology. I want to have a collection of tasks that are implemented by one agent (implementer) and marked as complete by another agent (reviewer). I want to make sure that the implementer has no ability to mark tasks as complete. That must be done by the reviewer as part of the review cycle (which happens autonomously). Similarly, when decisions are marked as human in the loop, I want to only allow humans to make those decisions and mark them as decided. This can be something as simple as clicking on a checkbox on bot comments.
james-in-a-box commentedon Feb 6, 2026
Issue Description Updated: Enhanced Planning/Task System
I've updated the issue description to add comprehensive detail on the planning/task system with structural enforcement. Here's a summary of the key additions:
New: Part 2 - Task Collection and Role-Based Enforcement
Added a detailed task collection system with structural separation of concerns:
commits[],notesstatus,passes,verifiedstatus,passes,review_feedback[]commits[], task definitionsKey features:
egg-contract) enforces role-based field access viaEGG_AGENT_ROLEenvironment variable.egg/contracts/{issue-number}.jsonNew: Part 3 - Human-in-the-Loop Decision System
Added a GitHub checkbox-based HITL decision system:
hitl(human only),reviewer(reviewer agent),agent(any agent)Example checkbox interaction:
Updated: Acceptance Criteria
Expanded acceptance criteria to cover:
Resolved Open Questions
egg-{issue})The issue now provides a complete blueprint for building the multi-agent pipeline with the structural enforcement you described.
— Authored by egg
james-in-a-box commentedon Feb 6, 2026
egg finished successfully. View run logs
jwbron commentedon Feb 6, 2026
@james-in-a-box you wiped out the description. Fix that, and also open an issue covering why this happened.
17 remaining items
Add spec and implementation plan for issue #133
Add contract schema and core library for issue #133 Phase 1 (#217)
Implement Phase 2: Phase-based operation restrictions
Implement Phase 2: Phase-based operation restrictions (#243)
Implement Phase 3: Agent CLI and prompt integration
Implement Phase 3: Agent CLI and prompt integration (#245)
Implement Phase 4: Pipeline workflow for SDLC checkpoints
Implement Phase 4: Pipeline workflow for SDLC checkpoints (#252)
Implement Phase 5: Circuit breaker and escalation
Implement Phase 5: Circuit breaker and escalation (#259)
Implement Phase 6: Integration tests and documentation
Replace spec docs with SDLC pipeline architecture guide
Add SDLC pipeline architecture guide
Implement Phase 6: Integration tests and documentation (#265)