Skip to content

feat: parent-delegated consultation mode for porch - #623

Closed
timeleft-- wants to merge 3 commits into
cluesmith:mainfrom
MachineWisdomAI:feature/parent-consultation-upstream
Closed

timeleft-- wants to merge 3 commits into
cluesmith:mainfrom
MachineWisdomAI:feature/parent-consultation-upstream

Conversation

@timeleft--

Copy link
Copy Markdown
Contributor

Summary

Adds a new consultation mode to porch that delegates phase reviews to the parent session instead of spawning cold-start consult API calls.

  • When porch.consultation is set to "parent" in af-config.json, porch emits phase-review-* gates at phase boundaries instead of running consult commands
  • The parent (architect) session reviews builder work and approves gates via porch approve
  • Gate names are scoped to phase/planPhase/iteration to prevent stale gates from blocking after rollback
  • Falls back to "default" mode (standard consult commands) when config is missing or invalid

Closes #614

Changes

  • config.ts: New loadConsultationMode() function reads porch.consultation from af-config.json
  • next.ts: Gate-intercept logic in handleBuildVerify() — emits phase-review-{phase}-{planPhase}-iter{N} gates; next() checks for pending phase-review gates before advancing
  • index.ts: Shows CONSULTATION: parent in porch status output
  • config.test.ts: 8 unit tests for loadConsultationMode()

Configuration

{
  "porch": {
    "consultation": "parent"
  }
}

Gate format

phase-review-{phase}-{planPhase}-iter{iteration}

Example: phase-review-implement-phase_1-iter1

Dogfooding

This feature has been dogfooded extensively on the MachineWisdomAI fork:

Test plan

  • loadConsultationMode() returns "parent" when configured, "default" otherwise (8 unit tests)
  • Phase-review gates emit at each phase boundary in parent mode
  • Stale gates from previous iterations don't block after rollback
  • porch status displays consultation mode
  • All 229 porch tests pass
  • Builds clean with no type errors

🤖 Generated with Claude Code

timeleft-- and others added 3 commits March 17, 2026 13:49
When af-config.json has porch.consultation: "parent", porch emits
scoped phase-review gates instead of consult commands. The builder
blocks, the parent session reviews and approves.

- config.ts: loadConsultationMode() reads from af-config.json
- next.ts: gate-intercept in handleBuildVerify() + gate check in next()
- index.ts: porch status shows CONSULTATION mode when configured
- config.test.ts: 8 new tests for loadConsultationMode

All 225 porch tests pass.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Address GPT 5.3 Codex review findings:
- Scope phase-review gate check to current phase/planPhase/iteration
  instead of scanning all phase-review-* keys (prevents stale gate
  deadlocks after rollback)
- Improve handleVerifyApproved messaging for empty reviews (parent
  mode says "Approved via parent-delegated phase-review gate")

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
loadConsultationMode() used findConfigRoot() which is from the artifact
resolver feature (not yet upstream). Since af-config.json is symlinked
into builder worktrees, we can resolve it directly from workspaceRoot.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@waleedkadous

Copy link
Copy Markdown
Contributor

Hey — thanks for this work! Just a heads up: PR #624 (merged as part of the v3.0.0-rc.8 config overhaul) added pluggable consultation models to porch, including a "parent" mode that emits phase-review-{phase} gates instead of running consult commands.

Could you take a look and let us know whether #624 already covers what this PR was doing, or if there's still functionality here that's additive? The main things I'd want to compare are the gate naming convention and the rollback-safety logic.

Also note that af-config.json has been replaced by .codev/config.json with a unified config loader, so this PR would need updating either way.

@timeleft--

Copy link
Copy Markdown
Contributor Author

Closing — v3.0.0 (PR #624) implemented pluggable consultation models including parent-delegated mode via porch.consultation.models: 'parent'. This PR's functionality is fully covered by the new architecture.

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.

feat: parent-delegated consultation mode for porch

2 participants