Skip to content

Commit 9f0c4e7

Browse files
committed
feat(flow): expand codex control plane and daemon APIs
1 parent 329865c commit 9f0c4e7

31 files changed

Lines changed: 6747 additions & 225 deletions

docs/codex-first-control-plane-roadmap.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,24 @@ The result is "good pieces, weak control plane".
6363

6464
These are enough to start. The missing work is unification.
6565

66+
## Constraint: no Codex fork
67+
68+
Flow should target current upstream Codex directly.
69+
70+
That means:
71+
72+
- prefer wrapper transport + config over patching Codex
73+
- use stable upstream surfaces like normal user skill roots, `skills/list`, and `thread/*`
74+
- treat newer upstream features such as `skills/list perCwdExtraUserRoots` and in-process app-server clients as accelerators, not prerequisites
75+
- keep repo-specific behavior in Flow or repo executors, not in a private Codex fork
76+
6677
## Proposed Architecture
6778

68-
### 1. `codexd`: long-lived Codex control daemon
79+
### 1. warm Codex control layer
6980

70-
Add a Flow-managed daemon, either as an extension of `ai-taskd` or as a focused
71-
`codexd`, with one warm `codex app-server` connection per repo.
81+
Add a Flow-managed warm control layer, either as an extension of `ai-taskd`, a
82+
focused `codexd`, or a lighter in-process broker where that is enough for the
83+
current upstream Codex client surface.
7284

7385
Responsibilities:
7486

docs/commands/ai.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,14 @@ Notes:
127127

128128
Flow can also materialize tiny per-launch runtime skills for current upstream Codex without forking Codex.
129129

130-
Enable it with:
130+
Enable it globally with:
131+
132+
```bash
133+
f codex enable-global --full
134+
f codex doctor --path ~/docs --assert-runtime --assert-schedule
135+
```
136+
137+
Or configure it manually with:
131138

132139
```toml
133140
[codex]
@@ -148,9 +155,25 @@ Inspect or clear runtime state:
148155
```bash
149156
f codex runtime show
150157
f codex runtime clear
158+
f codex memory status
159+
f codex memory query --path ~/code/flow "codex control plane runtime skills"
160+
f codex memory recent --path ~/docs
151161
f codex doctor
152162
```
153163

164+
Assertive health checks:
165+
166+
```bash
167+
f codex doctor --path ~/docs --assert-runtime
168+
f codex doctor --path ~/docs --assert-schedule
169+
f codex doctor --path ~/docs --assert-learning
170+
f codex doctor --path ~/docs --assert-autonomous
171+
```
172+
173+
`--assert-learning` is intentionally strict: it fails until Flow has real
174+
logged events, grounded outcome samples, and a non-empty scorecard for that
175+
target.
176+
154177
Built-in plan writer:
155178

156179
```bash
@@ -169,16 +192,32 @@ Codex usage history without replaying Codex in the hot path.
169192
Useful commands:
170193

171194
```bash
195+
f codex memory sync --limit 400
196+
f codex memory recent --path ~/work/example-project --limit 12
172197
f codex skill-eval show --path ~/work/example-project
173198
f codex skill-eval run --path ~/work/example-project
174199
f codex skill-eval cron --limit 400 --max-targets 12 --within-hours 168
175200
f codex skill-source list --path ~/work/example-project
176201
f codex skill-source sync --path ~/work/example-project --skill find-skills
177202
```
178203

204+
The Codex memory mirror:
205+
206+
- stores durable indexed memory under the Jazz2 root (`~/.jazz2/...` or `~/repos/garden-co/jazz2/.jazz2/...`)
207+
- mirrors Flow’s route/outcome history into SQLite with WAL enabled
208+
- extracts compact repo/code facts from repo capsules (summary, commands, important paths, docs hints)
209+
- adds bounded live code-path retrieval for explicit repo references, so prompts like `see ~/code/flow ...` can inject likely files such as `src/ai.rs` or `docs/...` without dumping raw source
210+
- indexes durable repo entrypoints and extracted symbols under the same Jazz2-rooted memory store, then supplements them with live symbol extraction from the top-ranked code files during `memory query` / `codex resolve`
211+
- adds tiny symbol snippets for the top code hits, so coding prompts can carry actual struct/function shape without inlining whole files
212+
- biases retrieval by intent: implementation/file-edit prompts prefer symbols, snippets, and `src/...` paths; summary/docs prompts prefer doc headings and docs paths
213+
- stays best-effort so failed memory writes do not block normal Codex coding turns
214+
- is refreshed again by `f codex skill-eval cron`, so the mirror heals even if a hot-path write is skipped
215+
- is queried automatically for explicit repo references during `f codex open` / `f codex resolve`
216+
179217
What `cron` does:
180218

181219
- scans only recent logged Flow Codex events
220+
- syncs recent skill-eval logs into the Jazz2-backed memory mirror
182221
- skips missing/moved repo paths
183222
- rebuilds scorecards for a bounded number of recent repos
184223
- never launches Codex or replays network work in the background
@@ -195,6 +234,8 @@ f codex-skill-eval-launchd-status
195234
f codex-skill-eval-launchd-logs
196235
```
197236

237+
`f codex enable-global --full` installs this schedule for you.
238+
198239
Default schedule:
199240

200241
- every 30 minutes

docs/commands/db.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ Create Jazz2 app credentials and populate env vars for the current project.
1616
f db jazz new --kind mirror --name gitedit-mirror
1717
```
1818

19+
Resolution order for the credential bootstrap helper:
20+
21+
1. Local `jazz-tools` binary on `PATH`
22+
2. Pinned `npx --yes jazz-tools@0.20.14`
23+
24+
For deliberate experiments, override the pinned fallback with:
25+
26+
```bash
27+
FLOW_JAZZ_TOOLS_PACKAGE_SPEC=jazz-tools@<version> f db jazz new --kind mirror
28+
```
29+
1930
## Postgres
2031

2132
Run Drizzle migrations for the default Postgres project (`~/org/la/la/server`).

docs/everruns-maple-runbook.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ For optimized mirror (remote ClickHouse + durable local spool), also set:
4848

4949
```bash
5050
f env set SEQ_CH_MODE=mirror
51-
f env set SEQ_CH_MEM_PATH=~/repos/ClickHouse/ClickHouse/user_files/seq_mem.jsonl
52-
f env set SEQ_CH_LOG_PATH=~/repos/ClickHouse/ClickHouse/user_files/seq_trace.jsonl
51+
f env set SEQ_CH_MEM_PATH=~/.config/flow/rl/seq_mem.jsonl
52+
f env set SEQ_CH_LOG_PATH=~/.config/flow/rl/seq_trace.jsonl
5353
```
5454

5555
## 2) Run with env injected

docs/flow-toml-spec.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ fr = "f run"
146146
- `runtime_skills`: when true, `f codex open` may materialize Flow-managed per-launch runtime skills for wrapper transports.
147147
- `[[codex.reference_resolver]]`: repo-specific reference unrollers with wildcard `match` patterns and a shell `command` template.
148148
- command templates support `{{ref}}`, `{{query}}`, and `{{cwd}}`.
149+
- `f codex enable-global --full` writes the global wrapper/runtime baseline into `~/.config/flow/flow.toml` for you.
149150
- `[skills.seq]`: optional defaults for `f skills fetch ...` (local seq scraper integration).
150151
- `[commit]`: optional commit workflow defaults; plain `f commit` uses fast commit + deferred Codex deep review by default. Set `quick-default = false` to make plain `f commit` run blocking review instead.
151152
- `[task_resolution]`: optional policy for nested task discovery (`f <scope>:<task>`, preferred scopes, and per-task routes when plain names collide).

docs/rl-signal-capture-runbook.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ From `~/code/flow`:
2727
export FLOW_RL_SIGNALS=true
2828
export FLOW_RL_SIGNALS_PATH=out/logs/flow_rl_signals.jsonl
2929
export FLOW_RL_SIGNALS_SEQ_MIRROR=true
30-
export FLOW_RL_SIGNALS_SEQ_PATH=~/repos/ClickHouse/ClickHouse/user_files/seq_mem.jsonl
30+
export FLOW_RL_SIGNALS_SEQ_PATH=~/.config/flow/rl/seq_mem.jsonl
3131
export FLOW_RL_SIGNAL_TEXT=snippet
3232
export FLOW_RL_SIGNAL_MAX_CHARS=4000
3333
```

flow.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ description = "Summarize RL signal counts, errors, and latency percentiles."
120120

121121
[[tasks]]
122122
name = "rl-dataset-build"
123-
command = "python3 ./scripts/build_rl_runtime_dataset.py --harbor-dir ${HARBOR_DIR:-$HOME/repos/laude-institute/harbor} --flow-signals ${FLOW_RL_SIGNALS_PATH:-out/logs/flow_rl_signals.jsonl} --seq-mem ${SEQ_CH_MEM_PATH:-$HOME/repos/ClickHouse/ClickHouse/user_files/seq_mem.jsonl} --write-latest $@"
123+
command = "python3 ./scripts/build_rl_runtime_dataset.py --harbor-dir ${HARBOR_DIR:-$HOME/repos/laude-institute/harbor} --flow-signals ${FLOW_RL_SIGNALS_PATH:-out/logs/flow_rl_signals.jsonl} --seq-mem ${SEQ_CH_MEM_PATH:-$HOME/.config/flow/rl/seq_mem.jsonl} --write-latest $@"
124124
description = "Build Harbor-ready RL dataset snapshot from flow+seq runtime signals."
125125

126126
[[tasks]]
@@ -491,12 +491,12 @@ variables = [
491491
{ key = "FLOW_RL_SIGNALS", default = "true" },
492492
{ key = "FLOW_RL_SIGNALS_PATH", default = "out/logs/flow_rl_signals.jsonl" },
493493
{ key = "FLOW_RL_SIGNALS_SEQ_MIRROR", default = "true" },
494-
{ key = "FLOW_RL_SIGNALS_SEQ_PATH", default = "~/repos/ClickHouse/ClickHouse/user_files/seq_mem.jsonl" },
494+
{ key = "FLOW_RL_SIGNALS_SEQ_PATH", default = "~/.config/flow/rl/seq_mem.jsonl" },
495495
{ key = "FLOW_ROUTER_SUGGESTED_TASK", default = "" },
496496
{ key = "FLOW_ROUTER_OVERRIDE_REASON", default = "" },
497497
{ key = "FLOW_RL_SIGNAL_TEXT", default = "snippet" },
498498
{ key = "FLOW_RL_SIGNAL_MAX_CHARS", default = "4000" },
499-
{ key = "SEQ_CH_MEM_PATH", default = "~/repos/ClickHouse/ClickHouse/user_files/seq_mem.jsonl" },
499+
{ key = "SEQ_CH_MEM_PATH", default = "~/.config/flow/rl/seq_mem.jsonl" },
500500
{ key = "HARBOR_DIR", default = "~/repos/laude-institute/harbor" },
501501
]
502502

scripts/build_rl_runtime_dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ def main() -> int:
456456
parser = argparse.ArgumentParser(description="Build RL runtime dataset from flow + seq logs")
457457
parser.add_argument("--harbor-dir", default=str(Path("~/repos/laude-institute/harbor").expanduser()))
458458
parser.add_argument("--flow-signals", default="out/logs/flow_rl_signals.jsonl")
459-
parser.add_argument("--seq-mem", default=str(Path("~/repos/ClickHouse/ClickHouse/user_files/seq_mem.jsonl").expanduser()))
459+
parser.add_argument("--seq-mem", default=str(Path("~/.config/flow/rl/seq_mem.jsonl").expanduser()))
460460
parser.add_argument("--snapshot", default="", help="snapshot name; default timestamp")
461461
parser.add_argument("--flow-last", type=int, default=20_000)
462462
parser.add_argument("--seq-last", type=int, default=50_000)

0 commit comments

Comments
 (0)