← Commit history

Step pages: no background pushes after project-page --no-push or --local-only, and no local paths on the page

Drew Owens ·4c62c3c6ba · ·parent 4bef5cb
project-page records projectPagePush (false with --no-push or --local-only); leaving a step pushes the step pages only to a page bound for pushing, and project-page --sync binds it again. Step pages name local files by their place in the run folder or their file name. Co-Authored-By: Claude Opus 5.5 <[email protected]>
4 files changed +186−12
crates/adom-aiflow/src/main.rs+30−3
@@ -223,7 +223,7 @@ enum Cmd {     #[arg(long)] out: Option<String>, /// push every visited step's sub-readme and the README's "How this board was built" section now (each step's is also pushed in the background when the run leaves it)     #[arg(long)] sync: bool, #[arg(long)] create: bool, /// the page already exists and is this same board's own page (an earlier run of it); refused otherwise     #[arg(long)] existing: bool, #[arg(long)] private: bool, #[arg(long)] title: Option<String>, /// what the board is: text, or a path to a file (for example design/brief.md) whose contents are read-    #[arg(long)] brief: Option<String>, #[arg(long)] replace_readme: bool, /// build locally and push nothing to the page (the wiki parts are still added to your private Cloud Library and exported from it)+    #[arg(long)] brief: Option<String>, #[arg(long)] replace_readme: bool, /// build locally and push nothing to the page (the wiki parts are still added to your private Cloud Library and exported from it); the steps the run leaves later are not pushed there either, until `project-page --sync`     #[arg(long)] no_push: bool, /// no wiki call at all (implies --no-push): no Cloud Library create, add or export, so only the project-library parts are packaged and the wiki parts are named as left out (issue #157)     #[arg(long)] local_only: bool, /// a folder of an EXISTING page (relative, like rig/boards/rig-carrier): the board's README and its PCM repository go there, the repository URLs carry it; implies --existing and never creates a page     #[arg(long)] page_dir: Option<String> },@@ -3475,6 +3475,29 @@ mod pcm_installed_version_tests {     } } +/// The page the background step pages go to when the run leaves a step: the project page, unless+/// `project-page` was built with --no-push or --local-only (`projectPagePush` false). Runs from before+/// the flag existed keep pushing. `project-page --sync` (an explicit push) binds the page again.+fn step_pages_page(data: &Value) -> Option<&str> {+    if data["projectPagePush"] == json!(false) { return None; }+    data["projectPage"].as_str().filter(|p| !p.is_empty())+}++#[cfg(test)]+mod step_pages_page_tests {+    use serde_json::json;++    #[test]+    fn a_local_project_page_gets_no_background_pushes() {+        assert_eq!(super::step_pages_page(&json!({"projectPage": "a/b", "projectPagePush": true})), Some("a/b"));+        assert_eq!(super::step_pages_page(&json!({"projectPage": "a/b", "projectPagePush": false})), None);+        // a run from before the flag keeps its behaviour+        assert_eq!(super::step_pages_page(&json!({"projectPage": "a/b"})), Some("a/b"));+        assert_eq!(super::step_pages_page(&json!({"projectPage": "", "projectPagePush": true})), None);+        assert_eq!(super::step_pages_page(&json!({})), None);+    }+}+ fn project_dir_of(r: &Run) -> PathBuf {     let src = r.data["sourceBoard"].as_str().map(PathBuf::from).unwrap_or_else(|| PathBuf::from(r.current_board()));     src.parent().map(Path::to_path_buf).unwrap_or_else(|| PathBuf::from("."))@@ -4568,7 +4591,8 @@ fn main() {                 let o = std::process::Command::new("python3").arg("-c").arg(include_str!("../../../tools/project-steps.py")).arg(&dir).arg(page).stdin(std::process::Stdio::null()).output().unwrap_or_else(|e| err(&format!("python3: {e}"), &[]));                 let v: Value = serde_json::from_slice(&o.stdout).unwrap_or(json!({"ok": false, "error": String::from_utf8_lossy(&o.stderr).to_string()}));                 if v["ok"] != true { err(&format!("step pages: {}", v["error"].as_str().unwrap_or("failed")), &[]); }-                r.data["projectPage"] = json!(page); r.save().unwrap();+                // an explicit push of the step pages binds the page for the background pushes too+                r.data["projectPage"] = json!(page); r.data["projectPagePush"] = json!(true); r.save().unwrap();                 ok(&format!("{} step page(s) and the README's build section pushed to {page} (commit {})", v["steps"].as_array().map(|a| a.len()).unwrap_or(0), v["commit"].as_str().unwrap_or("?")), &[]);                 return;             }@@ -4598,6 +4622,9 @@ fn main() {             r.outcome("project-page", v.clone());             r.data["projectPage"] = json!(page);             r.data["projectPageDir"] = json!(page_dir);+            // --no-push and --local-only build locally: the steps the run leaves later are not pushed to the+            // page either (a run told to stay off the wiki once made 14 step commits from the background)+            r.data["projectPagePush"] = json!(!no_push);             if let Some(l) = v["cloudLibrary"].as_str().filter(|l| l.starts_with("lib_")) { r.data["cloudLibrary"] = json!(l); }             r.save().unwrap();             if !no_push {@@ -7561,7 +7588,7 @@ fn main() {             }             // the board's project page gets the step just left as its own sub-readme (evidence, screenshots,             // usage) and a line in the README's build section, in the background so the step is not slowed-            if let (Some(pg), Some(pv)) = (r.data["projectPage"].as_str(), prev.as_deref()) {+            if let (Some(pg), Some(pv)) = (step_pages_page(&r.data), prev.as_deref()) {                 if pv != name.as_str() {                     let helper = dir.join(".aiflow-project-steps.py");                     let _ = std::fs::write(&helper, include_str!("../../../tools/project-steps.py"));
skills/adom-aiflow/SKILL.md+1−1
@@ -352,7 +352,7 @@ A KiCad run that starts with no board (`intake` with no `start --board`) follows 5. **`step schematic`**: draw the schematic in KiCad's schematic editor, on camera: `kicad_open_schematic`, `kicad_sch_place_symbol` (symbols from `PCM_<slug>`), `kicad_sch_wire`, `kicad_sch_label`, `kicad_sch_set_property`; save; **`schematic check --sch <project>.kicad_sch`** passes when kicad-cli ERC ran and has no errors (no ERC report is a failure, never a clean ERC), every BOM reference is on the sheet and every part comes from the project library. Never write the `.kicad_sch` with a script of your own: the viewer is meant to see it drawn. 6. Simulate (as in the Fusion lane), then make the board in KiCad (Update PCB from Schematic, the outline), save it and attach it (`start --board ... --spec ...` on the same `--run`), `step components` and on. -**The project page grows with the run.** Once `project-page` names the page, every step the run leaves is pushed as its own sub-readme, `steps/<nn>-<step>/README.md` (what the step does, each visit and why a return came back, the proof the binary recorded, the screenshots and your registered drawings, the AI usage), and the main README keeps a "How this board was built" section between `<!-- aiflow:steps -->` markers: one intro line per step linking to its page. Keep the main README for people: what the board is, the hero, the component table, then those intros; the evidence lives in the sub-readmes. Register your drawings with `artifact` so they land on their step's page. `project-page --page <owner/slug> --sync` pushes every step at once (do it at finish).+**The project page grows with the run.** Once `project-page` names the page, every step the run leaves is pushed as its own sub-readme, `steps/<nn>-<step>/README.md` (what the step does, each visit and why a return came back, the proof the binary recorded, the screenshots and your registered drawings, the AI usage), and the main README keeps a "How this board was built" section between `<!-- aiflow:steps -->` markers: one intro line per step linking to its page. Keep the main README for people: what the board is, the hero, the component table, then those intros; the evidence lives in the sub-readmes. Register your drawings with `artifact` so they land on their step's page. `project-page --page <owner/slug> --sync` pushes every step at once (do it at finish). A page built with `--no-push` or `--local-only` gets no background step pushes: the run stays off the wiki until `--sync`. Step pages name local files by their name inside the run folder, never by an absolute path on this machine.  **Antigravity (Google, Gemini) runs**: the run records Antigravity's quota (weekly and five-hour percent, from the local `agy` hub) and its token counters (from its own per-call records) at start, at every step and at finish; the run page and `deliver` show calls and tokens per step, the weekly percent used and its dollar share of the plan (`AIFLOW_PLAN_USD_MONTH`, default 199.99). Exact when nothing else uses Antigravity during the run. 
tests/step-pages-local-workflow.pyadded+124
@@ -0,0 +1,124 @@+"""Step pages stay off the wiki when the project page was built locally, and never carry local paths.++1. A run whose project page was built with `project-page --no-push` or `--local-only` (run.json+   `projectPagePush` false) pushes nothing when it leaves a step. `project-page --sync` (an explicit+   push) binds the page again, and the next step change pushes in the background. A run from before+   the flag (projectPage set, no projectPagePush) keeps pushing.+2. The step sub-readme names a file in the run folder by its place in the run folder and any other local+   file by its name: no absolute path of this machine reaches the page (outcome values, list items,+   nested values, a return's why).++adom-wiki is a fake on PATH that records every call and the text of every pushed .md file.+No CAD, desktop or dashboard.++  python3 tests/step-pages-local-workflow.py <adom-aiflow binary>+"""+import json, os, pathlib, re, subprocess, sys, tempfile, time+binary = str(pathlib.Path(sys.argv[1]).resolve())++FAKE_WIKI = r'''#!/usr/bin/env python3+import json, os, sys+a = sys.argv[1:]+rec = {"args": a, "cwd": os.getcwd()}+if a[:2] == ["repo", "push"]:+    i = a.index("--files"); files = a[i + 1:]+    if "-m" in files: files = files[:files.index("-m")]+    rec["files"] = files+    rec["texts"] = {f: open(os.path.join(os.getcwd(), f)).read() for f in files if f.endswith(".md") and os.path.isfile(os.path.join(os.getcwd(), f))}+open(os.environ["FAKE_WIKI_LOG"], "a").write(json.dumps(rec) + "\n")+if a[:2] == ["repo", "push"]:+    print(json.dumps({"status": "ok", "commit": "abc1234"})); sys.exit(0)+sys.exit(1)+'''++with tempfile.TemporaryDirectory(prefix='aiflow-step-pages-') as td:+    p = pathlib.Path(td)+    b = p / 'bin'; b.mkdir()+    (b / 'adom-wiki').write_text(FAKE_WIKI); (b / 'adom-wiki').chmod(0o755)+    log = p / 'wiki.jsonl'+    env = dict(os.environ, AIFLOW_DASHBOARD='off', PATH=f"{b}:{os.environ['PATH']}", FAKE_WIKI_LOG=str(log))+    env.pop('AIFLOW_PROJECT_STEPS_DRY', None)++    def call(run, *args):+        return subprocess.run([binary, '--run', str(run), '--ai-thread', 'step-pages-test', *args], env=env, capture_output=True, text=True, timeout=120)++    def pushes(wait=0.0):+        # the step pages go up from a background process: give it a moment before reading the log+        end = time.time() + wait+        while True:+            got = [json.loads(l) for l in log.read_text().splitlines() if '"push"' in l] if log.exists() else []+            if got or time.time() >= end: return got+            time.sleep(0.2)++    def data(run): return json.loads((run / 'run.json').read_text())++    def edit(run, **kv):+        d = data(run); d.update(kv); (run / 'run.json').write_text(json.dumps(d))++    def new_run(name):+        run = p / name+        r = call(run, 'intake', '--prompt-time', '2026-11-19T01:00:00Z', '--engine', 'test')+        assert r.returncode == 0, r.stdout + r.stderr+        return run++    # 1a. a project page built with --local-only: no wiki call then, and leaving a step pushes nothing+    run = new_run('local')+    edit(run, outcomes={'parts': {'pass': True, 'parts': [], 'bom': ''}})+    r = call(run, 'project-page', '--page', 'owner/board', '--local-only'); out = r.stdout + r.stderr+    assert r.returncode == 0 and 'project page built locally' in out, out+    assert data(run)['projectPage'] == 'owner/board' and data(run)['projectPagePush'] is False, data(run)+    assert not log.exists(), log.read_text()+    for st in ['rules', 'test-plan']:+        r = call(run, 'step', st); assert r.returncode == 0, r.stdout + r.stderr+    time.sleep(3)+    assert pushes() == [], pushes()+    assert not (run / 'project-steps.log').exists() or (run / 'project-steps.log').read_text() == '', (run / 'project-steps.log').read_text()++    # 1b. --sync is an explicit push: it pushes now and binds the page for the background pushes+    r = call(run, 'project-page', '--sync', '--page', 'owner/board'); out = r.stdout + r.stderr+    assert r.returncode == 0, out+    assert data(run)['projectPagePush'] is True, data(run)+    n = len(pushes()); assert n == 1, pushes()+    r = call(run, 'step', 'parts'); assert r.returncode == 0, r.stdout + r.stderr+    deadline = time.time() + 20+    while len(pushes()) == n and time.time() < deadline: time.sleep(0.3)+    assert len(pushes()) == n + 1, pushes()+    assert all(x['args'][2] == 'owner/board' for x in pushes())++    # 1c. a run from before the flag keeps pushing+    log.unlink()+    old = new_run('legacy')+    edit(old, projectPage='owner/board')+    assert call(old, 'step', 'rules').returncode == 0+    assert pushes(wait=20), 'a run with no projectPagePush flag stopped pushing its step pages'++    # 2. no absolute local path on a step page (the push helper, through --sync)+    log.unlink()+    run = new_run('paths')+    home = '/home/someone/project/boards/main'+    d = data(run)+    d['sequence'] = ['intake', 'rules']+    d.setdefault('steps', {})['rules'] = {'visits': [+        {'at': '2026-11-19T01:10:00Z'},+        {'at': '2026-11-19T01:20:00Z', 'back': True, 'why': f'the pack at {home}/rules/acb.kicad_dru was wrong'}]}+    d['outcomes'] = dict(d.get('outcomes') or {}, rules={+        'pass': True,+        'dru': f'{home}/rules/acb.kicad_dru',+        'report': str(run / 'rules' / 'report.json'),+        'kicadCli': 'C:\\Users\\someone\\KiCad\\bin\\kicad-cli.exe',+        'packs': [f'{home}/a.kicad_dru', 'https://wiki.adom.inc/adom/pcb-design-rules'],+        'files': {'bom': f'{home}/bom.csv', 'n': 3},+        'note': f'checked with file://{home}/notes.txt',+    })+    (run / 'run.json').write_text(json.dumps(d))+    r = call(run, 'project-page', '--sync', '--page', 'owner/board'); out = r.stdout + r.stderr+    assert r.returncode == 0, out+    ps = pushes(); assert len(ps) == 1, ps+    md = ps[0]['texts']['steps/02-rules/README.md']+    for leak in ['/home/someone', 'C:\\Users', str(p)]:+        assert leak not in md, (leak, md)+    for want in ['acb.kicad_dru', 'rules/report.json', 'kicad-cli.exe', 'a.kicad_dru', 'bom.csv', 'notes.txt',+                 'https://wiki.adom.inc/adom/pcb-design-rules', 'a return: the pack at acb.kicad_dru was wrong']:+        assert want in md, (want, md)+    assert not re.search(r'(?<![\w:/])/(?:home|tmp|Users|mnt)/', md), md+print('PASS: a project page built with --local-only gets no background step pushes; --sync pushes and binds the page again; a run from before the flag keeps pushing; step pages name local files by their place in the run or their name, never an absolute path (outcomes, lists, nested values, a return\'s why, file:// links), and URLs stay as they are')
tools/project-steps.py+31−8
@@ -56,17 +56,40 @@ def tokens_by_step(data):     return out  -def brief(v, depth=0):-    """A short human reading of an outcome: scalars and short lists, nested once."""+# An absolute local path: /a/b... (two or more parts) or C:\\... / C:/... . A URL's path is not one (the+# scheme's "//" comes right after a word character, which the look-behind refuses).+ABS_PATH = re.compile(r"(?<![\w:/.~-])(?:/[^\s/\"'`()\[\],;]+(?:/[^\s/\"'`()\[\],;]*)+|[A-Za-z]:[\\/][^\s\"'`()\[\],;]*)")+++def local(text, run=None):+    """`text` with every absolute local path replaced by its place in the run folder, else its file+    name: the page is read by people on other machines, and this machine's folders (the user's home,+    a container's session paths) are not theirs to see."""+    def rel(m):+        p = m.group(0).rstrip(".")+        tail = m.group(0)[len(p):]+        if run:+            r = os.path.abspath(run)+            q = os.path.abspath(p) if p.startswith("/") else p+            if q == r or q.startswith(r + os.sep):+                return (os.path.relpath(q, r) or ".") + tail+        return (re.split(r"[\\/]", p.rstrip("/\\"))[-1] or p) + tail+    if not isinstance(text, str): return text+    return ABS_PATH.sub(rel, re.sub(r"\bfile://(?=/)", "", text))+++def brief(v, depth=0, run=None):+    """A short human reading of an outcome: scalars and short lists, nested once; local paths as+    `local` writes them."""     if isinstance(v, dict):         rows = []         for k, x in v.items():-            if isinstance(x, (str, int, float, bool)) and len(str(x)) < 160: rows.append(f"- **{k}**: {x}")-            elif isinstance(x, list) and x and len(x) <= 8 and all(isinstance(i, (str, int, float)) for i in x): rows.append(f"- **{k}**: {', '.join(map(str, x))}")+            if isinstance(x, (str, int, float, bool)) and len(str(x)) < 160: rows.append(f"- **{k}**: {local(str(x), run)}")+            elif isinstance(x, list) and x and len(x) <= 8 and all(isinstance(i, (str, int, float)) for i in x): rows.append(f"- **{k}**: {', '.join(local(str(i), run) for i in x)}")             elif isinstance(x, list): rows.append(f"- **{k}**: {len(x)} item(s)")-            elif isinstance(x, dict) and depth == 0: rows.append(f"- **{k}**: " + "; ".join(f"{a} {b}" for a, b in list(x.items())[:8] if isinstance(b, (str, int, float, bool))))+            elif isinstance(x, dict) and depth == 0: rows.append(f"- **{k}**: " + "; ".join(f"{a} {local(str(b), run)}" for a, b in list(x.items())[:8] if isinstance(b, (str, int, float, bool))))         return "\n".join(rows)-    return str(v)+    return local(str(v), run)   def page_dir(data, page):@@ -96,13 +119,13 @@ def sub_readme(run, data, events, step, n, stage, folder=None):     visits = (data.get("steps", {}).get(step) or {}).get("visits") or []     d = os.path.join(stage, under(folder, "steps"), f"{n:02d}-{step}"); os.makedirs(d, exist_ok=True)     md = [f"# Step {n}: {title}", "", does, ""]-    md += ["## Visits", ""] + [f"- {v.get('at', '')}" + (f" (a return: {v.get('why')})" if v.get("back") else "") for v in visits] + [""]+    md += ["## Visits", ""] + [f"- {v.get('at', '')}" + (f" (a return: {local(str(v.get('why')), run)})" if v.get("back") else "") for v in visits] + [""]     proofs = (flow.get("proofs") or {}).get(step) or []     outs = data.get("outcomes") or {}     shown = [k for k in proofs if k in outs] + [k for k in outs if k.startswith(step) and k not in proofs]     if shown:         md += ["## What the binary checked", ""]-        for k in shown: md += [f"### {k}", "", brief(outs[k]), ""]+        for k in shown: md += [f"### {k}", "", brief(outs[k], run=run), ""]     ev = [e for e in data.get("evidence") or [] if e.get("step") == step]     if ev:         md += ["## Evidence", ""] + [f"- {e.get('kind')}: `{os.path.basename(e.get('file', ''))}`" + (" (pass)" if e.get("pass") else " (fail)" if e.get("pass") is False else "") for e in ev] + [""]