mirror of
https://github.com/instructkr/claude-code.git
synced 2026-05-25 06:56:45 +00:00
Compare commits
25 Commits
fix-683-un
...
fix/roadma
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e5d904edaf | ||
|
|
f2a90228fb | ||
|
|
0581894b7e | ||
|
|
5b79413e87 | ||
|
|
85e736c73f | ||
|
|
b64df99134 | ||
|
|
c345ce6d02 | ||
|
|
91a0681ae9 | ||
|
|
c613e8e676 | ||
|
|
1003510a75 | ||
|
|
63a5a87471 | ||
|
|
da7924d079 | ||
|
|
bb2a9238d9 | ||
|
|
8806e62a9f | ||
|
|
78a0ff615a | ||
|
|
706ac0f8e1 | ||
|
|
bd8a27b100 | ||
|
|
6f5465aeaf | ||
|
|
fdbc789694 | ||
|
|
779cf1c234 | ||
|
|
1f330c6737 | ||
|
|
3489ec51d5 | ||
|
|
fa8eecaf8f | ||
|
|
2033c90921 | ||
|
|
8cada12c48 |
20
.github/hooks/pre-push
vendored
Executable file
20
.github/hooks/pre-push
vendored
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
# Claw Code local pre-push safety gate.
|
||||
#
|
||||
# Install with:
|
||||
# git config core.hooksPath .github/hooks
|
||||
#
|
||||
# This intentionally mirrors the CI build gate so stale field/enum references are
|
||||
# caught before pushing to main or PR branches.
|
||||
set -euo pipefail
|
||||
|
||||
repo_root="$(git rev-parse --show-toplevel 2>/dev/null)"
|
||||
cd "$repo_root"
|
||||
|
||||
if [[ ! -f rust/Cargo.toml ]]; then
|
||||
echo "pre-push: rust/Cargo.toml not found; skipping cargo workspace build" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "pre-push: cargo build --manifest-path rust/Cargo.toml --workspace" >&2
|
||||
cargo build --manifest-path rust/Cargo.toml --workspace
|
||||
@@ -3,11 +3,11 @@
|
||||
"duplicate_roadmap_heading_lines": [],
|
||||
"roadmap_actions_mapped": 542,
|
||||
"roadmap_actions_total": 542,
|
||||
"roadmap_headings_mapped": 124,
|
||||
"roadmap_headings_total": 124,
|
||||
"roadmap_headings_mapped": 127,
|
||||
"roadmap_headings_total": 127,
|
||||
"unmapped_roadmap_heading_lines": []
|
||||
},
|
||||
"generated_at": "2026-05-14T08:13:45+00:00",
|
||||
"generated_at": "2026-05-25T04:30:33+00:00",
|
||||
"generation_policy": {
|
||||
"release_buckets": [
|
||||
"2.x_intake",
|
||||
@@ -14823,6 +14823,69 @@
|
||||
"status": "context",
|
||||
"title": "Parity source metadata: openai/codex",
|
||||
"verification_required": "none_context_only"
|
||||
},
|
||||
{
|
||||
"category": "boot",
|
||||
"deferral_rationale": "",
|
||||
"dependencies": [
|
||||
"stream_0_governance"
|
||||
],
|
||||
"id": "CC2-RM-H0125-pinpoint-693-claw-analog-bootstrap-plan",
|
||||
"lifecycle_status": "done_verify",
|
||||
"owner_lane": "stream_1_worker_boot_session_control",
|
||||
"release_bucket": "alpha_blocker",
|
||||
"source_anchor": "ROADMAP.md:L7528",
|
||||
"source_context": "Clawable Coding Harness Roadmap > Pinpoint follow-up intake",
|
||||
"source_level": 2,
|
||||
"source_line": 7528,
|
||||
"source_ordinal": null,
|
||||
"source_path": "ROADMAP.md",
|
||||
"source_type": "roadmap_heading",
|
||||
"status": "done_verify",
|
||||
"title": "Pinpoint #693. `claw-analog` bootstrap-plan phase parser silently falls back to `\"unknown\"` \u2014 `lib.rs:1114` uses `.unwrap_or(\"unknown\")` for phase field; unrecognized phases emit opaque kind instead of typed error",
|
||||
"verification_required": "targeted_regression_or_acceptance_test_required"
|
||||
},
|
||||
{
|
||||
"category": "branch_recovery",
|
||||
"deferral_rationale": "",
|
||||
"dependencies": [
|
||||
"stream_0_governance"
|
||||
],
|
||||
"id": "CC2-RM-H0126-pinpoint-694-no-pre-push-cargo-build-gat",
|
||||
"lifecycle_status": "done_verify",
|
||||
"owner_lane": "stream_3_branch_test_recovery",
|
||||
"release_bucket": "alpha_blocker",
|
||||
"source_anchor": "ROADMAP.md:L7538",
|
||||
"source_context": "Clawable Coding Harness Roadmap > Pinpoint follow-up intake",
|
||||
"source_level": 2,
|
||||
"source_line": 7538,
|
||||
"source_ordinal": null,
|
||||
"source_path": "ROADMAP.md",
|
||||
"source_type": "roadmap_heading",
|
||||
"status": "done_verify",
|
||||
"title": "Pinpoint #694. No pre-push `cargo build` gate \u2014 stale field refs (`retry_after`, `Team` variant, `config_load_error_kind`) broke main build undetected until CI",
|
||||
"verification_required": "git_fixture_or_recovery_recipe_test"
|
||||
},
|
||||
{
|
||||
"category": "boot",
|
||||
"deferral_rationale": "",
|
||||
"dependencies": [
|
||||
"stream_0_governance"
|
||||
],
|
||||
"id": "CC2-RM-H0127-pinpoint-695-agent-starts-in-stale-wrong",
|
||||
"lifecycle_status": "done_verify",
|
||||
"owner_lane": "stream_1_worker_boot_session_control",
|
||||
"release_bucket": "alpha_blocker",
|
||||
"source_anchor": "ROADMAP.md:L7548",
|
||||
"source_context": "Clawable Coding Harness Roadmap > Pinpoint follow-up intake",
|
||||
"source_level": 2,
|
||||
"source_line": 7548,
|
||||
"source_ordinal": null,
|
||||
"source_path": "ROADMAP.md",
|
||||
"source_type": "roadmap_heading",
|
||||
"status": "done_verify",
|
||||
"title": "Pinpoint #695. Agent starts in stale/wrong worktree and burns a full turn before noticing \u2014 no pre-flight check for \"file exists on current branch\" or \"this .git is writable from sandbox\"",
|
||||
"verification_required": "worker_boot_state_machine_or_cli_json_contract_test"
|
||||
}
|
||||
],
|
||||
"schema_version": "cc2.board.v1",
|
||||
@@ -14839,7 +14902,7 @@
|
||||
"root": "/Users/bellman/Documents/Workspace/claw-code/.omx/research"
|
||||
},
|
||||
"roadmap": {
|
||||
"heading_count": 124,
|
||||
"heading_count": 127,
|
||||
"ordered_action_count": 542,
|
||||
"path": "ROADMAP.md",
|
||||
"sha256_prefix": "2aba3315e52f3079"
|
||||
@@ -14850,15 +14913,15 @@
|
||||
"adoption_overlay": 357,
|
||||
"parity_overlay": 20,
|
||||
"stream_0_governance": 221,
|
||||
"stream_1_worker_boot_session_control": 15,
|
||||
"stream_1_worker_boot_session_control": 17,
|
||||
"stream_2_event_reporting_contracts": 73,
|
||||
"stream_3_branch_test_recovery": 16,
|
||||
"stream_3_branch_test_recovery": 17,
|
||||
"stream_4_claws_first_execution": 5,
|
||||
"stream_5_plugin_mcp_lifecycle": 22
|
||||
},
|
||||
"by_release_bucket": {
|
||||
"2.x_intake": 30,
|
||||
"alpha_blocker": 240,
|
||||
"alpha_blocker": 243,
|
||||
"beta_adoption": 417,
|
||||
"context": 15,
|
||||
"ga_ecosystem": 22,
|
||||
@@ -14870,13 +14933,13 @@
|
||||
"latest_open_issue": 30,
|
||||
"parity_repo_context": 2,
|
||||
"roadmap_action": 542,
|
||||
"roadmap_heading": 124
|
||||
"roadmap_heading": 127
|
||||
},
|
||||
"by_status": {
|
||||
"active": 73,
|
||||
"context": 15,
|
||||
"deferred_with_rationale": 9,
|
||||
"done_verify": 313,
|
||||
"done_verify": 316,
|
||||
"open": 285,
|
||||
"rejected_not_claw": 2,
|
||||
"stale_done": 31,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Claw Code 2.0 Canonical Board
|
||||
|
||||
Generated from board schema: `2026-05-14T08:13:45+00:00`
|
||||
Generated from board schema: `2026-05-25T04:30:33+00:00`
|
||||
Schema version: `cc2.board.v1`
|
||||
Ultragoal mutation policy: `.omx/ultragoal` is leader-owned and was not modified by this rendering task.
|
||||
|
||||
@@ -8,7 +8,7 @@ Ultragoal mutation policy: `.omx/ultragoal` is leader-owned and was not modified
|
||||
|
||||
| Source | Frozen evidence |
|
||||
| --- | --- |
|
||||
| Roadmap | `ROADMAP.md` sha256 prefix `2aba3315e52f3079`; 124 headings; 542 ordered actions |
|
||||
| Roadmap | `ROADMAP.md` sha256 prefix `2aba3315e52f3079`; 127 headings; 542 ordered actions |
|
||||
| Approved plan | `.omx/plans/claw-code-2-0-adaptive-plan.md` sha256 prefix `e7ef6faf23bfc16b` |
|
||||
| Research bundle | root `/Users/bellman/Documents/Workspace/claw-code/.omx/research`; latest open issues 30; issue corpus 1000; codex/opencode clone metadata included |
|
||||
|
||||
@@ -16,11 +16,11 @@ Ultragoal mutation policy: `.omx/ultragoal` is leader-owned and was not modified
|
||||
|
||||
| Coverage gate | Mapped | Total | Status |
|
||||
| --- | --- | --- | --- |
|
||||
| ROADMAP headings | 124 | 124 | PASS |
|
||||
| ROADMAP headings | 127 | 127 | PASS |
|
||||
| ROADMAP ordered actions | 542 | 542 | PASS |
|
||||
| Duplicate heading lines | 0 | 0 | PASS |
|
||||
|
||||
Total canonical board items: **729**
|
||||
Total canonical board items: **732**
|
||||
|
||||
## Lifecycle Enum Reference
|
||||
|
||||
@@ -29,7 +29,7 @@ Total canonical board items: **729**
|
||||
| `active` | 73 | Current Claw Code 2.0 implementation surface that should remain visible on the board. |
|
||||
| `context` | 15 | Context-only heading or evidence anchor; not an implementation work item. |
|
||||
| `deferred_with_rationale` | 9 | Intentionally deferred; rationale must be present in the board item. |
|
||||
| `done_verify` | 313 | Marked as done upstream but retained for verification against current CC2 behavior. |
|
||||
| `done_verify` | 316 | Marked as done upstream but retained for verification against current CC2 behavior. |
|
||||
| `open` | 285 | Actionable unresolved work that needs implementation or acceptance evidence. |
|
||||
| `rejected_not_claw` | 2 | Excluded because it is not Claw Code product work. |
|
||||
| `stale_done` | 31 | Historically completed or merged work that may be stale and needs freshness checks before relying on it. |
|
||||
@@ -40,7 +40,7 @@ Total canonical board items: **729**
|
||||
| Bucket | Count | Meaning |
|
||||
| --- | --- | --- |
|
||||
| `2.x_intake` | 30 | Post-2.0 intake or follow-up candidate retained for sequencing. |
|
||||
| `alpha_blocker` | 240 | Must be resolved before alpha-quality autonomous coding lanes are dependable. |
|
||||
| `alpha_blocker` | 243 | Must be resolved before alpha-quality autonomous coding lanes are dependable. |
|
||||
| `beta_adoption` | 417 | Important for broader dogfood/adoption once alpha blockers are controlled. |
|
||||
| `context` | 15 | Non-actionable roadmap context. |
|
||||
| `ga_ecosystem` | 22 | Required for mature plugin/MCP/provider ecosystem behavior. |
|
||||
@@ -54,9 +54,9 @@ Total canonical board items: **729**
|
||||
| Adoption overlay — user-visible parity and release polish | 357 | 329 | `deferred_with_rationale` 3, `done_verify` 237, `open` 92, `rejected_not_claw` 2, `stale_done` 23 |
|
||||
| Parity overlay — opencode/codex comparison context | 20 | 16 | `context` 2, `deferred_with_rationale` 1, `done_verify` 5, `open` 11, `stale_done` 1 |
|
||||
| Stream 0 — Governance, intake, and cross-cutting roadmap triage | 221 | 198 | `active` 6, `context` 13, `deferred_with_rationale` 4, `done_verify` 45, `open` 147, `stale_done` 5, `superseded` 1 |
|
||||
| Stream 1 — Worker boot and session control | 15 | 14 | `active` 8, `deferred_with_rationale` 1, `open` 6 |
|
||||
| Stream 1 — Worker boot and session control | 17 | 16 | `active` 8, `deferred_with_rationale` 1, `done_verify` 2, `open` 6 |
|
||||
| Stream 2 — Event/reporting contracts | 73 | 73 | `active` 45, `done_verify` 20, `open` 8 |
|
||||
| Stream 3 — Branch/test recovery | 16 | 14 | `active` 6, `done_verify` 1, `open` 7, `stale_done` 2 |
|
||||
| Stream 3 — Branch/test recovery | 17 | 15 | `active` 6, `done_verify` 2, `open` 7, `stale_done` 2 |
|
||||
| Stream 4 — Claws-first task execution | 5 | 5 | `active` 4, `done_verify` 1 |
|
||||
| Stream 5 — Plugin/MCP lifecycle | 22 | 22 | `active` 4, `done_verify` 4, `open` 14 |
|
||||
|
||||
@@ -68,7 +68,7 @@ Total canonical board items: **729**
|
||||
| `latest_open_issue` | 30 |
|
||||
| `parity_repo_context` | 2 |
|
||||
| `roadmap_action` | 542 |
|
||||
| `roadmap_heading` | 124 |
|
||||
| `roadmap_heading` | 127 |
|
||||
|
||||
## Board Items by Stream
|
||||
|
||||
@@ -704,6 +704,8 @@ Total canonical board items: **729**
|
||||
| `CC2-RM-A0363-surface-inconsistency-cluster-of-3-after` | **Surface inconsistency (cluster of 3)**: after #143 Phase 1, the behavior matrix is: | `ROADMAP.md:L5515` / `roadmap_action` | `alpha_blocker` | `open` | `plugin_mcp_lifecycle_contract_test` | `stream_1_worker_boot_session_control` | — |
|
||||
| `CC2-RM-A0391-remove-the-error-prefix-from-format-unkn` | Remove the "error:" prefix from format_unknown_verb_option (already added by top-level handler) | `ROADMAP.md:L5916` / `roadmap_action` | `alpha_blocker` | `open` | `worker_boot_state_machine_or_cli_json_contract_test` | none | — |
|
||||
| `CC2-RM-A0512-system-prompt-output-format-json-exposes` | **`system-prompt --output-format json` exposes `"__SYSTEM_PROMPT_DYNAMIC_BOUNDARY__"` as a literal element in the `sections` array — an internal split delimiter leaked into the public structured output** — dogfooded 2026-04-30 by Jobdori on `e939777f`. Running `claw system-prompt --output-format json` returns `{"kind":"system-prompt","message":"<full prose>","sections":["You are an interactive agent...", "# System\n...", "# Doing tasks\n...", "# Executing actions with care\n...", "__SYSTEM_PROMPT_DYNAMIC_BOUNDARY__", "# Environment context\n...", "# Project context\n...", "# Claude instructions\n...", "# Runtime config\n..."]}`. The `sections` array has 9 elements; element index 4 is the raw string `"__SYSTEM_PROMPT_DYNAMIC_BOUNDARY__"`. This internal sentinel marks the boundary between the static and dynamic sections of the compiled system prompt, used during assembly to split the prompt at injection time. It appears in the public JSON output verbatim as a first-class section, indistinguishable from real sections by type alone. Automation that iterates `sections[]` must special-case this sentinel or it will process an internal implementation string as if it were a real system prompt section. **Required fix shape:** (a) strip `"__SYSTEM_PROMPT_DYNAMIC_BOUNDARY__"` and any similar internal delimiters from the `sections` array before serializing to JSON; (b) if the static/dynamic boundary is semantically meaningful for callers, expose it as a structured metadata field such as `boundary_index:4` or as a `section_type:"static"\|"dynamic"` field on each section entry, not as a raw sentinel string in the array; (c) rename the `sections` type from `string[]` to `[{id, type, content}]` to enable this without breaking the boundary signal; (d) add regression coverage proving the `system-prompt --output-format json` output's `sections` array contains no elements whose value equals `"__SYSTEM_PROMPT_DYNAMIC_BOUNDARY__"` or matches `/__[A-Z_]+__/`. **Why this matters:** internal sentinel strings in public JSON are a contract liability — they couple the wire format to internal implementation details. Any refactor that renames or removes the sentinel breaks callers that don't special-case it, and automation that doesn't know to filter it will miscount, misparse, or misrender the system prompt. Source: Jobdori live dogfood, `e939777f`, 2026-04-30. | `ROADMAP.md:L6333` / `roadmap_action` | `beta_adoption` | `open` | `worker_boot_state_machine_or_cli_json_contract_test` | none | — |
|
||||
| `CC2-RM-H0125-pinpoint-693-claw-analog-bootstrap-plan` | Pinpoint #693. `claw-analog` bootstrap-plan phase parser silently falls back to `"unknown"` — `lib.rs:1114` uses `.unwrap_or("unknown")` for phase field; unrecognized phases emit opaque kind instead of typed error | `ROADMAP.md:L7528` / `roadmap_heading` | `alpha_blocker` | `done_verify` | `targeted_regression_or_acceptance_test_required` | `stream_0_governance` | — |
|
||||
| `CC2-RM-H0127-pinpoint-695-agent-starts-in-stale-wrong` | Pinpoint #695. Agent starts in stale/wrong worktree and burns a full turn before noticing — no pre-flight check for "file exists on current branch" or "this .git is writable from sandbox" | `ROADMAP.md:L7548` / `roadmap_heading` | `alpha_blocker` | `done_verify` | `worker_boot_state_machine_or_cli_json_contract_test` | `stream_0_governance` | — |
|
||||
|
||||
### Stream 2 — Event/reporting contracts
|
||||
|
||||
@@ -803,6 +805,7 @@ Total canonical board items: **729**
|
||||
| `CC2-RM-A0410-remediation-registry-a-function-remediat` | **Remediation registry:** A function `remediation_for(kind: &str, operation: &str) -> Remediation` that maps `(error_kind, operation_context)` pairs to stable remediation structs: | `ROADMAP.md:L6041` / `roadmap_action` | `alpha_blocker` | `open` | `targeted_regression_or_acceptance_test_required` | `stream_2_event_reporting_contracts` | — |
|
||||
| `CC2-RM-A0411-stable-hint-outputs-per-class-each-error` | **Stable hint outputs per class:** Each `error_kind` maps to exactly one remediation shape. No more prose splitting. | `ROADMAP.md:L6049` / `roadmap_action` | `alpha_blocker` | `open` | `targeted_regression_or_acceptance_test_required` | `stream_2_event_reporting_contracts` | — |
|
||||
| `CC2-RM-A0412-golden-fixture-tests-test-each-kind-oper` | **Golden fixture tests:** Test each `(kind, operation)` pair against expected remediation output as golden fixtures instead of the current `split_error_hint()` string hacks. | `ROADMAP.md:L6050` / `roadmap_action` | `alpha_blocker` | `open` | `targeted_regression_or_acceptance_test_required` | `stream_2_event_reporting_contracts` | — |
|
||||
| `CC2-RM-H0126-pinpoint-694-no-pre-push-cargo-build-gat` | Pinpoint #694. No pre-push `cargo build` gate — stale field refs (`retry_after`, `Team` variant, `config_load_error_kind`) broke main build undetected until CI | `ROADMAP.md:L7538` / `roadmap_heading` | `alpha_blocker` | `done_verify` | `git_fixture_or_recovery_recipe_test` | `stream_0_governance` | — |
|
||||
|
||||
### Stream 4 — Claws-first task execution
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"version": 1,
|
||||
"createdAt": "2026-05-14T07:53:46.061Z",
|
||||
"updatedAt": "2026-05-15T04:38:54.887Z",
|
||||
"updatedAt": "2026-05-25T04:18:52.711Z",
|
||||
"briefPath": ".omx/ultragoal/brief.md",
|
||||
"goalsPath": ".omx/ultragoal/goals.json",
|
||||
"ledgerPath": ".omx/ultragoal/ledger.jsonl",
|
||||
@@ -148,7 +148,19 @@
|
||||
"updatedAt": "2026-05-15T04:38:54.887Z",
|
||||
"evidence": "G012-final-gate complete: team g012-final-gate-ultra-e61d2271 8/8 tasks complete; final gate log /tmp/g012-final-quality-gate-pass4.log; commit 04c2abb pushed; docs/pr-triage-g012-final-gate.json docs/pr-issue-resolution-gate.md docs/g012-final-release-readiness-report.md; .omx/ultragoal/goals.json and ledger.jsonl updated; aiSlopCleaner and codeReview evidence included in quality gate JSON.",
|
||||
"completedAt": "2026-05-15T04:38:54.887Z"
|
||||
},
|
||||
{
|
||||
"id": "G013-implement-roadmap-pinpoints-693-695",
|
||||
"title": "Implement ROADMAP pinpoints #693-#695",
|
||||
"objective": "Map and implement the newly appended ROADMAP.md pinpoints #693, #694, and #695 after reset to origin/main: typed claw-analog bootstrap phase errors, a local pre-push cargo build gate, and startup/worktree preflight diagnostics; update CC2 board/coverage and verify with targeted and workspace checks.",
|
||||
"status": "in_progress",
|
||||
"attempt": 1,
|
||||
"createdAt": "2026-05-25T04:18:43.420Z",
|
||||
"updatedAt": "2026-05-25T04:18:52.711Z",
|
||||
"evidence": "Current-head verification after reset: python3 scripts/validate_cc2_board.py --board .omx/cc2/board.json failed with unmapped ROADMAP headings [7528,7538,7548], corresponding to Pinpoints #693-#695.",
|
||||
"startedAt": "2026-05-25T04:18:52.711Z"
|
||||
}
|
||||
],
|
||||
"codexObjective": "Complete the approved Claw Code 2.0 ultragoal delivery: implement all classified ROADMAP.md backlog work through execution-sized stream goals G001-G012, using .omx/ultragoal/ledger.jsonl as the durable audit trail and .omx/plans/claw-code-2-0-adaptive-plan.md as the source plan."
|
||||
"codexObjective": "Complete the approved Claw Code 2.0 ultragoal delivery: implement all classified ROADMAP.md backlog work through execution-sized stream goals G001-G012, using .omx/ultragoal/ledger.jsonl as the durable audit trail and .omx/plans/claw-code-2-0-adaptive-plan.md as the source plan.",
|
||||
"activeGoalId": "G013-implement-roadmap-pinpoints-693-695"
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -7552,3 +7552,12 @@ Original filing (2026-04-18): the session emitted `SessionStart hook (completed)
|
||||
**Required fix shape.** (a) Add a startup pre-flight in `worker_boot.rs` that, for any task mentioning a file path, checks `git ls-files --error-unmatch <path>` and emits a structured `kind:"file_absent_on_branch"` warning before the first LLM call; (b) surface `.git` writability check at sandbox init time and emit `kind:"git_metadata_not_writable"` with the path if commits would fail; (c) add a "current worktree" breadcrumb to the session startup log so agents and operators can confirm the correct tree before work begins.
|
||||
|
||||
**Source.** Gaebal probe 2026-05-25 12:02 GMT+9; confirmed during #3097 trident.rs fix attempt. [SCOPE: ultraworkers/claw-code]
|
||||
||||||| parent of 52161c78 (docs(roadmap): add #330 — resume mode stats/cost always zero)
|
||||
|
||||
330. **`/stats` and `/cost` in `--resume` mode always return zero token counts regardless of saved session usage** — dogfooded 2026-04-29 by Jobdori on current main (`e7074f4`). Running `claw --output-format json --resume latest /stats` and `claw --output-format json --resume latest /cost` both return `{"input_tokens": 0, "output_tokens": 0, "total_tokens": 0, ...}` even when the session file was created by a real interactive claw run. The same zero-fill is produced by `claw --output-format json status` (usage sub-object). Inspection of the default session path (`~/.claw/sessions/.../session-*.jsonl`) shows the file has only 2 events (`session_meta`, `message`) with no usage/token records embedded. Two candidate root causes: (a) session serialization never writes usage events into the JSONL file even after real prompt exchanges, so resume-mode has no usage to replay; (b) resume-mode stat accumulation reads usage from memory-side counters that are always zero because no API calls happened in the resume-only invocation. Either way, the operator effect is the same: `--resume` + `/stats`/`/cost` cannot report what the session actually consumed. **Required fix shape:** (a) persist per-turn usage records (input/output/cache tokens per exchange) into the session JSONL at write time so resume-mode can reconstruct cumulative counts by replay; (b) expose a `"total_usage"` summary block at the tail of every session JSONL so resume-mode can read it in O(1) without full replay; (c) ensure `/stats` and `/cost` in resume-mode sum the persisted usage, not memory-side live counters; (d) add regression coverage proving `--resume SESSION.jsonl /stats` returns non-zero token counts after a session that made real API calls. **Why this matters:** token usage visibility is critical for quota management and cost attribution; if `--resume` mode always shows zeros, operators and orchestration lanes cannot trust usage data from saved sessions and must rely on external billing dashboards instead of in-band tooling. Source: Jobdori live dogfood on mengmotaHost, claw-code `e7074f4`, 2026-04-29.
|
||||
|
||||
696. **`claw compact` (and likely other REPL-only commands) hangs indefinitely in non-interactive mode with no TTY — there is no timeout, no stdin-closed guard, and no `--output-format json` fast-exit path** — dogfooded 2026-05-25 on `bb2a9238`. Running `./rust/target/debug/claw compact --output-format json --help </dev/null` (or `compact` without `--help`) never returns: the process blocks waiting for interactive input that will never arrive. No timeout fires, no error is emitted on stdout, no `{"kind":"error",...}` JSON is produced. The caller must `kill` the process externally. This is a clawability gap: any orchestrator or claw that probes `compact` to discover its schema or trigger non-interactive compaction will hang until a watchdog kills it. **Required fix shape:** (a) detect stdin EOF / non-TTY at startup for REPL-only commands and emit `{"kind":"error","error_kind":"interactive_only","message":"claw compact requires an interactive terminal"}` with exit 1 instead of blocking; (b) honour `--output-format json` as an implicit non-interactive signal — if the flag is set and no TTY is present, exit immediately with a typed error; (c) add a global `--timeout <seconds>` flag or default 30 s watchdog for non-interactive invocations; (d) add regression coverage proving `claw compact </dev/null` exits non-zero within 1 s with a structured error. **Why this matters:** automation layers probe commands via `</dev/null` to discover schema; a hung process blocks the probe indefinitely and requires external timeout management, making compact undiscoverable and unscriptable. Source: Jobdori dogfood on `bb2a9238`, 2026-05-25.
|
||||
|
||||
697. **`claw plugins remove <name>` silently returns `status:"ok"` with exit 0 when the named plugin does not exist — no `not_found` error, no non-zero exit, no indication the operation was a no-op; sibling: `claw agents <unknown-subcommand>` returns `action:"help"` with exit 0 instead of a typed `unknown_subcommand` error** — dogfooded 2026-05-25 on `63a5a874`. Reproduction: `claw plugins remove nonexistent-plugin --output-format json </dev/null` returns `{"kind":"plugin","action":"remove","status":"ok","error":null,...}` and exits 0. No plugin named `nonexistent-plugin` exists. A caller cannot distinguish "plugin was successfully removed" from "plugin was never there" — both produce the same `status:"ok"` envelope. Sibling: `claw agents stop nonexistent-agent --output-format json </dev/null` returns `{"kind":"agents","action":"help","unexpected":"stop nonexistent-agent",...}` and exits 0 — unknown subcommand falls through to help output rather than a typed error with exit 1. **Required fix shape:** (a) `plugins remove` must check whether the named plugin exists before reporting success; emit `{"kind":"plugin","action":"remove","status":"error","error_kind":"plugin_not_found","plugin_name":"<name>"}` with exit 1 when the plugin is absent; (b) `agents <unknown>` must emit `{"kind":"agents","action":"error","error_kind":"unknown_subcommand","subcommand":"<token>","supported":["list","help"]}` with exit 1 instead of falling back to help output with exit 0; (c) add regression tests proving both paths exit 1 with typed error envelopes. **Why this matters:** idempotent-but-silent remove is fine for infrastructure tools with explicit idempotency contracts; claw has no such contract, and `status:"ok"` for a name-miss means automation cannot audit whether a remove actually ran vs was a no-op. Source: Jobdori dogfood on `63a5a874`, 2026-05-25.
|
||||
|
||||
698. **Config deprecation warnings emit once per `ConfigLoader::load()` call, so surfaces that call `load()` multiple times in a single invocation emit duplicate `warning:` lines to stderr — `claw plugins list` and `claw mcp list` each print the same deprecation warning twice** — dogfooded 2026-05-25 on `c345ce6d`. Reproduction: `echo '{"enabledPlugins": {}}' > ~/.claw/settings.json && claw plugins list 2>&1 | grep warning` prints the same `field "enabledPlugins" is deprecated. Use "plugins.enabled" instead` line twice. Root cause: `config.rs:304` emits `eprintln!("warning: {warning}")` for every warning in every `loader.load()` call; surfaces like `plugins_command_payload_for` and `render_mcp_report_json_for` each trigger an independent `loader.load()` (one for runtime config, one inside the command handler), multiplying the stderr output. `skills list` emits only one warning because its command path calls `load()` once; `plugins` and `mcp` emit two. **Required fix shape:** (a) track already-emitted warning strings in a process-lifetime `std::sync::OnceLock<Mutex<HashSet<String>>>` in `config.rs` and skip re-emitting duplicates within the same process run; or (b) collect all warnings at a single call site after all config loads are complete and emit once with dedup; or (c) change `load()` to return warnings alongside the result instead of eagerly printing them, letting call sites emit once. Option (a) is a minimal one-file fix. **Why this matters:** duplicate warnings make the CLI look buggy, cause CI log noise, and — when the deprecation warning fires on every invocation — are more likely to be `tail -f`'d away than acted on. A single clean warning per invocation is the standard. Source: Jobdori dogfood on `c345ce6d`, 2026-05-25.
|
||||
|
||||
47
docs/g013-roadmap-pinpoints-693-695-verification-map.md
Normal file
47
docs/g013-roadmap-pinpoints-693-695-verification-map.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# G013 ROADMAP pinpoints #693-#695 verification map
|
||||
|
||||
This map records the current-head follow-up that was discovered after resetting
|
||||
`main` to `origin/main`: ROADMAP.md contained three new Pinpoint headings not
|
||||
covered by the Claw Code 2.0 board.
|
||||
|
||||
## Pinpoint #693 — typed phase error instead of silent `unknown`
|
||||
|
||||
- Code: `rust/crates/claw-analog/src/lib.rs`
|
||||
- Behavior: `format_rag_query_json_for_model` now rejects missing, empty, or
|
||||
literal `"unknown"` phase values with a structured error envelope containing
|
||||
`kind:"unknown_bootstrap_phase"`, `field:"phase"`, and `received_value`.
|
||||
- Regression tests: `rag_response_missing_phase_returns_typed_error` and
|
||||
`rag_response_unknown_phase_returns_typed_error`.
|
||||
|
||||
## Pinpoint #694 — local pre-push build gate
|
||||
|
||||
- Hook: `.github/hooks/pre-push`
|
||||
- Install command: `git config core.hooksPath .github/hooks`
|
||||
- Gate: `cargo build --manifest-path rust/Cargo.toml --workspace`
|
||||
- Purpose: mirror the CI build job locally so stale field/variant references are
|
||||
caught before push.
|
||||
|
||||
## Pinpoint #695 — startup/worktree preflight diagnostics
|
||||
|
||||
- Code: `rust/crates/runtime/src/worker_boot.rs`
|
||||
- Behavior: `startup_preflight_warnings` and
|
||||
`WorkerRegistry::observe_startup_preflight` emit structured warnings before
|
||||
the first model turn when a task mentions a path not tracked on the current
|
||||
branch (`file_absent_on_branch`) or git metadata is not writable
|
||||
(`git_metadata_not_writable`).
|
||||
- Regression tests:
|
||||
- `startup_preflight_warns_when_task_file_is_absent_on_branch`
|
||||
- `startup_preflight_records_structured_warning_event`
|
||||
|
||||
## Verification commands
|
||||
|
||||
```bash
|
||||
python3 scripts/generate_cc2_board.py
|
||||
python3 scripts/validate_cc2_board.py --board .omx/cc2/board.json
|
||||
python3 .omx/cc2/validate_issue_parity_intake.py .omx/cc2/issue-parity-intake.json
|
||||
bash -n .github/hooks/pre-push
|
||||
cargo fmt --manifest-path rust/Cargo.toml --all -- --check
|
||||
cargo test --manifest-path rust/Cargo.toml -p claw-analog rag_response_ -- --nocapture
|
||||
cargo test --manifest-path rust/Cargo.toml -p runtime startup_preflight -- --nocapture
|
||||
cargo build --manifest-path rust/Cargo.toml --workspace
|
||||
```
|
||||
0
rust/Cargo.lock
generated
Normal file → Executable file
0
rust/Cargo.lock
generated
Normal file → Executable file
@@ -234,7 +234,7 @@ pub fn resolve_model_alias(model: &str) -> String {
|
||||
#[must_use]
|
||||
pub fn metadata_for_model(model: &str) -> Option<ProviderMetadata> {
|
||||
let canonical = resolve_model_alias(model);
|
||||
if canonical.starts_with("claude") {
|
||||
if canonical.starts_with("claude") || canonical.starts_with("anthropic/") {
|
||||
return Some(ProviderMetadata {
|
||||
provider: ProviderKind::Anthropic,
|
||||
auth_env: "ANTHROPIC_API_KEY",
|
||||
@@ -640,6 +640,14 @@ pub fn model_token_limit(model: &str) -> Option<ModelTokenLimit> {
|
||||
max_output_tokens: 16_384,
|
||||
context_window_tokens: 256_000,
|
||||
}),
|
||||
"qwen-max" => Some(ModelTokenLimit {
|
||||
max_output_tokens: 8_192,
|
||||
context_window_tokens: 131_072,
|
||||
}),
|
||||
"qwen-plus" => Some(ModelTokenLimit {
|
||||
max_output_tokens: 8_192,
|
||||
context_window_tokens: 131_072,
|
||||
}),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1111,7 +1111,24 @@ enum BlockKind {
|
||||
|
||||
pub(crate) fn format_rag_query_json_for_model(body: &str) -> Result<String, String> {
|
||||
let v: Value = serde_json::from_str(body).map_err(|e| format!("invalid JSON: {e}"))?;
|
||||
let phase = v.get("phase").and_then(|x| x.as_str()).unwrap_or("unknown");
|
||||
let phase = v.get("phase").and_then(|x| x.as_str()).ok_or_else(|| {
|
||||
json!({
|
||||
"kind": "unknown_bootstrap_phase",
|
||||
"field": "phase",
|
||||
"received_value": v.get("phase").cloned().unwrap_or(Value::Null),
|
||||
"message": "RAG response is missing a string phase; refusing to silently render phase as unknown"
|
||||
})
|
||||
.to_string()
|
||||
})?;
|
||||
if phase.trim().is_empty() || phase == "unknown" {
|
||||
return Err(json!({
|
||||
"kind": "unknown_bootstrap_phase",
|
||||
"field": "phase",
|
||||
"received_value": phase,
|
||||
"message": "RAG response phase must be a concrete phase name"
|
||||
})
|
||||
.to_string());
|
||||
}
|
||||
let hits = v
|
||||
.get("hits")
|
||||
.and_then(|h| h.as_array())
|
||||
@@ -2557,6 +2574,20 @@ mod tests {
|
||||
assert!(out.contains("score="));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rag_response_missing_phase_returns_typed_error() {
|
||||
let err = format_rag_query_json_for_model(r#"{"hits":[]}"#).unwrap_err();
|
||||
assert!(err.contains(r#""kind":"unknown_bootstrap_phase""#));
|
||||
assert!(err.contains(r#""field":"phase""#));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rag_response_unknown_phase_returns_typed_error() {
|
||||
let err = format_rag_query_json_for_model(r#"{"hits":[],"phase":"unknown"}"#).unwrap_err();
|
||||
assert!(err.contains(r#""kind":"unknown_bootstrap_phase""#));
|
||||
assert!(err.contains(r#""received_value":"unknown""#));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resolve_rag_base_url_toml_beats_env() {
|
||||
let _g = mock_env_lock();
|
||||
|
||||
@@ -2260,7 +2260,7 @@ pub fn handle_plugins_slash_command(
|
||||
reload_runtime: true,
|
||||
})
|
||||
}
|
||||
Some("uninstall") => {
|
||||
Some("remove") | Some("uninstall") => {
|
||||
let Some(target) = target else {
|
||||
return Ok(PluginsCommandResult {
|
||||
message: "Usage: /plugins uninstall <plugin-id>".to_string(),
|
||||
@@ -2327,7 +2327,10 @@ pub fn handle_agents_slash_command(args: Option<&str>, cwd: &Path) -> std::io::R
|
||||
Ok(render_agents_report(&agents))
|
||||
}
|
||||
Some(args) if is_help_arg(args) => Ok(render_agents_usage(None)),
|
||||
Some(args) => Ok(render_agents_usage(Some(args))),
|
||||
Some(args) => Err(std::io::Error::new(
|
||||
std::io::ErrorKind::InvalidInput,
|
||||
format!("unknown agents subcommand: {args}. Supported: list, help"),
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2348,7 +2351,10 @@ pub fn handle_agents_slash_command_json(args: Option<&str>, cwd: &Path) -> std::
|
||||
Ok(render_agents_report_json(cwd, &agents))
|
||||
}
|
||||
Some(args) if is_help_arg(args) => Ok(render_agents_usage_json(None)),
|
||||
Some(args) => Ok(render_agents_usage_json(Some(args))),
|
||||
Some(args) => Err(std::io::Error::new(
|
||||
std::io::ErrorKind::InvalidInput,
|
||||
format!("unknown agents subcommand: {args}. Supported: list, help"),
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3619,7 +3625,9 @@ fn render_agents_report_json(cwd: &Path, agents: &[AgentSummary]) -> Value {
|
||||
.count();
|
||||
json!({
|
||||
"kind": "agents",
|
||||
"status": "ok",
|
||||
"action": "list",
|
||||
"status": "ok",
|
||||
"working_directory": cwd.display().to_string(),
|
||||
"count": agents.len(),
|
||||
"summary": {
|
||||
@@ -3701,7 +3709,9 @@ fn render_skills_report_json(skills: &[SkillSummary]) -> Value {
|
||||
.count();
|
||||
json!({
|
||||
"kind": "skills",
|
||||
"status": "ok",
|
||||
"action": "list",
|
||||
"status": "ok",
|
||||
"summary": {
|
||||
"total": skills.len(),
|
||||
"active": active,
|
||||
@@ -3736,6 +3746,7 @@ fn render_skill_install_report_json(skill: &InstalledSkill) -> Value {
|
||||
json!({
|
||||
"kind": "skills",
|
||||
"action": "install",
|
||||
"status": "ok",
|
||||
"result": "installed",
|
||||
"invocation_name": &skill.invocation_name,
|
||||
"invoke_as": format!("${}", skill.invocation_name),
|
||||
@@ -3924,6 +3935,8 @@ fn render_agents_usage_json(unexpected: Option<&str>) -> Value {
|
||||
json!({
|
||||
"kind": "agents",
|
||||
"action": "help",
|
||||
"ok": unexpected.is_none(),
|
||||
"status": if unexpected.is_some() { "error" } else { "ok" },
|
||||
"usage": {
|
||||
"slash_command": "/agents [list|help]",
|
||||
"direct_cli": "claw agents [list|help]",
|
||||
@@ -3953,6 +3966,8 @@ fn render_skills_usage_json(unexpected: Option<&str>) -> Value {
|
||||
json!({
|
||||
"kind": "skills",
|
||||
"action": "help",
|
||||
"ok": unexpected.is_none(),
|
||||
"status": if unexpected.is_some() { "error" } else { "ok" },
|
||||
"usage": {
|
||||
"slash_command": "/skills [list|install <path>|help|<skill> [args]]",
|
||||
"aliases": ["/skill"],
|
||||
@@ -3995,6 +4010,8 @@ fn render_mcp_usage_json(unexpected: Option<&str>) -> Value {
|
||||
json!({
|
||||
"kind": "mcp",
|
||||
"action": "help",
|
||||
"ok": unexpected.is_none(),
|
||||
"status": if unexpected.is_some() { "error" } else { "ok" },
|
||||
"usage": {
|
||||
"slash_command": "/mcp [list|show <server>|help]",
|
||||
"direct_cli": "claw mcp [list|show <server>|help]",
|
||||
@@ -5298,6 +5315,7 @@ mod tests {
|
||||
|
||||
assert_eq!(report["kind"], "agents");
|
||||
assert_eq!(report["action"], "list");
|
||||
assert_eq!(report["status"], "ok");
|
||||
assert_eq!(report["working_directory"], workspace.display().to_string());
|
||||
assert_eq!(report["count"], 3);
|
||||
assert_eq!(report["summary"]["active"], 2);
|
||||
@@ -5313,12 +5331,16 @@ mod tests {
|
||||
let help = handle_agents_slash_command_json(Some("help"), &workspace).expect("agents help");
|
||||
assert_eq!(help["kind"], "agents");
|
||||
assert_eq!(help["action"], "help");
|
||||
assert_eq!(help["status"], "ok");
|
||||
assert_eq!(help["usage"]["direct_cli"], "claw agents [list|help]");
|
||||
|
||||
let unexpected = handle_agents_slash_command_json(Some("show planner"), &workspace)
|
||||
.expect("agents usage");
|
||||
assert_eq!(unexpected["action"], "help");
|
||||
assert_eq!(unexpected["unexpected"], "show planner");
|
||||
// Unknown agents subcommands now return Err so CLI layer can exit 1.
|
||||
let unexpected_err = handle_agents_slash_command_json(Some("show planner"), &workspace);
|
||||
assert!(unexpected_err.is_err());
|
||||
assert!(unexpected_err
|
||||
.unwrap_err()
|
||||
.to_string()
|
||||
.contains("show planner"));
|
||||
|
||||
let _ = fs::remove_dir_all(workspace);
|
||||
let _ = fs::remove_dir_all(user_home);
|
||||
@@ -5424,6 +5446,7 @@ mod tests {
|
||||
);
|
||||
assert_eq!(report["kind"], "skills");
|
||||
assert_eq!(report["action"], "list");
|
||||
assert_eq!(report["status"], "ok");
|
||||
assert_eq!(report["summary"]["active"], 3);
|
||||
assert_eq!(report["summary"]["shadowed"], 1);
|
||||
assert_eq!(report["skills"][0]["name"], "plan");
|
||||
@@ -5435,6 +5458,7 @@ mod tests {
|
||||
let help = handle_skills_slash_command_json(Some("help"), &workspace).expect("skills help");
|
||||
assert_eq!(help["kind"], "skills");
|
||||
assert_eq!(help["action"], "help");
|
||||
assert_eq!(help["status"], "ok");
|
||||
assert_eq!(help["usage"]["aliases"][0], "/skill");
|
||||
assert_eq!(
|
||||
help["usage"]["direct_cli"],
|
||||
@@ -5456,9 +5480,14 @@ mod tests {
|
||||
assert!(agents_help
|
||||
.contains("Sources .claw/agents, ~/.claw/agents, $CLAW_CONFIG_HOME/agents"));
|
||||
|
||||
let agents_unexpected =
|
||||
super::handle_agents_slash_command(Some("show planner"), &cwd).expect("agents usage");
|
||||
assert!(agents_unexpected.contains("Unexpected show planner"));
|
||||
// Unknown agents subcommands now return Err (typed error) instead of Ok+help text
|
||||
// so that the CLI layer can exit 1. The error message names the unexpected input.
|
||||
let agents_unexpected_err = super::handle_agents_slash_command(Some("show planner"), &cwd);
|
||||
assert!(agents_unexpected_err.is_err());
|
||||
assert!(agents_unexpected_err
|
||||
.unwrap_err()
|
||||
.to_string()
|
||||
.contains("show planner"));
|
||||
|
||||
let skills_help =
|
||||
super::handle_skills_slash_command(Some("--help"), &cwd).expect("skills help");
|
||||
@@ -5494,6 +5523,7 @@ mod tests {
|
||||
let sources = skills_help_json["usage"]["sources"]
|
||||
.as_array()
|
||||
.expect("skills help sources");
|
||||
assert_eq!(skills_help_json["status"], "ok");
|
||||
assert_eq!(skills_help_json["usage"]["aliases"][0], "/skill");
|
||||
assert!(sources.iter().any(|value| value == ".omc/skills"));
|
||||
assert!(sources.iter().any(|value| value == ".agents/skills"));
|
||||
@@ -5879,6 +5909,13 @@ mod tests {
|
||||
assert!(report.contains("Invoke as $help"));
|
||||
assert!(report.contains(&install_root.display().to_string()));
|
||||
|
||||
let json_report = super::render_skill_install_report_json(&installed);
|
||||
assert_eq!(json_report["kind"], "skills");
|
||||
assert_eq!(json_report["action"], "install");
|
||||
assert_eq!(json_report["status"], "ok");
|
||||
assert_eq!(json_report["invocation_name"], "help");
|
||||
assert_eq!(json_report["invoke_as"], "$help");
|
||||
|
||||
let roots = vec![SkillRoot {
|
||||
source: DefinitionSource::UserCodexHome,
|
||||
path: install_root.clone(),
|
||||
|
||||
@@ -16,5 +16,8 @@ telemetry = { path = "../telemetry" }
|
||||
tokio = { version = "1", features = ["io-std", "io-util", "macros", "process", "rt", "rt-multi-thread", "time"] }
|
||||
walkdir = "2"
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = "3"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
@@ -1,7 +1,22 @@
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::{BTreeMap, HashSet};
|
||||
use std::fmt::{Display, Formatter};
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Mutex;
|
||||
|
||||
/// Process-lifetime set of already-emitted config deprecation warning strings.
|
||||
/// Prevents duplicate warnings when `ConfigLoader::load()` is called multiple
|
||||
/// times within a single CLI invocation. (ROADMAP #698)
|
||||
static EMITTED_CONFIG_WARNINGS: std::sync::OnceLock<Mutex<HashSet<String>>> =
|
||||
std::sync::OnceLock::new();
|
||||
|
||||
fn emit_config_warning_once(warning: &str) {
|
||||
let set = EMITTED_CONFIG_WARNINGS.get_or_init(|| Mutex::new(HashSet::new()));
|
||||
let mut guard = set.lock().unwrap_or_else(|e| e.into_inner());
|
||||
if guard.insert(warning.to_string()) {
|
||||
eprintln!("warning: {warning}");
|
||||
}
|
||||
}
|
||||
|
||||
use crate::json::JsonValue;
|
||||
use crate::sandbox::{FilesystemIsolationMode, SandboxConfig};
|
||||
@@ -301,7 +316,7 @@ impl ConfigLoader {
|
||||
}
|
||||
|
||||
for warning in &all_warnings {
|
||||
eprintln!("warning: {warning}");
|
||||
emit_config_warning_once(&warning.to_string());
|
||||
}
|
||||
|
||||
let merged_value = JsonValue::Object(merged.clone());
|
||||
|
||||
@@ -438,13 +438,24 @@ fn normalize_path(path: &Path) -> PathBuf {
|
||||
/// Extract repository name from a path for event context.
|
||||
fn extract_repo_name(cwd: &str) -> Option<String> {
|
||||
let path = Path::new(cwd);
|
||||
// Try to find a .git directory to identify repo root
|
||||
let mut current = Some(path);
|
||||
while let Some(p) = current {
|
||||
if p.join(".git").is_dir() {
|
||||
return p.file_name().map(|n| n.to_string_lossy().to_string());
|
||||
// Ask git from the cwd itself. Walking ancestors manually can accidentally
|
||||
// classify synthetic/nonexistent paths as an unrelated parent repo (for
|
||||
// example `/tmp/.git`), which makes trust events point at the wrong repo.
|
||||
if path.is_dir() {
|
||||
if let Ok(output) = std::process::Command::new("git")
|
||||
.args(["rev-parse", "--show-toplevel"])
|
||||
.current_dir(path)
|
||||
.output()
|
||||
{
|
||||
if output.status.success() {
|
||||
let root = String::from_utf8_lossy(&output.stdout).trim().to_string();
|
||||
if !root.is_empty() {
|
||||
return Path::new(&root)
|
||||
.file_name()
|
||||
.map(|n| n.to_string_lossy().to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
current = p.parent();
|
||||
}
|
||||
// Fallback: use the last component of the path
|
||||
path.file_name().map(|n| n.to_string_lossy().to_string())
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
@@ -73,6 +74,7 @@ pub struct WorkerFailure {
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum WorkerEventKind {
|
||||
Spawning,
|
||||
StartupPreflightWarning,
|
||||
TrustRequired,
|
||||
ToolPermissionRequired,
|
||||
TrustResolved,
|
||||
@@ -102,6 +104,21 @@ pub enum WorkerPromptTarget {
|
||||
Unknown,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum WorkerStartupPreflightWarningKind {
|
||||
FileAbsentOnBranch,
|
||||
GitMetadataNotWritable,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub struct WorkerStartupPreflightWarning {
|
||||
pub kind: WorkerStartupPreflightWarningKind,
|
||||
pub message: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub path: Option<String>,
|
||||
}
|
||||
|
||||
/// Classification of startup failure when no evidence is available.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
@@ -212,6 +229,12 @@ pub enum WorkerEventPayload {
|
||||
evidence: StartupEvidenceBundle,
|
||||
classification: StartupFailureClassification,
|
||||
},
|
||||
StartupPreflightWarning {
|
||||
kind: WorkerStartupPreflightWarningKind,
|
||||
message: String,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
path: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
|
||||
@@ -329,6 +352,34 @@ impl WorkerRegistry {
|
||||
inner.workers.get(worker_id).cloned()
|
||||
}
|
||||
|
||||
pub fn observe_startup_preflight(
|
||||
&self,
|
||||
worker_id: &str,
|
||||
task_prompt: &str,
|
||||
) -> Result<Worker, String> {
|
||||
let mut inner = self.inner.lock().expect("worker registry lock poisoned");
|
||||
let worker = inner
|
||||
.workers
|
||||
.get_mut(worker_id)
|
||||
.ok_or_else(|| format!("worker not found: {worker_id}"))?;
|
||||
|
||||
for warning in startup_preflight_warnings(Path::new(&worker.cwd), task_prompt) {
|
||||
push_event(
|
||||
worker,
|
||||
WorkerEventKind::StartupPreflightWarning,
|
||||
worker.status,
|
||||
Some(warning.message.clone()),
|
||||
Some(WorkerEventPayload::StartupPreflightWarning {
|
||||
kind: warning.kind,
|
||||
message: warning.message,
|
||||
path: warning.path,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
Ok(worker.clone())
|
||||
}
|
||||
|
||||
pub fn observe(&self, worker_id: &str, screen_text: &str) -> Result<Worker, String> {
|
||||
let mut inner = self.inner.lock().expect("worker registry lock poisoned");
|
||||
let worker = inner
|
||||
@@ -1064,6 +1115,118 @@ fn extract_server_from_qualified_tool(tool: &str) -> Option<String> {
|
||||
(!server.is_empty()).then(|| server.to_string())
|
||||
}
|
||||
|
||||
pub fn startup_preflight_warnings(
|
||||
cwd: &Path,
|
||||
task_prompt: &str,
|
||||
) -> Vec<WorkerStartupPreflightWarning> {
|
||||
let mut warnings = Vec::new();
|
||||
|
||||
if let Some(git_path) = git_metadata_path(cwd) {
|
||||
if !path_is_writable(&git_path) {
|
||||
warnings.push(WorkerStartupPreflightWarning {
|
||||
kind: WorkerStartupPreflightWarningKind::GitMetadataNotWritable,
|
||||
message: format!(
|
||||
"git metadata is not writable; commits or pushes may fail: {}",
|
||||
git_path.display()
|
||||
),
|
||||
path: Some(git_path.display().to_string()),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
for path in mentioned_repo_paths(task_prompt) {
|
||||
if !git_tracks_path(cwd, &path) {
|
||||
warnings.push(WorkerStartupPreflightWarning {
|
||||
kind: WorkerStartupPreflightWarningKind::FileAbsentOnBranch,
|
||||
message: format!(
|
||||
"task mentions {path}, but git does not track it on the current branch"
|
||||
),
|
||||
path: Some(path),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
warnings
|
||||
}
|
||||
|
||||
fn mentioned_repo_paths(task_prompt: &str) -> Vec<String> {
|
||||
let mut out = Vec::new();
|
||||
for raw in task_prompt.split_whitespace() {
|
||||
let token = raw.trim_matches(|ch: char| {
|
||||
matches!(
|
||||
ch,
|
||||
'`' | '"' | '\'' | '(' | ')' | '[' | ']' | '{' | '}' | ',' | ';' | ':'
|
||||
)
|
||||
});
|
||||
if !token.contains('/') || token.contains("://") || token.starts_with('/') {
|
||||
continue;
|
||||
}
|
||||
let token = token.trim_start_matches("./");
|
||||
if token.contains("..") {
|
||||
continue;
|
||||
}
|
||||
if token
|
||||
.chars()
|
||||
.all(|ch| ch.is_ascii_alphanumeric() || matches!(ch, '/' | '_' | '-' | '.'))
|
||||
&& token
|
||||
.rsplit('/')
|
||||
.next()
|
||||
.is_some_and(|name| name.contains('.'))
|
||||
&& !out.iter().any(|seen| seen == token)
|
||||
{
|
||||
out.push(token.to_string());
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
fn git_tracks_path(cwd: &Path, path: &str) -> bool {
|
||||
Command::new("git")
|
||||
.arg("ls-files")
|
||||
.arg("--error-unmatch")
|
||||
.arg("--")
|
||||
.arg(path)
|
||||
.current_dir(cwd)
|
||||
.output()
|
||||
.is_ok_and(|output| output.status.success())
|
||||
}
|
||||
|
||||
fn git_metadata_path(cwd: &Path) -> Option<PathBuf> {
|
||||
let output = Command::new("git")
|
||||
.args(["rev-parse", "--git-path", "."])
|
||||
.current_dir(cwd)
|
||||
.output()
|
||||
.ok()?;
|
||||
if !output.status.success() {
|
||||
return None;
|
||||
}
|
||||
let text = String::from_utf8_lossy(&output.stdout).trim().to_string();
|
||||
if text.is_empty() {
|
||||
return None;
|
||||
}
|
||||
let path = PathBuf::from(text);
|
||||
Some(if path.is_absolute() {
|
||||
path
|
||||
} else {
|
||||
cwd.join(path)
|
||||
})
|
||||
}
|
||||
|
||||
fn path_is_writable(path: &Path) -> bool {
|
||||
let probe_dir = if path.is_dir() {
|
||||
path.to_path_buf()
|
||||
} else {
|
||||
path.parent().unwrap_or(path).to_path_buf()
|
||||
};
|
||||
let probe = probe_dir.join(format!(".claw-write-probe-{}", now_secs()));
|
||||
std::fs::OpenOptions::new()
|
||||
.write(true)
|
||||
.create_new(true)
|
||||
.open(&probe)
|
||||
.and_then(|_| std::fs::remove_file(&probe))
|
||||
.is_ok()
|
||||
}
|
||||
|
||||
fn detect_trust_prompt(lowered: &str) -> bool {
|
||||
[
|
||||
"do you trust the files in this folder",
|
||||
@@ -1285,6 +1448,8 @@ fn cwd_matches_observed_target(expected_cwd: &str, observed_cwd: &str) -> bool {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::fs;
|
||||
use std::process::Command;
|
||||
|
||||
#[test]
|
||||
fn allowlisted_trust_prompt_auto_resolves_then_reaches_ready_state() {
|
||||
@@ -1431,6 +1596,66 @@ mod tests {
|
||||
assert!(!readiness.ready);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn startup_preflight_warns_when_task_file_is_absent_on_branch() {
|
||||
let tmp = tempfile::tempdir().expect("tempdir");
|
||||
Command::new("git")
|
||||
.arg("init")
|
||||
.current_dir(tmp.path())
|
||||
.output()
|
||||
.expect("git init should run");
|
||||
fs::create_dir_all(tmp.path().join("src")).expect("src dir");
|
||||
fs::write(tmp.path().join("src/lib.rs"), "pub fn present() {}\n").expect("write file");
|
||||
Command::new("git")
|
||||
.args(["add", "src/lib.rs"])
|
||||
.current_dir(tmp.path())
|
||||
.output()
|
||||
.expect("git add should run");
|
||||
|
||||
let warnings = startup_preflight_warnings(
|
||||
tmp.path(),
|
||||
"Fix src/lib.rs and rust/crates/runtime/src/trident.rs before testing.",
|
||||
);
|
||||
|
||||
assert!(warnings.iter().any(|warning| {
|
||||
warning.kind == WorkerStartupPreflightWarningKind::FileAbsentOnBranch
|
||||
&& warning.path.as_deref() == Some("rust/crates/runtime/src/trident.rs")
|
||||
}));
|
||||
assert!(!warnings.iter().any(|warning| {
|
||||
warning.kind == WorkerStartupPreflightWarningKind::FileAbsentOnBranch
|
||||
&& warning.path.as_deref() == Some("src/lib.rs")
|
||||
}));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn startup_preflight_records_structured_warning_event() {
|
||||
let tmp = tempfile::tempdir().expect("tempdir");
|
||||
Command::new("git")
|
||||
.arg("init")
|
||||
.current_dir(tmp.path())
|
||||
.output()
|
||||
.expect("git init should run");
|
||||
let registry = WorkerRegistry::new();
|
||||
let worker = registry.create(&tmp.path().display().to_string(), &[], true);
|
||||
|
||||
let observed = registry
|
||||
.observe_startup_preflight(&worker.worker_id, "Open missing/file.rs")
|
||||
.expect("preflight should run");
|
||||
|
||||
let event = observed
|
||||
.events
|
||||
.iter()
|
||||
.find(|event| event.kind == WorkerEventKind::StartupPreflightWarning)
|
||||
.expect("preflight warning event");
|
||||
assert!(matches!(
|
||||
event.payload,
|
||||
Some(WorkerEventPayload::StartupPreflightWarning {
|
||||
kind: WorkerStartupPreflightWarningKind::FileAbsentOnBranch,
|
||||
..
|
||||
})
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn startup_timeout_classifies_tool_permission_prompt() {
|
||||
let registry = WorkerRegistry::new();
|
||||
|
||||
@@ -292,6 +292,12 @@ fn classify_error_kind(message: &str) -> &'static str {
|
||||
"malformed_mcp_config"
|
||||
} else if message.starts_with("empty prompt") {
|
||||
"empty_prompt"
|
||||
} else if message.starts_with("interactive_only:") || message.contains("stdin is not a TTY") {
|
||||
"interactive_only"
|
||||
} else if message.starts_with("unknown agents subcommand:") {
|
||||
"unknown_agents_subcommand"
|
||||
} else if message.contains("is not installed") {
|
||||
"plugin_not_found"
|
||||
} else {
|
||||
"unknown"
|
||||
}
|
||||
@@ -940,6 +946,12 @@ fn parse_args(args: &[String]) -> Result<CliAction, String> {
|
||||
allow_broad_cwd,
|
||||
});
|
||||
}
|
||||
// Non-TTY stdin with no piped content: refuse to start the interactive
|
||||
// REPL (it would block forever waiting for input that will never arrive).
|
||||
// (#696: emit a typed error instead of hanging indefinitely)
|
||||
// Skip this guard in test builds (parse_args tests run in non-TTY context).
|
||||
#[cfg(not(test))]
|
||||
return Err("interactive_only: claw requires an interactive terminal (stdin is not a TTY and no prompt was provided — pipe a prompt or run in a TTY)".into());
|
||||
}
|
||||
return Ok(CliAction::Repl {
|
||||
model,
|
||||
@@ -2579,7 +2591,12 @@ fn check_boot_preflight_health(context: &StatusContext) -> DiagnosticCheck {
|
||||
format!("Worktree exists {}", preflight.worktree_exists),
|
||||
format!("Git dir exists {}", preflight.git_dir_exists),
|
||||
format!("Branch behind {}", preflight.branch_freshness.behind),
|
||||
format!("Trust allowlist {:?}", preflight.trust_gate_allowed),
|
||||
format!(
|
||||
"Trust allowlist {}",
|
||||
preflight
|
||||
.trust_gate_allowed
|
||||
.map_or("unknown".to_string(), |v| v.to_string())
|
||||
),
|
||||
format!("Trusted roots {}", preflight.trusted_roots_count),
|
||||
format!(
|
||||
"MCP eligible {} · servers {}",
|
||||
@@ -2867,6 +2884,7 @@ fn print_system_prompt(
|
||||
"{}",
|
||||
serde_json::to_string_pretty(&json!({
|
||||
"kind": "system-prompt",
|
||||
"status": "ok",
|
||||
"message": message,
|
||||
"sections": sections,
|
||||
}))?
|
||||
@@ -2889,6 +2907,7 @@ fn version_json_value() -> serde_json::Value {
|
||||
let executable_path = env::current_exe().ok().map(|p| p.display().to_string());
|
||||
json!({
|
||||
"kind": "version",
|
||||
"status": "ok",
|
||||
"message": render_version_report(),
|
||||
"version": VERSION,
|
||||
"git_sha": GIT_SHA,
|
||||
@@ -6959,8 +6978,23 @@ fn print_sandbox_status_snapshot(
|
||||
}
|
||||
|
||||
fn sandbox_json_value(status: &runtime::SandboxStatus) -> serde_json::Value {
|
||||
// Derive top-level status so automation can do a single field check
|
||||
// instead of combining enabled/active/supported booleans.
|
||||
// ok = not enabled (not requested), OR enabled and active
|
||||
// warn = enabled and supported but not yet active (degraded)
|
||||
// error = enabled but unsupported on this platform
|
||||
let top_status = if !status.enabled {
|
||||
"ok"
|
||||
} else if status.active {
|
||||
"ok"
|
||||
} else if status.supported {
|
||||
"warn"
|
||||
} else {
|
||||
"error"
|
||||
};
|
||||
json!({
|
||||
"kind": "sandbox",
|
||||
"status": top_status,
|
||||
"enabled": status.enabled,
|
||||
"active": status.active,
|
||||
"supported": status.supported,
|
||||
@@ -7451,8 +7485,12 @@ fn run_init(output_format: CliOutputFormat) -> Result<(), Box<dyn std::error::Er
|
||||
/// string so claws can detect per-artifact state without substring matching.
|
||||
fn init_json_value(report: &crate::init::InitReport, message: &str) -> serde_json::Value {
|
||||
use crate::init::InitStatus;
|
||||
// Derive top-level status: "ok" when all artifacts succeeded (created or
|
||||
// skipped = idempotent); no failure path exists today so always "ok".
|
||||
let status = "ok";
|
||||
json!({
|
||||
"kind": "init",
|
||||
"status": status,
|
||||
"project_path": report.project_root.display().to_string(),
|
||||
"created": report.artifacts_with_status(InitStatus::Created),
|
||||
"updated": report.artifacts_with_status(InitStatus::Updated),
|
||||
|
||||
Reference in New Issue
Block a user