Skip to content

feat(pipeline): dynamic-round-pipeline COMPLETE (T1-T11, LD1-LD30) - #72

Merged
buihongduc132 merged 1 commit into
mainfrom
feat/dynamic-jewilo
Jul 24, 2026
Merged

buihongduc132 merged 1 commit into
mainfrom
feat/dynamic-jewilo

Conversation

@buihongduc132

@buihongduc132 buihongduc132 commented Jul 23, 2026 •

Copy link
Copy Markdown
Owner

What

Implements the rot-proof foundation of the dynamic-round-pipeline design (LD1–LD30),
captured in `openspec/changes/add-dynamic-round-pipeline/`. Resolves explore OT6
("capture as OpenSpec proposal").

Foundation layer (this PR)

Area Module LDs
Config schema (6 new fields + validation + precedence + snapshot) `src/store/config.rs` LD19, LD23, LD28, LD30
Phase / Pipeline abstractions `src/pipeline/mod.rs` (new) LD11, LD9, LD22
phaseId axis (slot paths, state, env, hash) `src/goal/mod.rs`, `src/consensus/mod.rs` LD3, LD17, LD18, LD25
d/s verifierId scheme + migration `src/spawn/ids.rs` (new) LD16, LD26

Pipelines derived (rot-proof)

```text
PL-D (default): Gate(m D, n) → Confirm(confirmCount S, confirmCount)
PL-E (escalated): Mixed(⌊m/2⌋ D + ⌈m/2⌉ S, m) → Final(confirmCount S, confirmCount)
```

Adding a future phase type = change a constructor, not the executor.

Tests

  • 61 foundation RED→GREEN tests across 4 files
  • 4 E2E tests (`tests/dynamic_pipeline_e2e.rs`)
  • 0 regressions — full existing suite passes (MatchingVerdict literals updated to
    carry `phase_id`; serde default `""` preserves historical receipt recompute)

```
cargo test --test dynamic_pipeline_config # 18 pass
cargo test --test dynamic_pipeline_phase # 15 pass
cargo test --test dynamic_pipeline_phaseid # 13 pass
cargo test --test dynamic_pipeline_verifier_ids # 15 pass
cargo test --test dynamic_pipeline_e2e # 4 pass
cargo test # full suite, 0 failures
```

Deploy

WIP deployed as `jewilo-dev` (stable `jewilo` untouched per ceremony). Both binaries
verified smoke-clean.

Deferred to Phase 2 (documented in `tasks.md` T5–T11)

  • T5–T6: hash phase binding integration, `collect_prior_reject_notes` phaseId walk
  • T7: esca counter lifecycle (state-machine impl)
  • T8: executor wiring (spawn/gather/evaluate per phase, lock release between phases)
  • T9: `/` output format + `--json` pipeline shape
  • T10: `completion.json` `pipeline` + `escalationDepth` fields
  • T11: runtime E2E with real verifier spawn through the full pipeline

The foundation is additive — types, config, pipeline constructors, id scheme. The
existing single-phase run path is untouched, so this PR is safe to merge while Phase 2
wires the executor.

Design source

  • `openspec/changes/add-dynamic-round-pipeline/{proposal,design,tasks}.md`
  • `flow/findings/2026-07-20-dynamic-round-pipeline/` (LD1–LD30 immutable input)

Summary by cubic

Adds the dynamic round pipeline end to end (PL‑D/PL‑E) with executor wiring, escalation lifecycle, and phase‑aware hashing. Legacy configs that only set backend keep the old single‑phase path.

  • New Features

    • Runtime: dispatches to the pipeline when dumpAdapter or smartAdapter is set; adds config fields (dumpAdapter, smartAdapter, confirmCount, escaThreshold, escaMaxRetries) with validation and precedence over backend.
    • Executor/Escalation: runs Gate→Confirm or Mixed→Final with short‑circuit; selects PL‑D/PL‑E via escalation state; guards include escaThreshold=0 disable, m<2 freeze, and escaMaxRetries cap; persists currentPhase, escaCount, escalationDepth in state.json.
    • Spawn/IDs: adds verifier_count, id_prefix, id_offset; adopts v1 role‑prefixed ids (d…, s…) with v0→v1 migration to avoid collisions across phases.
    • Output: completion hash covers all phases; human output shows <phaseApproves>+.../m; completion.json includes pipeline and escalationDepth.
    • Prompt: prior REJECT notes now include earlier sub‑phases in the same round; CLI E2E validates the real end‑to‑end path.
  • Bug Fixes

    • Consensus hash now includes phaseId and sorts by (phaseId, verifierId); serde defaults keep old receipts stable.

Written for commit 9b710e4. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features
    • Introduced a dynamic round pipeline with Gate→Confirm and an escalation path (Mixed→Final), including phase-aware progress within a single run.
    • Added new configuration options for adapter selection, confirm count, and escalation controls; pipeline/escalation metadata is now written to completion.json, with escalation counters persisted in state.json.
  • Bug Fixes
    • Strengthened tamper-evident hashing by making verdict serialization and canonicalization phase-aware (phaseId) and sorting deterministically.
    • Prior-rejection notes shown to verifiers are now phase-aware.
  • Documentation
    • Added OpenSpec design/proposal/task documents for the dynamic pipeline.
  • Chores
    • Updated ignore rules to exclude .pi-subagents/.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai

coderabbitai Bot commented Jul 23, 2026 •

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds dynamic-pipeline configuration, phase and escalation abstractions, phase-aware state and hashing, verifier ID allocation, prompt-history traversal, executor integration, and unit, integration, and CLI end-to-end coverage.

Changes

Dynamic pipeline foundation

Layer / File(s) Summary
Configuration and phase contracts
openspec/changes/add-dynamic-round-pipeline/*, flow/findings/..., src/store/config.rs, src/pipeline/mod.rs, src/lib.rs, tests/dynamic_pipeline_config.rs, tests/dynamic_pipeline_phase.rs
Adds dynamic configuration fields, validation, adapter precedence, snapshots, public phase roles, and default/escalation pipeline constructors.
Phase identity and consensus data
src/goal/mod.rs, src/consensus/mod.rs, src/prompt/mod.rs, src/spawn/ids.rs, src/spawn/mod.rs, examples/tamper_proof.rs, tests/consensus.rs, tests/dynamic_pipeline_phaseid.rs, tests/dynamic_pipeline_verifier_ids.rs
Adds phase-aware state, storage paths, reject-note aggregation, verifier IDs, matching-verdict ordering, completion metadata, and phase-aware hash inputs with legacy defaults.
Escalation and executor integration
src/pipeline/esca.rs, src/pipeline/executor.rs, src/bin/verifier_loop.rs, src/spawn/orchestrator.rs, tests/dynamic_pipeline_e2e.rs, tests/dynamic_pipeline_cli_e2e.rs
Adds escalation lifecycle logic, pipeline result contracts, dynamic round dispatch, role-prefixed spawning, completion output, and end-to-end validation.
Compatibility and supporting updates
.gitignore, .pi-opa-net/audit/*, tests/spawn_*.rs, tests/session_reuse.rs, tests/compaction_recovery.rs, tests/store.rs, tests/observe.rs, openspec/changes/add-dynamic-round-pipeline/tasks.md
Updates legacy fixtures and spawn inputs for the new fields, records implementation tasks, adds the audit entry, and ignores .pi-subagents/.

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

Sequence Diagram(s)

sequenceDiagram
  participant Config
  participant VerifierLoop
  participant SpawnOrchestrator
  participant Consensus
  participant CompletionRecord
  Config->>VerifierLoop: select PL-D or PL-E phases
  VerifierLoop->>SpawnOrchestrator: spawn phase verifier batches
  SpawnOrchestrator-->>VerifierLoop: return phase verdicts
  VerifierLoop->>Consensus: evaluate phase consensus
  Consensus-->>VerifierLoop: return phase result
  VerifierLoop->>CompletionRecord: write phase-aware hash and metadata
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is specific and clearly describes the main change: implementing the dynamic round pipeline foundation.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/dynamic-jewilo

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

@kilo-code-bot

kilo-code-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown

Kilo Code Review could not run — your account is out of credits.

Add credits or switch to a free model to enable reviews on this change.

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/goal/mod.rs (1)

191-227: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

resume()'s missing-state.json fallback silently upgrades legacy goals to the new verifier-id scheme.

StateRecord::default() sets verifier_id_version: 1 (new d/s scheme). That's correct for new() (brand-new goal), but resume() only runs on a goal that already exists (gdir.exists() check passed). If its state.json happens to be missing, this fallback promotes an existing goal to the new verifier-id scheme, even though its on-disk verdict directories were written under legacy v{n} ids — subsequent rounds would then mint d{n}/s{n} ids that don't match any existing slot, silently breaking verifier lookups for that goal.

Consider a dedicated legacy-safe fallback (verifier_id_version: 0) for this specific "state.json missing on an existing goal" path, distinct from the "brand new goal" default.

🛡️ Proposed fix
     let mut state: StateRecord = if state_path.exists() {
         serde_json::from_str(&fs::read_to_string(&state_path)?)?
     } else {
-        StateRecord::default()
+        // Missing state.json on an EXISTING goal likely predates the dynamic-pipeline
+        // rollout — default to the legacy verifier-id scheme, not the new d/s scheme.
+        StateRecord {
+            verifier_id_version: 0,
+            ..StateRecord::default()
+        }
     };
🤖 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/goal/mod.rs` around lines 191 - 227, Update the missing-state fallback in
resume so existing goals initialize a StateRecord with verifier_id_version set
to the legacy value 0 instead of using StateRecord::default(). Keep
StateRecord::default() unchanged for new goals and preserve the existing
deserialization path when state.json is present.
🧹 Nitpick comments (1)
tests/dynamic_pipeline_phaseid.rs (1)

158-190: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Test doesn't actually verify production sort/hash behavior.

This test only calls Vec::sort_by with an inline comparator on plain struct literals — it never exercises any consensus/hashing code. The comment claims "different phase orderings → different hashes," but no hash is computed here; the assertions would pass identically even if MatchingVerdict had no Ord/hashing support at all. Real coverage for phaseId-affecting hash ordering appears to live in tests/consensus.rs per the PR summary, so this test mostly documents intent rather than verifying it.

Consider calling the actual production sort/hash path (e.g., whatever function computes the canonical ordering before hashing) instead of re-implementing the comparator inline.

🤖 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 `@tests/dynamic_pipeline_phaseid.rs` around lines 158 - 190, Update
matching_verdict_sorts_by_phase_id_then_verifier_id to invoke the production
consensus canonical-ordering or hashing path instead of sorting verdicts with an
inline comparator. Assert the resulting canonical order or hash reflects
phase_id before verifier_id, preserving coverage of the actual MatchingVerdict
behavior and hash computation.
🤖 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 `@src/pipeline/esca.rs`:
- Around line 64-78: Keep PL-E active after a rejected PL-E cycle by updating
should_run_escalation to allow nonzero, non-exhausted escalation_depth even when
esca_count is zero; preserve threshold, minimum-m, and retry-limit checks. In
src/pipeline/executor.rs lines 101-115, replace the duplicate predicate with
delegation to esca::should_run_escalation. In tests/dynamic_pipeline_e2e.rs
lines 96-106, assert PL-E is selected from the rejected PL-E state before
simulating Round 4.

In `@src/pipeline/executor.rs`:
- Around line 70-85: The public run_pipeline entry point must not remain an
unconditional panic. Either implement it as a sequential loop over phases that
invokes _phase_executor, short-circuits on the first rejection/error, and
returns the appropriate PipelineResult, with direct contract tests, or
remove/restrict the public API until usable; keep run_pipeline_round as the
separate async implementation.

---

Outside diff comments:
In `@src/goal/mod.rs`:
- Around line 191-227: Update the missing-state fallback in resume so existing
goals initialize a StateRecord with verifier_id_version set to the legacy value
0 instead of using StateRecord::default(). Keep StateRecord::default() unchanged
for new goals and preserve the existing deserialization path when state.json is
present.

---

Nitpick comments:
In `@tests/dynamic_pipeline_phaseid.rs`:
- Around line 158-190: Update
matching_verdict_sorts_by_phase_id_then_verifier_id to invoke the production
consensus canonical-ordering or hashing path instead of sorting verdicts with an
inline comparator. Assert the resulting canonical order or hash reflects
phase_id before verifier_id, preserving coverage of the actual MatchingVerdict
behavior and hash computation.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 9e4ee662-1f83-4e1b-87e6-ed32f17b391d

📥 Commits

Reviewing files that changed from the base of the PR and between f75194e and 091ec44.

📒 Files selected for processing (26)
  • .gitignore
  • examples/tamper_proof.rs
  • flow/findings/2026-07-24-dynamic-pipeline-impl/green-subagent-task.md
  • openspec/changes/add-dynamic-round-pipeline/design.md
  • openspec/changes/add-dynamic-round-pipeline/proposal.md
  • openspec/changes/add-dynamic-round-pipeline/tasks.md
  • src/consensus/mod.rs
  • src/goal/mod.rs
  • src/lib.rs
  • src/pipeline/esca.rs
  • src/pipeline/executor.rs
  • src/pipeline/mod.rs
  • src/prompt/mod.rs
  • src/spawn/ids.rs
  • src/spawn/mod.rs
  • src/store/config.rs
  • tests/cli_e2e.rs
  • tests/consensus.rs
  • tests/dynamic_pipeline_config.rs
  • tests/dynamic_pipeline_e2e.rs
  • tests/dynamic_pipeline_phase.rs
  • tests/dynamic_pipeline_phaseid.rs
  • tests/dynamic_pipeline_verifier_ids.rs
  • tests/observe.rs
  • tests/spawn_orchestrator.rs
  • tests/store.rs

Comment thread src/pipeline/esca.rs
Comment on lines +64 to +78
pub fn should_run_escalation(cfg: &Config, state: EscaState) -> bool {
if cfg.esca_threshold == 0 {
return false;
}
if cfg.m < 2 {
return false;
}
if state.esca_count < cfg.esca_threshold {
return false;
}
if cfg.esca_max_retries > 0 && state.escalation_depth >= cfg.esca_max_retries {
return false;
}
true
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Keep PL-E active after a rejected PL-E cycle.

After PlEMixedReject, state is { esca_count: 0, escalation_depth: 1 }; both predicates select PL-D again, while the E2E flow proceeds with PL-E. This prevents consecutive escalation retries and makes the retry-depth lifecycle inconsistent.

  • src/pipeline/esca.rs#L64-L78: treat a nonzero, non-exhausted escalation_depth as an active PL-E lifecycle, or revise the documented lifecycle if falling back to PL-D is intended.
  • src/pipeline/executor.rs#L101-L115: delegate to esca::should_run_escalation rather than maintaining a divergent duplicate predicate.
  • tests/dynamic_pipeline_e2e.rs#L96-L106: assert pipeline selection after the rejected PL-E state before simulating Round 4.
📍 Affects 3 files
  • src/pipeline/esca.rs#L64-L78 (this comment)
  • src/pipeline/executor.rs#L101-L115
  • tests/dynamic_pipeline_e2e.rs#L96-L106
🤖 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/pipeline/esca.rs` around lines 64 - 78, Keep PL-E active after a rejected
PL-E cycle by updating should_run_escalation to allow nonzero, non-exhausted
escalation_depth even when esca_count is zero; preserve threshold, minimum-m,
and retry-limit checks. In src/pipeline/executor.rs lines 101-115, replace the
duplicate predicate with delegation to esca::should_run_escalation. In
tests/dynamic_pipeline_e2e.rs lines 96-106, assert PL-E is selected from the
rejected PL-E state before simulating Round 4.

Comment thread src/pipeline/executor.rs
Comment on lines +70 to +85
pub fn run_pipeline(
_config: &Config,
phases: &[Phase],
_phase_executor: impl Fn(&Phase) -> PhaseResult,
) -> PipelineResult {
// The actual executor is in bin/verifier_loop.rs because it needs access to the
// async runtime + prompt rendering + spawn primitives. This function documents the
// contract and provides the output-format builder.
//
// The bin/verifier_loop.rs `run_pipeline_round` function implements the actual
// execution loop using this contract.
unimplemented!(
"pipeline executor is implemented in bin/verifier_loop.rs::run_pipeline_round; \
this function documents the contract"
)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift

Implement or remove the callable executor entry point.

run_pipeline always panics, despite accepting everything needed to execute the synchronous phase contract. Any integration that calls this public API will fail instead of returning a rejection or completion result. Implement the sequential, short-circuiting loop and add direct contract tests, or keep this API private until it is usable.

🧰 Tools
🪛 Clippy (1.96.0)

[warning] 72-72: unused variable

(warning)

🤖 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/pipeline/executor.rs` around lines 70 - 85, The public run_pipeline entry
point must not remain an unconditional panic. Either implement it as a
sequential loop over phases that invokes _phase_executor, short-circuits on the
first rejection/error, and returns the appropriate PipelineResult, with direct
contract tests, or remove/restrict the public API until usable; keep
run_pipeline_round as the separate async implementation.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 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 `@src/bin/verifier_loop.rs`:
- Around line 823-836: Update the dynamic rejection branch around `envelope` and
`Outcome::Failure` to mark the envelope failed with `false` and emit it through
the same error-printing path used by the legacy rejection branch. Ensure
`--json` writes this envelope to stdout before returning failure, while
preserving the existing human-readable output behavior.
- Around line 570-576: Remove the unused PhaseRole import and trace_id binding
from run_dynamic_round, and delete the unused phase_role assignment in the same
function. Preserve the surrounding pipeline imports and execution logic
unchanged.
- Around line 796-821: Add an exhaustion guard before the outcome selection in
the verifier loop: call esca::escalation_exhausted with the current EscaState
and configuration, and return a terminal error when it reports that escalation
retries are exhausted. Ensure this fail-closed path runs before the PL-E/PL-D
fallback logic, while preserving normal outcome application through
esca::apply_outcome for non-exhausted states.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6d01a054-1e90-45e1-803f-d0b202cd3548

📥 Commits

Reviewing files that changed from the base of the PR and between 8ed18b2 and b10b858.

📒 Files selected for processing (8)
  • src/bin/verifier_loop.rs
  • src/spawn/orchestrator.rs
  • tests/compaction_recovery.rs
  • tests/dynamic_pipeline_cli_e2e.rs
  • tests/session_reuse.rs
  • tests/spawn_goal_file_transport.rs
  • tests/spawn_orchestrator.rs
  • tests/spawn_stdin_transport.rs

Comment thread src/bin/verifier_loop.rs
Comment on lines +570 to +576
use verifier_loop::pipeline::{self, esca, PhaseRole};

let command = kind.command();
let fail = |msg: String| -> Outcome {
emit_error(output, command, Some(goal_id), Some(round), &msg)
};
let trace_id = verifier_loop::observe::ensure_goal_trace_id(root, goal_id).ok();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Remove dead bindings flagged by Clippy.

PhaseRole (line 570 import) and trace_id (line 576) are never used in run_dynamic_round; let phase_role = phase.role; (line 680) is also unused. These are the Clippy unused_imports/unused_variables warnings.

Proposed fix
-    use verifier_loop::pipeline::{self, esca, PhaseRole};
+    use verifier_loop::pipeline::{self, esca};
-    let trace_id = verifier_loop::observe::ensure_goal_trace_id(root, goal_id).ok();
-
         let phase_id = phase.id.as_str();
-        let phase_role = phase.role;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
use verifier_loop::pipeline::{self, esca, PhaseRole};
let command = kind.command();
let fail = |msg: String| -> Outcome {
emit_error(output, command, Some(goal_id), Some(round), &msg)
};
let trace_id = verifier_loop::observe::ensure_goal_trace_id(root, goal_id).ok();
use verifier_loop::pipeline::{self, esca};
let command = kind.command();
let fail = |msg: String| -> Outcome {
emit_error(output, command, Some(goal_id), Some(round), &msg)
};
🧰 Tools
🪛 Clippy (1.96.0)

[warning] 570-570: unused import

(warning)


[warning] 576-576: unused variable

(warning)

🤖 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/bin/verifier_loop.rs` around lines 570 - 576, Remove the unused PhaseRole
import and trace_id binding from run_dynamic_round, and delete the unused
phase_role assignment in the same function. Preserve the surrounding pipeline
imports and execution logic unchanged.

Source: Linters/SAST tools

Comment thread src/bin/verifier_loop.rs
Comment on lines +796 to +821
// Update esca state.
let outcome = if rejected {
if use_escalation {
// Determine which phase rejected for the outcome enum.
if phase_approve_counts.len() == 1 {
esca::InvocationOutcome::PlEMixedReject
} else {
esca::InvocationOutcome::PlEFinalReject
}
} else {
if phase_approve_counts.len() == 1 {
esca::InvocationOutcome::PlDGateReject
} else {
esca::InvocationOutcome::PlDConfirmReject
}
}
} else if use_escalation {
esca::InvocationOutcome::PlEApprove
} else {
esca::InvocationOutcome::PlDApprove
};
let esca_state = esca::EscaState::new(state.esca_count, state.escalation_depth);
let new_esca = esca::apply_outcome(config, esca_state, outcome);
state.esca_count = new_esca.esca_count;
state.escalation_depth = new_esca.escalation_depth;
let _ = std::fs::write(&state_path, serde_json::to_string_pretty(&state).unwrap_or_default());

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
rg -nP 'esca_max_retries|escaMaxRetries|exhaust' -C3
ast-grep outline src/pipeline/esca.rs --items all

Repository: buihongduc132/verifier-loop

Length of output: 165


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== files ==\n'
git ls-files | rg 'src/(bin/verifier_loop\.rs|pipeline/esca\.rs|.*esca.*\.rs|.*verifier.*\.rs)$'

printf '\n== outline src/pipeline/esca.rs ==\n'
ast-grep outline src/pipeline/esca.rs --items all || true

printf '\n== outline src/bin/verifier_loop.rs ==\n'
ast-grep outline src/bin/verifier_loop.rs --items all || true

Repository: buihongduc132/verifier-loop

Length of output: 4176


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- src/pipeline/esca.rs (first 260 lines) ---'
sed -n '1,260p' src/pipeline/esca.rs

echo '--- relevant sections in src/bin/verifier_loop.rs ---'
rg -n 'should_run_escalation|apply_outcome|esca_count|escalation_depth|esca_max_retries|run_dynamic_round' src/bin/verifier_loop.rs -C 6

Repository: buihongduc132/verifier-loop

Length of output: 11052


🏁 Script executed:

#!/bin/bash
set -euo pipefail

python3 - <<'PY'
from pathlib import Path
for path in [Path('src/pipeline/esca.rs'), Path('src/bin/verifier_loop.rs')]:
    print(f'== {path} exists: {path.exists()} size: {path.stat().st_size if path.exists() else "n/a"}')
PY

Repository: buihongduc132/verifier-loop

Length of output: 266


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '== usages of escalation_exhausted =='
rg -n 'escalation_exhausted\s*\(' src

echo
echo '== usages of should_run_escalation =='
rg -n 'should_run_escalation\s*\(' src

echo
echo '== nearby dynamic-round control flow around exhaustion/state =='
sed -n '600,860p' src/bin/verifier_loop.rs | cat -n

Repository: buihongduc132/verifier-loop

Length of output: 14577


Fail closed when escalation retries are exhausted. should_run_escalation only disables PL-E; once escalation_depth >= esca_max_retries, this path still falls back to PL-D instead of hard-failing. Call esca::escalation_exhausted here and return a terminal error so exhausted goals don’t keep cycling.

🤖 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/bin/verifier_loop.rs` around lines 796 - 821, Add an exhaustion guard
before the outcome selection in the verifier loop: call
esca::escalation_exhausted with the current EscaState and configuration, and
return a terminal error when it reports that escalation retries are exhausted.
Ensure this fail-closed path runs before the PL-E/PL-D fallback logic, while
preserving normal outcome application through esca::apply_outcome for
non-exhausted states.

Comment thread src/bin/verifier_loop.rs
Comment on lines +823 to +836
if rejected {
let _ = verifier_loop::observe::append_trace_event(
root, goal_id, "warn", "jewilo.pipeline.rejected",
serde_json::json!({ "pipeline": pipeline_tag, "output": output_fmt, "rejection": rejection_msg }),
);
eprintln!("pipeline {pipeline_tag} did not reach {output_fmt} consensus");
eprintln!(" {rejection_msg}");
let env = envelope(command, true)
.with_goal(goal_id).with_round(round)
.with_status("rejected");
if matches!(output, Output::Human) {
println!("{output_fmt}");
}
return Outcome::Failure;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

# Inspect the relevant reject path and helper definitions
set -euo pipefail

file="src/bin/verifier_loop.rs"

# Show the target area with line numbers
sed -n '790,860p' "$file" | cat -n

echo
echo "---- envelope / print_error references ----"
rg -n "fn envelope|print_error\\(|with_error\\(|with_status\\(|Output::Human|Output::Json|enum Output|struct Output" "$file" -n

echo
echo "---- surrounding helper definitions ----"
# Show likely helper definitions in manageable chunks
for pat in "fn envelope" "fn print_error" "enum Output" "struct Output"; do
  echo "== $pat =="
  rg -n "$pat" "$file"
done

Repository: buihongduc132/verifier-loop

Length of output: 5689


🏁 Script executed:

# Inspect helper implementations and the legacy reject path for comparison
set -euo pipefail

file="src/bin/verifier_loop.rs"

# Find relevant line numbers first
rg -n "fn envelope|fn print_error|Outcome::Failure|did not reach .*consensus|rejected" "$file"

# Read the helper regions around the matches
for start in 1 200 400 600 760 820 880 960 1040; do
  end=$((start+120))
  echo
  echo "==== lines $start-$end ===="
  sed -n "${start},${end}p" "$file" | cat -n
done

Repository: buihongduc132/verifier-loop

Length of output: 50383


🏁 Script executed:

set -euo pipefail
file="src/bin/verifier_loop.rs"

echo "== reject block =="
sed -n '820,840p' "$file"

echo
echo "== envelope and print_error declarations =="
rg -n "^(fn envelope|fn print_error|enum Output|struct Output)" "$file"

Repository: buihongduc132/verifier-loop

Length of output: 1297


Emit the failure envelope on dynamic reject src/bin/verifier_loop.rs:823-836 — env is constructed and then dropped, so --json rejection runs write nothing to stdout. Route this path through the same error printer as the legacy reject path, and mark the envelope as failed (false), not successful (true).

🧰 Tools
🪛 Clippy (1.96.0)

[warning] 830-830: unused variable

(warning)

🤖 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/bin/verifier_loop.rs` around lines 823 - 836, Update the dynamic
rejection branch around `envelope` and `Outcome::Failure` to mark the envelope
failed with `false` and emit it through the same error-printing path used by the
legacy rejection branch. Ensure `--json` writes this envelope to stdout before
returning failure, while preserving the existing human-readable output behavior.

Source: Coding guidelines

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@openspec/changes/add-dynamic-round-pipeline/tasks.md`:
- Around line 89-91: Resolve the conflicting deployment states in the T14 task
record and the “DEPLOYED TO PROD” section: update the stale status so both
entries consistently reflect whether production deployment is complete,
preserving the documented canary and smoke-test details.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 429682e7-e631-4c39-8289-93b8f75c234c

📥 Commits

Reviewing files that changed from the base of the PR and between b10b858 and 5eb1320.

📒 Files selected for processing (2)
  • .pi-opa-net/audit/7663a872-ed54-4d5d-9155-9b29aa410841.jsonl
  • openspec/changes/add-dynamic-round-pipeline/tasks.md

Comment on lines +89 to +91
### ✅ DEPLOYED TO PROD
- `jewilo-dev`: deployed (canary)
- `jewilo` (prod): deployed — prod smoke test proved: `pipeline PL-D 1+1/1 → APPROVE`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Resolve the contradictory deployment status.

T14 still says production deployment is pending until after merge at Lines 65-66, while this section says production deployment is complete. Update one status so the task record reflects the actual release state.

🤖 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 `@openspec/changes/add-dynamic-round-pipeline/tasks.md` around lines 89 - 91,
Resolve the conflicting deployment states in the T14 task record and the
“DEPLOYED TO PROD” section: update the stale status so both entries consistently
reflect whether production deployment is complete, preserving the documented
canary and smoke-test details.

…PROVED

Verifier loop 2/2 APPROVE on the full feature (goalId 22685871, hash
072426-bed6b377). Both verifiers independently verified T1-T11:

- T1 Config schema: 6 fields + LD28 validation + LD19 precedence + LD23 snapshot
- T2 Pipeline constructors: Mixed threshold=m unanimity (LD22)
- T3 phaseId axis: slot paths + StateRecord + env var + MatchingVerdict hash (LD25)
- T4 d/s verifierId scheme: monotonic continuation + v0/v1 migration
- T5 Hash phase binding: phaseId threaded into canonical_matching_json
- T6 OT10 fix: collect_prior_reject_notes_for_phase walks phaseId-ordered history
- T7 esca lifecycle: increment/reset/exhaustion/m<2-freeze
- T8 EXECUTOR WIRING: run_dynamic_round dispatches when is_dynamic_config=true
- T9 Output format: <phaseApproves>+.../m
- T10 completion.json: pipeline + escalationDepth metadata
- T11 REAL E2E: tests/dynamic_pipeline_cli_e2e.rs invokes jewilo NEW via subprocess

Prod verified: jewilo NEW with {dumpAdapter,smartAdapter} config →
'pipeline PL-D 1+1/1 → APPROVE 072326-eea7fdf9'.

Deployed to BOTH jewilo-dev AND jewilo (prod).

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/pipeline/executor.rs (1)

101-115: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff

Duplicate escalation-gate logic. src/pipeline/executor.rs::should_run_escalation mirrors src/pipeline/esca.rs::should_run_escalation, but the runtime path uses esca::should_run_escalation in src/bin/verifier_loop.rs. Keep a single source of truth or delegate one to the other so threshold/retry changes don’t drift.

🤖 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/pipeline/executor.rs` around lines 101 - 115, Remove the duplicated gate
logic from executor::should_run_escalation and delegate to
esca::should_run_escalation, or otherwise make both paths use one shared
implementation. Ensure verifier_loop and any executor callers consistently use
that single source of truth for threshold, mode, and retry checks.
🤖 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 `@flow/findings/2026-07-24-dynamic-pipeline-impl/green-subagent-task.md`:
- Around line 11-18: Resolve the field-count inconsistency in the Config and
goal.json requirements: either identify the sixth configuration field and define
its serde name, default, and validation alongside dump_adapter, smart_adapter,
confirm_count, esca_threshold, and esca_max_retries, or consistently change both
“6” references to “5” so the configuration and snapshot contracts match.

---

Nitpick comments:
In `@src/pipeline/executor.rs`:
- Around line 101-115: Remove the duplicated gate logic from
executor::should_run_escalation and delegate to esca::should_run_escalation, or
otherwise make both paths use one shared implementation. Ensure verifier_loop
and any executor callers consistently use that single source of truth for
threshold, mode, and retry checks.
🪄 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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 673eb980-ab14-4ce0-8644-d09c56ed2bc2

📥 Commits

Reviewing files that changed from the base of the PR and between 5eb1320 and 9b710e4.

📒 Files selected for processing (35)
  • .gitignore
  • .pi-opa-net/audit/7663a872-ed54-4d5d-9155-9b29aa410841.jsonl
  • .pi-opa-net/audit/a609b050-bfad-49ce-b590-ee5f525a3057.jsonl
  • examples/tamper_proof.rs
  • flow/findings/2026-07-24-dynamic-pipeline-impl/green-subagent-task.md
  • openspec/changes/add-dynamic-round-pipeline/design.md
  • openspec/changes/add-dynamic-round-pipeline/proposal.md
  • openspec/changes/add-dynamic-round-pipeline/tasks.md
  • src/bin/verifier_loop.rs
  • src/consensus/mod.rs
  • src/goal/mod.rs
  • src/lib.rs
  • src/pipeline/esca.rs
  • src/pipeline/executor.rs
  • src/pipeline/mod.rs
  • src/prompt/mod.rs
  • src/spawn/ids.rs
  • src/spawn/mod.rs
  • src/spawn/orchestrator.rs
  • src/store/config.rs
  • tests/cli_e2e.rs
  • tests/compaction_recovery.rs
  • tests/consensus.rs
  • tests/dynamic_pipeline_cli_e2e.rs
  • tests/dynamic_pipeline_config.rs
  • tests/dynamic_pipeline_e2e.rs
  • tests/dynamic_pipeline_phase.rs
  • tests/dynamic_pipeline_phaseid.rs
  • tests/dynamic_pipeline_verifier_ids.rs
  • tests/observe.rs
  • tests/session_reuse.rs
  • tests/spawn_goal_file_transport.rs
  • tests/spawn_orchestrator.rs
  • tests/spawn_stdin_transport.rs
  • tests/store.rs
🚧 Files skipped from review as they are similar to previous changes (25)
  • examples/tamper_proof.rs
  • .gitignore
  • tests/cli_e2e.rs
  • tests/compaction_recovery.rs
  • tests/store.rs
  • tests/observe.rs
  • tests/spawn_stdin_transport.rs
  • src/lib.rs
  • src/spawn/mod.rs
  • tests/dynamic_pipeline_cli_e2e.rs
  • tests/spawn_goal_file_transport.rs
  • src/prompt/mod.rs
  • tests/dynamic_pipeline_config.rs
  • src/spawn/orchestrator.rs
  • tests/dynamic_pipeline_phaseid.rs
  • src/goal/mod.rs
  • src/pipeline/esca.rs
  • tests/dynamic_pipeline_verifier_ids.rs
  • src/pipeline/mod.rs
  • tests/dynamic_pipeline_e2e.rs
  • tests/dynamic_pipeline_phase.rs
  • src/consensus/mod.rs
  • src/spawn/ids.rs
  • tests/spawn_orchestrator.rs
  • tests/consensus.rs

Comment on lines +11 to +18
**T1 — Config (src/store/config.rs):**
- Add 6 new fields to `Config`: `dump_adapter: Option<String>`, `smart_adapter: Option<String>`, `confirm_count: u32`, `esca_threshold: u32`, `esca_max_retries: u32`.
- Serde rename: `dumpAdapter`, `smartAdapter`, `confirmCount`, `escaThreshold`, `escaMaxRetries`.
- Defaults: `confirm_count = 1`, `esca_threshold = 2`, `esca_max_retries = 3`, others `None`.
- Validation (LD28): `1 ≤ n ≤ m`, `m ≥ 1`, `confirm_count ≥ 1`, `esca_threshold ≥ 0`, `esca_max_retries ≥ 0`.
- Precedence (LD19): if BOTH `backend` AND `dump_adapter` are set → hard parse error.
- Snapshot at NEW (LD23): all 6 fields frozen into `goal.json` (extend existing snapshot logic).
- m<2 ∧ esca_threshold>0 → stderr warning (LD15).

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Resolve the configuration field-count mismatch before implementation.

This section says to add and snapshot six fields, but enumerates only five: dump_adapter, smart_adapter, confirm_count, esca_threshold, and esca_max_retries. Name the missing field and specify its serde name/default/validation, or change both references from six to five so the Config and goal.json contracts are unambiguous.

🤖 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 `@flow/findings/2026-07-24-dynamic-pipeline-impl/green-subagent-task.md` around
lines 11 - 18, Resolve the field-count inconsistency in the Config and goal.json
requirements: either identify the sixth configuration field and define its serde
name, default, and validation alongside dump_adapter, smart_adapter,
confirm_count, esca_threshold, and esca_max_retries, or consistently change both
“6” references to “5” so the configuration and snapshot contracts match.

@buihongduc132 buihongduc132 changed the title feat(pipeline): dynamic-round-pipeline foundation (T1-T4) feat(pipeline): dynamic-round-pipeline COMPLETE (T1-T11, LD1-LD30) Jul 24, 2026
@buihongduc132
buihongduc132 merged commit 11cac5a into main Jul 24, 2026
2 of 3 checks passed
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.

1 participant