Skip to content

feat(compile): S2-lite warm compile daemon — hook chain 406ms → 146ms (−64%)#83

Merged
Cranot merged 1 commit into
mainfrom
feat/compile-daemon-s2lite
Jul 16, 2026
Merged

feat(compile): S2-lite warm compile daemon — hook chain 406ms → 146ms (−64%)#83
Cranot merged 1 commit into
mainfrom
feat/compile-daemon-s2lite

Conversation

@Cranot

@Cranot Cranot commented Jul 16, 2026

Copy link
Copy Markdown
Owner

The BUILD-PLAN's committed next-session opener. Process startup dominates the interactive compile channel (~49% of compile wall; a cache HIT computes in ~2ms while the caller pays the full cold spawn). roam compile-daemon start holds roam imported + index warm in one per-repo loopback process; the v4 UPS hook tries the socket with a 10ms connect budget and cold-spawns on ANY failure.

Scope (S2-lite by design): per-repo (foreign-cwd requests refused → hook falls back cold, never another repo's envelope); manual lifecycle (start/status/stop, foreground); loopback + random token (.roam/compile-daemon.json, 0600 best-effort). Serves via the existing in-process CliRunner path; the request's session_id/agent-mode are stamped around the invoke so telemetry keeps its join key.

Falsifier (hook chain <100ms median on cache hits, n=20 live prompts): FAIL as specced — shipped with the miss disclosed.

  • Cold chain (same hook, daemon hidden): median 406ms (n=8)
  • Daemon chain: median 146ms (n=20, all injected) → −64%
  • Decomposition: ~61ms Python interpreter+imports (irreducible while hooks are python3) + ~15ms socket RT + ~70ms kernel HIT-path (compile_plan's classifier + search-semantic/git-rev-parse subprocesses run before the cache lookup — the pre-existing "caller pays 76ms on a 2ms HIT" lever, tracked as head-4/S6).
  • A daemon-side response memo would pass the bar but re-introduces exactly the staleness semantics the W147 cache closed (dirty-tree envelopes). Refused; the honest path to <100ms is the kernel HIT-path lever.

Hook body v4; v3 fleets heal via the #81 registry (v4 pristine + surgered SHAs seeded). 18 daemon tests + 3 UPS daemon-path tests (incl. daemon-refusal never injected, dead-config double fail-open); 90 green across touched suites; mode-policy/budget/commands-doc gates integrated; prepush full-suite green on push.

…s (-64%)

Process startup, not compute, dominates the interactive compile channel
(~49% of total compile wall; a cache HIT computes in ~2ms while the caller
pays the full cold-spawn chain). `roam compile-daemon start` keeps roam
imported and the index warm in one long-lived per-repo process serving
loopback JSON requests; the v4 UPS hook tries that socket with a 10ms
connect budget and cold-spawns on ANY failure — the daemon can never break
the hook, and stopping it is always safe.

S2-LITE scope by design: per-repo (foreign-cwd requests are refused so the
hook falls back cold rather than get another repo's envelope), manual
lifecycle (start/status/stop; foreground), loopback + random token
(.roam/compile-daemon.json, 0600 best-effort). The daemon serves via the
existing in-process CliRunner path and stamps the request's session id /
agent mode around the invoke, so telemetry keeps its join key.

FALSIFIER (build-plan S2-lite: hook chain <100ms median on cache hits,
n=20 live prompts, this box): FAIL as specced — shipped with the miss
disclosed, not laundered. Measured: cold chain median 406ms (n=8);
daemon chain median 146ms (n=20, all injected). Decomposition: ~61ms
Python interpreter+imports (irreducible while hooks are python3), ~15ms
socket round-trip, ~70ms kernel HIT-path overhead (compile_plan's
classifier + search-semantic/git-rev-parse subprocesses run before the
cache lookup — the pre-existing "caller pays 76ms on a 2ms HIT" lever,
tracked separately as head-4/S6). A daemon-side response memo would pass
the bar but re-introduces the exact staleness semantics the W147 cache
was built to close; refused.

Hook body v4 (v3 fleets heal via the registry; v4 pristine + surgered
SHAs seeded). 18 daemon tests + 3 UPS daemon-path tests; 90 green across
the touched suites; counts synced (279 commands).
@Cranot
Cranot merged commit 0506aed into main Jul 16, 2026
7 of 11 checks passed
@github-actions

Copy link
Copy Markdown

roam-code Analysis

Mode: incremental (changed-only) — base 046feceea58661a1172b19d6b4533e8dc962adc5, 30 changed+dependent files

Health Score: 78/100 FAIR

health: Fair codebase (78/100) — 49 critical, 7 warnings, focus: god_components
pr-risk: High risk (59/100) — careful review needed (risk_level high) (driver: hotspot_score)

Health Metrics

Metric Value
Health Score 78/100
Tangle Ratio 0%
Propagation Cost 0.0014
Total Issues 65

PR Risk

Metric Value
Risk Score 59/100

Quality Gate: PASSED

Gate expression: health_score>=50

SARIF Upload

Metric Value
Category roam-code-self-analysis/self-analysis/py3.12
Results Uploaded 82
Full analysis output

health

{
  "_meta": {
    "cache_ttl_s": 300,
    "cacheable": true,
    "index_age_s": 4,
    "index_status": {
      "dirty_files": 0,
      "fresh": false,
      "head_commit": "8b15348daa9f",
      "hint": "index latest commit f83238988f20 != HEAD 8b15348daa9f — git-derived metrics (commits, churn, co-change, weather) may be stale. Run `roam index --force`.",
      "indexed_commit": "f83238988f20"
    },
    "latency_ms": null,
    "response_tokens": 4086,
    "roam_version": "13.9.0",
    "timestamp": "2026-07-16T16:00:54Z"
  },
  "actionable_count": 16,
  "actionable_cycles": 0,
  "agent_contract": {
    "confidence": null,
    "facts": [
      "Fair codebase (78/100) — 49 critical, 7 warnings, focus: god_components",
      "health score 78",
      "tangle ratio 0.0",
      "0.0014 propagation cost findings",
      "issue count 65"
    ],
    "next_commands": [
      "roam debt",
      "roam trends --days 30"
    ],
    "risks": []
  },
  "algebraic_connectivity": null,
  "algebraic_connectivity_available": false,
  "bottleneck_thresholds": {
    "p70": 451.3,
    "p90": 3925.7,
    "population": 2354,
    "utility_multiplier": 1.5
  },
  "category_severity": {
    "bottlenecks": {
      "critical": 15,
      "info": 0,
      "warning": 0
    },
    "cycles": {
      "critical": 0,
      "info": 0,
      "warning": 0
    },
    "god_components": {
      "critical": 34,
      "info": 9,
      "warning": 7
    },
    "layer_violations": {
      "critical": 0,
      "info": 0,
      "warning": 0
    }
  },
  "command": "health",
  "cycles_actionable": 0,
  "cycles_total": 17,
  "framework_filtered": 0,
  "health_score": 78,
  "ignored_cycles": 17,
  "imported_coverable_lines": 0,
  "imported_coverage_files": 0,
  "imported_coverage_pct": null,
  "imported_covered_lines": 0,
  "index_status": {
    "dirty_files": 0,
    "fresh": false,
    "head_commit": "8b15348daa9f",
    "hint": "index latest commit f83238988f20 != HEAD 8b15348daa9f — git-derived metrics (commits, churn, co-change, weather) may be stale. Run `roam index --force`.",
    "indexed_commit": "f83238988f20"
  },
  "issue_count": 65,
  "list_counts": {
    "bottlenecks": 15,
    "cycle_break_suggestions": 0,
    "cycles": 17,
    "god_components": 50,
    "layer_violations": 0,
    "next_steps": 2,
    "score_breakdown": 5
  },
  "project": "roam-code",
  "propagation_cost": 0.0014,
  "schema": "roam-envelope-v1",
  "schema_version": "1.1.0",
  "severity": {
    "critical": 49,
    "info": 26,
    "warning": 7
  },
  "summary": {
    "actionable_cycles": 0,
    "algebraic_connectivity": null,
    "algebraic_connectivity_available": false,
    "category_severity": {
      "bottlenecks": {
        "critical": 15,
        "info": 0,
        "warning": 0
      },
      "cycles": {
        "critical": 0,
        "info": 0,
        "warning": 0
      },
      "god_components": {
        "critical": 34,
        "info": 9,
        "warning": 7
      },
      "layer_violations": {
        "critical": 0,
        "info": 0,
        "warning": 0
      }
    },
    "cycles_actionable": 0,
    "cycles_definition": "Cycle counts derived from `roam.graph.cycles.find_cycles(G, min_size=2)` on the symbol graph. `cycles_total` = all SCCs of size >= 2; `cycles_actionable` = SCCs spanning >=2 files AND no test files (same-file and test-only cycles are informational). Run `roam health` for the per-cycle breakdown.",
    "cycles_total": 17,
    "detail_available": true,
    "god_components": 50,
    "god_components_definition": "God components: symbols where `(in_degree + out_degree) > 20` from the `graph_metrics` table, with utility-aware severity bands (standard >50=CRITICAL >30=WARNING; utility >150=CRITICAL >90=WARNING). Run `roam health` for the per-symbol breakdown. Legacy aliases: `god_objects` (fingerprint), `god_classes` (rules).",
    "health_score": 78,
    "health_score_definition": "weighted geometric mean (0-100) of 5 sigmoid health factors: tangle_ratio, god_components, bottlenecks, layer_violations, file_health (+coverage if available).",
    "ignored_cycles": 17,
    "imported_coverage_files": 0,
    "imported_coverage_pct": null,
    "issue_count": 65,
    "partial_success": true,
    "preserved_list_truncations": {},
    "propagation_cost": 0.0014,
    "severity": {
      "critical": 49,
      "info": 26,
      "warning": 7
    },
    "tangle_ratio": 0,
    "tangle_ratio_definition": "fraction of symbols inside non-trivial SCCs; higher = more cyclic coupling.",
    "total_cycles": 17,
    "truncated": true,
    "verdict": "Fair codebase (78/100) — 49 critical, 7 warnings, focus: god_components",
    "warnings_out": [
      "health_algebraic_connectivity_warning:RuntimeWarning:algebraic_connectivity compute failed (ModuleNotFoundError): No module named 'numpy'; returning 0.0 sentinel — value is NOT a legitimate disconnected-graph reading"
    ]
  },
  "tangle_ratio": 0,
  "total_cycles": 17,
  "utility_count": 34,
  "version": "13.9.0",
  "warnings_out": [
    "health_algebraic_connectivity_warning:RuntimeWarning:algebraic_connectivity compute failed (ModuleNotFoundError): No module named 'numpy'; returning 0.0 sentinel — value is NOT a legitimate disconnected-graph reading"
  ]
}

pr-risk

{
  "_meta": {
    "cache_ttl_s": 60,
    "cacheable": true,
    "index_age_s": 6,
    "index_status": {
      "dirty_files": 0,
      "fresh": false,
      "head_commit": "8b15348daa9f",
      "hint": "index latest commit f83238988f20 != HEAD 8b15348daa9f — git-derived metrics (commits, churn, co-change, weather) may be stale. Run `roam index --force`.",
      "indexed_commit": "f83238988f20"
    },
    "latency_ms": null,
    "response_tokens": 3120,
    "roam_version": "13.9.0",
    "timestamp": "2026-07-16T16:00:57Z"
  },
  "actor": null,
  "agent_contract": {
    "confidence": null,
    "facts": [
      "High risk (59/100) — careful review needed (risk_level high) (driver: hotspot_score)",
      "risk score 59",
      "3 risk rank findings",
      "24 changed files",
      "678 lines added"
    ],
    "next_commands": [],
    "risks": [
      "pr-risk: high (59/100) on 046feceea58661a1172b19d6b4533e8dc962adc5..HEAD — driver: hotspot_score",
      "High blast radius: 9745 of 42016 symbols affected (23.2%) on 046feceea58661a1172b19d6b4533e8dc962adc5..HEAD",
      "Test coverage gap: 5 of 12 changed source files have adjacent tests (42% covered) on..."
    ]
  },
  "author": null,
  "blast_radius_pct": 23.2,
  "bus_factor_risk": 0.44,
  "change_shape": "mixed",
  "changed_files": 24,
  "closest_historical_pattern": [
    ".githooks/commit-msg",
    ".githooks/pre-commit",
    ".githooks/pre-push",
    "AGENTS.md",
    "README.md",
    "docs/COMMANDS.md",
    "docs/ci-integration.md",
    "llms-install.md",
    "scripts/bench_analyze.py",
    "scripts/wait-for-output.sh",
    "skills/roam/SKILL.md",
    "src/roam/cli.py",
    "src/roam/commands/cmd_compile_daemon.py",
    "src/roam/commands/cmd_hooks.py",
    "src/roam/competitor_site_data.py",
    "src/roam/modes/policy.py",
    "templates/distribution/landing-page/docs/agent-contract.html",
    "templates/distribution/landing-page/docs/integration-tutorials.html",
    "templates/distribution/landing-page/llms.txt",
    "templates/distribution/landing-page/pricing.html",
    "templates/distribution/landing-page/setup.html",
    "tests/test_budget_coverage_survey.py",
    "tests/test_compile_daemon.py",
    "tests/test_hooks_claude_setup.py"
  ],
  "closest_similarity": 1,
  "cluster_spread": 0.01,
  "clusters_touched": 99,
  "command": "pr-risk",
  "coupling_score": 0.01,
  "dead_code": [
    {
      "file": "src/roam/cli.py",
      "kind": "class",
      "name": "LazyGroup"
    },
    {
      "file": "src/roam/cli.py",
      "kind": "method",
      "name": "parse_args"
    },
    {
      "file": "src/roam/cli.py",
      "kind": "method",
      "name": "list_commands"
    },
    {
      "file": "src/roam/cli.py",
      "kind": "method",
      "name": "get_command"
    },
    {
      "file": "src/roam/cli.py",
      "kind": "method",
      "name": "resolve_command"
    },
    {
      "file": "src/roam/cli.py",
      "kind": "method",
      "name": "invoke"
    },
    {
      "file": "src/roam/cli.py",
      "kind": "method",
      "name": "format_help"
    },
    {
      "file": "src/roam/commands/cmd_compile_daemon.py",
      "kind": "method",
      "name": "write_daemon_file"
    },
    {
      "file": "src/roam/commands/cmd_compile_daemon.py",
      "kind": "method",
      "name": "close"
    },
    {
      "file": "src/roam/commands/cmd_compile_daemon.py",
      "kind": "method",
      "name": "prewarm"
    }
  ],
  "dead_exports": 20,
  "familiarity": {
    "avg_familiarity": 1,
    "files": [],
    "files_assessed": 0
  },
  "findings": [
    {
      "claim": "pr-risk: high (59/100) on 046feceea58661a1172b19d6b4533e8dc962adc5..HEAD — driver: hotspot_score",
      "confidence": "heuristic",
      "evidence": {
        "actor": null,
        "author": null,
        "blast_radius_pct": 23.2,
        "bus_factor_risk": 0.438,
        "changed_files_count": 24,
        "commit_range": "046feceea58661a1172b19d6b4533e8dc962adc5..HEAD",
        "coupling_score": 0.007,
        "created_at_epoch": 1784217657,
        "diff_id": "d7d04e3e19cd",
        "familiarity_risk": 0,
        "file_list": [
          ".githooks/commit-msg",
          ".githooks/pre-commit",
          ".githooks/pre-push",
          "AGENTS.md",
          "README.md",
          "docs/COMMANDS.md",
          "docs/ci-integration.md",
          "llms-install.md",
          "scripts/bench_analyze.py",
          "scripts/wait-for-output.sh",
          "skills/roam/SKILL.md",
          "src/roam/cli.py",
          "src/roam/commands/cmd_compile_daemon.py",
          "src/roam/commands/cmd_hooks.py",
          "src/roam/competitor_site_data.py",
          "src/roam/modes/policy.py",
          "templates/distribution/landing-page/docs/agent-contract.html",
          "templates/distribution/landing-page/docs/integration-tutorials.html",
          "templates/distribution/landing-page/llms.txt",
          "templates/distribution/landing-page/pricing.html",
          "templates/distribution/landing-page/setup.html",
          "tests/test_budget_coverage_survey.py",
          "tests/test_compile_daemon.py",
          "tests/test_hooks_claude_setup.py"
        ],
        "hotspot_score": 0.987,
        "label": "046feceea58661a1172b19d6b4533e8dc962adc5..HEAD",
        "lines_added": 678,
        "lines_removed": 36,
        "minor_risk": 0,
        "novelty_score": 0,
        "reductive_change": false,
        "risk_level": "high",
        "risk_score": 59,
        "staged": false,
        "test_coverage_pct": 41.7,
        "top_driver": "hotspot_score"
      },
      "finding_id_str": "pr-risk:composite-risk-score:d7d04e3e19cd",
      "kind": "pr-risk:composite-risk-score",
      "severity": "high",
      "source_detector": "pr-risk",
      "source_version": "1.0.0",
      "subject_id": null,
      "subject_kind": "commit"
    },
    {
      "claim": "High blast radius: 9745 of 42016 symbols affected (23.2%) on 046feceea58661a1172b19d6b4533e8dc962adc5..HEAD",
      "confidence": "structural",
      "evidence": {
        "affected_symbols": 9745,
        "blast_radius_pct": 23.2,
        "changed_files_count": 24,
        "changed_symbol_ids_count": 313,
        "commit_range": "046feceea58661a1172b19d6b4533e8dc962adc5..HEAD",
        "created_at_epoch": 1784217657,
        "diff_id": "d7d04e3e19cd",
        "file_list": [
          ".githooks/commit-msg",
          ".githooks/pre-commit",
          ".githooks/pre-push",
          "AGENTS.md",
          "README.md",
          "docs/COMMANDS.md",
          "docs/ci-integration.md",
          "llms-install.md",
          "scripts/bench_analyze.py",
          "scripts/wait-for-output.sh",
          "skills/roam/SKILL.md",
          "src/roam/cli.py",
          "src/roam/commands/cmd_compile_daemon.py",
          "src/roam/commands/cmd_hooks.py",
          "src/roam/competitor_site_data.py",
          "src/roam/modes/policy.py",
          "templates/distribution/landing-page/docs/agent-contract.html",
          "templates/distribution/landing-page/docs/integration-tutorials.html",
          "templates/distribution/landing-page/llms.txt",
          "templates/distribution/landing-page/pricing.html",
          "templates/distribution/landing-page/setup.html",
          "tests/test_budget_coverage_survey.py",
          "tests/test_compile_daemon.py",
          "tests/test_hooks_claude_setup.py"
        ],
        "label": "046feceea58661a1172b19d6b4533e8dc962adc5..HEAD",
        "staged": false,
        "total_symbols": 42016
      },
      "finding_id_str": "pr-risk:high-blast-radius-symbol-touched:d7d04e3e19cd",
      "kind": "pr-risk:high-blast-radius-symbol-touched",
      "severity": "high",
      "source_detector": "pr-risk",
      "source_version": "1.0.0",
      "subject_id": null,
      "subject_kind": "commit"
    },
    {
      "claim": "Test coverage gap: 5 of 12 changed source files have adjacent tests (42% covered) on 046feceea58661a1172b19d6b4533e8dc962adc5..HEAD",
      "confidence": "structural",
      "evidence": {
        "changed_files_count": 24,
        "commit_range": "046feceea58661a1172b19d6b4533e8dc962adc5..HEAD",
        "covered_files": 5,
        "created_at_epoch": 1784217657,
        "diff_id": "d7d04e3e19cd",
        "file_list": [
          ".githooks/commit-msg",
          ".githooks/pre-commit",
          ".githooks/pre-push",
          "AGENTS.md",
          "README.md",
          "docs/COMMANDS.md",
          "docs/ci-integration.md",
          "llms-install.md",
          "scripts/bench_analyze.py",
          "scripts/wait-for-output.sh",
          "skills/roam/SKILL.md",
          "src/roam/cli.py",
          "src/roam/commands/cmd_compile_daemon.py",
          "src/roam/commands/cmd_hooks.py",
          "src/roam/competitor_site_data.py",
          "src/roam/modes/policy.py",
          "templates/distribution/landing-page/docs/agent-contract.html",
          "templates/distribution/landing-page/docs/integration-tutorials.html",
          "templates/distribution/landing-page/llms.txt",
          "templates/distribution/landing-page/pricing.html",
          "templates/distribution/landing-page/setup.html",
          "tests/test_budget_coverage_survey.py",
          "tests/test_compile_daemon.py",
          "tests/test_hooks_claude_setup.py"
        ],
        "label": "046feceea58661a1172b19d6b4533e8dc962adc5..HEAD",
        "source_files_count": 12,
        "staged": false,
        "test_coverage_pct": 41.7,
        "uncovered_files": 7
      },
      "finding_id_str": "pr-risk:test-coverage-gap:d7d04e3e19cd",
      "kind": "pr-risk:test-coverage-gap",
      "severity": "medium",
      "source_detector": "pr-risk",
      "source_version": "1.0.0",
      "subject_id": null,
      "subject_kind": "commit"
    }
  ],
  "hotspot_score": 0.99,
  "label": "046feceea58661a1172b19d6b4533e8dc962adc5..HEAD",
  "layer_spread": 0.58,
  "layers_touched": 18,
  "lines_added": 678,
  "lines_removed": 36,
  "minor_risk": {
    "files": [],
    "files_assessed": 0,
    "minor_files": 0
  },
  "novelty_score": 0,
  "per_file": [
    {
      "blast": 9558,
      "churn": 3397,
      "is_test": false,
      "lines_added": 1,
      "lines_removed": 0,
      "path": "src/roam/cli.py",
      "symbols": 86
    },
    {
      "blast": 8258,
      "churn": 672,
      "is_test": false,
      "lines_added": 4,
      "lines_removed": 0,
      "path": "src/roam/modes/policy.py",
      "symbols": 18
    },
    {
      "blast": 104,
      "churn": 2260,
      "is_test": false,
      "lines_added": 71,
      "lines_removed": 16,
      "path": "src/roam/commands/cmd_hooks.py",
      "symbols": 49
    },
    {
      "blast": 68,
      "churn": 3559,
      "is_test": false,
      "lines_added": 1,
      "lines_removed": 1,
      "path": "src/roam/competitor_site_data.py",
      "symbols": 24
    },
    {
      "blast": 63,
      "churn": 311,
      "is_test": false,
      "lines_added": 311,
      "lines_removed": 0,
      "path": "src/roam/commands/cmd_compile_daemon.py",
      "symbols": 27
    },
    {
      "blast": 37,
      "churn": 867,
      "is_test": true,
      "lines_added": 95,
      "lines_removed": 0,
      "path": "tests/test_hooks_claude_setup.py",
      "symbols": 67
    },
    {
      "blast": 12,
      "churn": 174,
      "is_test": true,
      "lines_added": 174,
      "lines_removed": 0,
      "path": "tests/test_compile_daemon.py",
      "symbols": 21
    },
    {
      "blast": 5,
      "churn": 883,
      "is_test": true,
      "lines_added": 1,
      "lines_removed": 0,
      "path": "tests/test_budget_coverage_survey.py",
      "symbols": 16
    },
    {
      "blast": 4,
      "churn": 247,
      "is_test": false,
      "lines_added": 0,
      "lines_removed": 0,
      "path": "scripts/bench_analyze.py",
      "symbols": 5
    },
    {
      "blast": 0,
      "churn": 52,
      "is_test": false,
      "lines_added": 0,
      "lines_removed": 0,
      "path": ".githooks/commit-msg",
      "
...(truncated)

roam-code analysis | Commands: health pr-risk

@github-actions

Copy link
Copy Markdown

Roam Agent Review

Verdict: NOCHANGES (risk_level low)

blast-radius 0/100 · ai-likelihood 0/100 · rule violations 0 · critique high-severity 0

Verdict: NOCHANGES. All structural signals clean at the configured thresholds.


Powered by roam-code — Apache 2.0, 100% local. Customize thresholds in .roam/rules.yml. Docs.

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.

2 participants