Skip to content

Commit 5d78b12

Browse files
committed
Add scenario matrix methodology
1 parent a1f3614 commit 5d78b12

18 files changed

Lines changed: 8451 additions & 25 deletions

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ temp
1313
# Python cache
1414
__pycache__/
1515
*.pyc
16+
17+
.codex
18+
*.json
19+
plan.md

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ A Claude Code plugin that provides iterative development with independent AI rev
1515
- **Iteration over Perfection** -- Instead of expecting perfect output in one shot, Humanize leverages continuous feedback loops where issues are caught early and refined incrementally.
1616
- **One Build + One Review** -- Claude implements, Codex independently reviews. No blind spots.
1717
- **Ralph Loop with Swarm Mode** -- Iterative refinement continues until all acceptance criteria are met. Optionally parallelize with Agent Teams.
18+
- **Manager-Driven Scenario Matrix** -- Humanize keeps a machine-readable task graph in `.humanize/rlcr/<timestamp>/scenario-matrix.json`, lets the top-level manager reconcile task state, projects that state back into the Goal Tracker and checkpoint contract, and can nudge a stuck agent toward a narrower recovery path without replacing the single-mainline rule.
1819
- **Begin with the End in Mind** -- Before the loop starts, Humanize verifies that *you* understand the plan you are about to execute. The human must remain the architect. ([Details](docs/usage.md#begin-with-the-end-in-mind))
1920

2021
## How It Works
@@ -25,6 +26,14 @@ A Claude Code plugin that provides iterative development with independent AI rev
2526

2627
The loop has two phases: **Implementation** (Claude works, Codex reviews summaries) and **Code Review** (Codex checks code quality with severity markers). Issues feed back into implementation until resolved.
2728

29+
New-format loops also maintain a compatibility-first manager orchestration runtime:
30+
31+
- `scenario-matrix.json` is the machine-native control plane. It stores authoritative task state, dependency edges, task packets, repair-wave clustering, checkpoint/convergence metadata, and oversight signals.
32+
- The top-level manager is the only authoritative scheduler and matrix reconciler. Execution agents implement code, while the manager assigns bounded task packets, ingests feedback, and keeps exactly one current primary objective.
33+
- Review findings first enter a raw backlog, are deduplicated and normalized into grouped issue backlogs, and only become executable tasks when the manager explicitly promotes them.
34+
- `goal-tracker.md` and `round-N-contract.md` remain human-facing compatibility views, but their mutable task sections are now projected from the matrix.
35+
- Oversight interventions such as `nudge`, `reframe`, `split`, or `resequence` only steer the active agent back onto the current task. They do not create multiple mainlines or take over implementation authority.
36+
2837
## Install
2938

3039
```bash
@@ -69,6 +78,20 @@ Requires [codex CLI](https://github.com/openai/codex) for review. See the full [
6978
humanize monitor gemini # Gemini invocations only
7079
```
7180

81+
The RLCR monitor now shows scenario-matrix readiness, the current mainline projection, the current manager checkpoint, convergence state, repair-wave context, and any active oversight action alongside the existing loop status.
82+
83+
6. **Render the current scenario matrix as an HTML dashboard**:
84+
```bash
85+
source <path/to/humanize>/scripts/humanize.sh
86+
humanize matrix # latest local RLCR session
87+
humanize matrix --input tmp.json # explicit matrix/session/state file
88+
humanize matrix --serve # local browser client with refresh
89+
```
90+
91+
`humanize matrix` generates a local HTML snapshot with the current primary objective, supporting window, dependency graph, feedback queues, recent events, and convergence/oversight status.
92+
93+
`humanize matrix --serve` starts a local HTML client on `http://127.0.0.1:<port>/`. Leave that page open and use the in-page `Refresh Snapshot` button instead of reopening freshly generated files.
94+
7295
## Monitor Dashboard
7396

7497
<p align="center">
@@ -78,6 +101,7 @@ Requires [codex CLI](https://github.com/openai/codex) for review. See the full [
78101
## Documentation
79102

80103
- [Usage Guide](docs/usage.md) -- Commands, options, environment variables
104+
- [Scenario Matrix Guide](scenario-matrix.md) -- Manager role, task packets, repair waves, and convergence flow
81105
- [Install for Claude Code](docs/install-for-claude.md) -- Full installation instructions
82106
- [Install for Codex](docs/install-for-codex.md) -- Codex skill runtime setup
83107
- [Install for Kimi](docs/install-for-kimi.md) -- Kimi CLI skill setup

docs/usage.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@ Humanize creates an iterative feedback loop with two phases:
1111

1212
The loop continues until all acceptance criteria are met or no issues remain.
1313

14+
New-format RLCR loops also keep a compatibility-first runtime artifact at `.humanize/rlcr/<timestamp>/scenario-matrix.json`. The matrix is the machine-readable control plane: it records seeded plan tasks, dependency edges, manager authority, task packets, repair waves, checkpoint/convergence state, review-driven state changes, and bounded oversight interventions when the active agent appears stuck.
15+
16+
The top-level orchestrating session acts as the **manager**. It is the only authoritative scheduler and matrix reconciler. Execution agents implement code, while the manager reviews progress, ingests findings, and keeps exactly one current `primary objective` plus a bounded supporting window.
17+
18+
Subagents do not receive the full global loop prompt by default. Instead, Humanize projects a **task packet** from the matrix that includes the current primary objective, local task, direct dependencies, downstream impact, allowed scope, success criteria, stop criteria, and explicit out-of-scope boundaries. This is how the runtime avoids "subagent single-player mode" caused by limited LLM context.
19+
20+
Review findings first enter a raw backlog, are deduplicated, and are normalized into grouped issue backlogs before the manager decides whether any of them should become executable repair tasks. Low-value or out-of-bound findings can stay deferred in a watchlist instead of automatically joining the frontier.
21+
22+
`goal-tracker.md` and `round-N-contract.md` remain the human-facing workflow. Humanize projects matrix state back into those files so the active checkpoint still has exactly one current mainline objective even when several supporting tasks are queued behind it.
23+
24+
Oversight does not replace the executing agent. It only injects bounded corrections such as `nudge`, `reframe`, `split`, `reclassify`, or `resequence` when repeated failures suggest the current method or task framing is unhealthy.
25+
1426
## Begin with the End in Mind
1527

1628
Before the RLCR loop starts any work, Humanize runs a **Plan Understanding Quiz** -- a brief pre-flight check that verifies you genuinely understand the plan you are about to execute.
@@ -64,6 +76,12 @@ The quiz is advisory, not a gate. You always have the option to proceed. But tha
6476
| `/gen-plan --input <draft.md> --output <plan.md>` | Generate structured plan from draft |
6577
| `/refine-plan --input <annotated-plan.md>` | Refine an annotated plan and generate a QA ledger |
6678
| `/ask-codex [question]` | One-shot consultation with Codex |
79+
| `humanize matrix [--input <path>] [--output <path>] [--serve]` | Render a local HTML dashboard or run a refreshable local matrix client |
80+
81+
For scenario-matrix inspection, there are now two modes:
82+
83+
- `humanize matrix` writes a static HTML snapshot next to the current matrix or session.
84+
- `humanize matrix --serve` starts a localhost HTML client. Keep that browser tab open and use the page's `Refresh Snapshot` button to pull the latest matrix view without reopening generated files.
6785

6886
## Command Reference
6987

@@ -227,6 +245,53 @@ for getting a second opinion, reviewing a design, or asking domain-specific ques
227245
Responses are saved to `.humanize/skill/<timestamp>/` with `input.md`, `output.md`,
228246
and `metadata.md` for reference.
229247

248+
### humanize matrix
249+
250+
After sourcing `scripts/humanize.sh`, you can render a scenario-matrix snapshot into a local HTML dashboard:
251+
252+
```bash
253+
source scripts/humanize.sh
254+
255+
humanize matrix
256+
humanize matrix --input .humanize/rlcr/2026-04-01_20-41-00
257+
humanize matrix --input tmp.json --output /tmp/matrix-view.html
258+
```
259+
260+
Input resolution rules:
261+
262+
- No `--input`: use the latest local RLCR session under `.humanize/rlcr/`
263+
- Session directory: resolve that session's `scenario-matrix.json`
264+
- `state.md` / `*-state.md`: follow `scenario_matrix_file` from the state file
265+
- `.json` file: render that matrix file directly
266+
- Project directory: resolve the latest local RLCR session under that project
267+
268+
The generated HTML snapshot includes:
269+
270+
- current primary objective and supporting window
271+
- task board grouped into primary/supporting/active/done/deferred buckets
272+
- dependency edges between tasks
273+
- checkpoint, convergence, and oversight status
274+
- recent events plus execution/review feedback queues
275+
- per-task detail drill-down without reading raw JSON
276+
277+
## Monitoring
278+
279+
Load the helper script and run the RLCR monitor:
280+
281+
```bash
282+
source scripts/humanize.sh
283+
humanize monitor rlcr
284+
humanize matrix
285+
```
286+
287+
The monitor remains compatible with legacy loops, but for new loops it also surfaces:
288+
289+
- scenario-matrix readiness (`ready`, `legacy`, `missing`, `invalid`, or `not_applicable`)
290+
- the current matrix-derived mainline summary
291+
- the current manager checkpoint and convergence status
292+
- the primary repair-wave or cluster context when one is active
293+
- any active oversight action currently steering the next round
294+
230295
## Configuration
231296

232297
Humanize uses a 4-layer config hierarchy (lowest to highest priority):

hooks/lib/loop-common.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ readonly FIELD_PRIVACY_MODE="privacy_mode"
4242
readonly FIELD_MAINLINE_STALL_COUNT="mainline_stall_count"
4343
readonly FIELD_LAST_MAINLINE_VERDICT="last_mainline_verdict"
4444
readonly FIELD_DRIFT_STATUS="drift_status"
45+
readonly FIELD_SCENARIO_MATRIX_FILE="scenario_matrix_file"
46+
readonly FIELD_SCENARIO_MATRIX_REQUIRED="scenario_matrix_required"
4547

4648
readonly MAINLINE_VERDICT_ADVANCED="advanced"
4749
readonly MAINLINE_VERDICT_STALLED="stalled"
@@ -407,6 +409,8 @@ _parse_state_fields() {
407409
STATE_MAINLINE_STALL_COUNT=$(echo "$STATE_FRONTMATTER" | grep "^${FIELD_MAINLINE_STALL_COUNT}:" | sed "s/${FIELD_MAINLINE_STALL_COUNT}: *//" | tr -d ' ' || true)
408410
STATE_LAST_MAINLINE_VERDICT=$(echo "$STATE_FRONTMATTER" | grep "^${FIELD_LAST_MAINLINE_VERDICT}:" | sed "s/${FIELD_LAST_MAINLINE_VERDICT}: *//" | tr -d ' ' || true)
409411
STATE_DRIFT_STATUS=$(echo "$STATE_FRONTMATTER" | grep "^${FIELD_DRIFT_STATUS}:" | sed "s/${FIELD_DRIFT_STATUS}: *//" | tr -d ' ' || true)
412+
STATE_SCENARIO_MATRIX_FILE=$(echo "$STATE_FRONTMATTER" | grep "^${FIELD_SCENARIO_MATRIX_FILE}:" | sed "s/${FIELD_SCENARIO_MATRIX_FILE}: *//; s/^\"//; s/\"\$//" || true)
413+
STATE_SCENARIO_MATRIX_REQUIRED=$(echo "$STATE_FRONTMATTER" | grep "^${FIELD_SCENARIO_MATRIX_REQUIRED}:" | sed "s/${FIELD_SCENARIO_MATRIX_REQUIRED}: *//" | tr -d ' ' || true)
410414
}
411415

412416
# Parse state file frontmatter and set variables (tolerant mode with defaults)
@@ -457,6 +461,7 @@ parse_state_file() {
457461
STATE_MAINLINE_STALL_COUNT="${STATE_MAINLINE_STALL_COUNT:-0}"
458462
STATE_LAST_MAINLINE_VERDICT="${STATE_LAST_MAINLINE_VERDICT:-$MAINLINE_VERDICT_UNKNOWN}"
459463
STATE_DRIFT_STATUS="${STATE_DRIFT_STATUS:-$DRIFT_STATUS_NORMAL}"
464+
STATE_SCENARIO_MATRIX_REQUIRED="${STATE_SCENARIO_MATRIX_REQUIRED:-false}"
460465
# STATE_REVIEW_STARTED left as-is (empty if missing, to allow schema validation)
461466

462467
return 0
@@ -536,6 +541,7 @@ parse_state_file_strict() {
536541
STATE_MAINLINE_STALL_COUNT="${STATE_MAINLINE_STALL_COUNT:-0}"
537542
STATE_LAST_MAINLINE_VERDICT="${STATE_LAST_MAINLINE_VERDICT:-$MAINLINE_VERDICT_UNKNOWN}"
538543
STATE_DRIFT_STATUS="${STATE_DRIFT_STATUS:-$DRIFT_STATUS_NORMAL}"
544+
STATE_SCENARIO_MATRIX_REQUIRED="${STATE_SCENARIO_MATRIX_REQUIRED:-false}"
539545

540546
return 0
541547
}

0 commit comments

Comments
 (0)