mirror of
https://github.com/instructkr/claude-code.git
synced 2026-05-14 01:46:44 +00:00
Compare commits
1 Commits
fix/resume
...
docs/roadm
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6427303786 |
@@ -6301,4 +6301,4 @@ Original filing (2026-04-18): the session emitted `SessionStart hook (completed)
|
|||||||
380. **Top-level `tokens --help --output-format json` hangs with zero stdout/stderr instead of returning bounded command help JSON** — dogfooded 2026-04-30 for the 02:30 nudge on current `origin/main` / rebuilt `./rust/target/debug/claw` with embedded `git_sha` `d95b230c`. After verifying #358 covered `cost --help`, a fresh adjacent probe on the token-budget surface showed the same silent failure class: repeated bounded runs of `timeout 8 ./rust/target/debug/claw tokens --help --output-format json` exited `124` with `stdout=0` and `stderr=0`. In the same rebuilt binary, `version --output-format json` returned promptly with version/build metadata, proving the binary itself and JSON output path are reachable. This is distinct from #358's cost help hang: the affected surface is the sibling `tokens` command help, which agents use before estimating prompt/session token budgets. **Required fix shape:** (a) make `tokens --help --output-format json` return static/bounded stdout JSON with `kind:"help"` or `kind:"tokens"`, `action:"help"`, usage, options, examples, supported output formats, and related slash/direct commands; (b) ensure help rendering does not initialize slow token accounting, session, or provider state; (c) if any dynamic provider is consulted, return a typed JSON timeout/unavailable error instead of hanging; (d) add regression coverage proving tokens help in JSON mode returns within a deterministic budget. **Why this matters:** token budgeting is a preflight clawability surface. If help hangs silently, automation cannot safely discover how to inspect or constrain token usage before running expensive prompts, and budget-aware wrappers stall at the discovery step. Source: gaebal-gajae dogfood follow-up for the 02:30 nudge on rebuilt `./rust/target/debug/claw` `d95b230c`.
|
380. **Top-level `tokens --help --output-format json` hangs with zero stdout/stderr instead of returning bounded command help JSON** — dogfooded 2026-04-30 for the 02:30 nudge on current `origin/main` / rebuilt `./rust/target/debug/claw` with embedded `git_sha` `d95b230c`. After verifying #358 covered `cost --help`, a fresh adjacent probe on the token-budget surface showed the same silent failure class: repeated bounded runs of `timeout 8 ./rust/target/debug/claw tokens --help --output-format json` exited `124` with `stdout=0` and `stderr=0`. In the same rebuilt binary, `version --output-format json` returned promptly with version/build metadata, proving the binary itself and JSON output path are reachable. This is distinct from #358's cost help hang: the affected surface is the sibling `tokens` command help, which agents use before estimating prompt/session token budgets. **Required fix shape:** (a) make `tokens --help --output-format json` return static/bounded stdout JSON with `kind:"help"` or `kind:"tokens"`, `action:"help"`, usage, options, examples, supported output formats, and related slash/direct commands; (b) ensure help rendering does not initialize slow token accounting, session, or provider state; (c) if any dynamic provider is consulted, return a typed JSON timeout/unavailable error instead of hanging; (d) add regression coverage proving tokens help in JSON mode returns within a deterministic budget. **Why this matters:** token budgeting is a preflight clawability surface. If help hangs silently, automation cannot safely discover how to inspect or constrain token usage before running expensive prompts, and budget-aware wrappers stall at the discovery step. Source: gaebal-gajae dogfood follow-up for the 02:30 nudge on rebuilt `./rust/target/debug/claw` `d95b230c`.
|
||||||
381. **Top-level `cache --help --output-format json` hangs with zero stdout/stderr instead of returning bounded command help JSON** — dogfooded 2026-04-30 for the 03:00 nudge on current `origin/main` / rebuilt `./rust/target/debug/claw` with embedded `git_sha` `d95b230c`. After #358 and #380 landed for the cost/tokens preflight help hangs, a fresh adjacent probe on the cache-control surface showed the same silent failure class: repeated bounded runs of `timeout --kill-after=1s 8s ./rust/target/debug/claw cache --help --output-format json` exited `124` with `stdout=0` and `stderr=0`. In the same rebuilt binary, `version --output-format json` returned promptly with version/build metadata, proving the binary itself and JSON output path are reachable. This is distinct from the separate `/cache` slash-command envelope mismatch class: the affected surface here is top-level `cache` command help, where agents need bounded local discovery before deciding whether to inspect, clear, or summarize cache state. **Required fix shape:** (a) make `cache --help --output-format json` return static/bounded stdout JSON with `kind:"help"` or `kind:"cache"`, `action:"help"`, usage, options, examples, supported output formats, and related slash/direct commands; (b) ensure help rendering does not initialize slow cache/session/provider state; (c) if any dynamic provider is consulted, return a typed JSON timeout/unavailable error instead of hanging; (d) add regression coverage proving cache help in JSON mode returns within a deterministic budget. **Why this matters:** cache inspection and cleanup are recovery/control-plane operations. If cache help hangs silently, claws cannot safely discover cache semantics before attempting cleanup, and automation stalls before it can choose a non-destructive cache action. Source: gaebal-gajae dogfood follow-up for the 03:00 nudge on rebuilt `./rust/target/debug/claw` `d95b230c`.
|
381. **Top-level `cache --help --output-format json` hangs with zero stdout/stderr instead of returning bounded command help JSON** — dogfooded 2026-04-30 for the 03:00 nudge on current `origin/main` / rebuilt `./rust/target/debug/claw` with embedded `git_sha` `d95b230c`. After #358 and #380 landed for the cost/tokens preflight help hangs, a fresh adjacent probe on the cache-control surface showed the same silent failure class: repeated bounded runs of `timeout --kill-after=1s 8s ./rust/target/debug/claw cache --help --output-format json` exited `124` with `stdout=0` and `stderr=0`. In the same rebuilt binary, `version --output-format json` returned promptly with version/build metadata, proving the binary itself and JSON output path are reachable. This is distinct from the separate `/cache` slash-command envelope mismatch class: the affected surface here is top-level `cache` command help, where agents need bounded local discovery before deciding whether to inspect, clear, or summarize cache state. **Required fix shape:** (a) make `cache --help --output-format json` return static/bounded stdout JSON with `kind:"help"` or `kind:"cache"`, `action:"help"`, usage, options, examples, supported output formats, and related slash/direct commands; (b) ensure help rendering does not initialize slow cache/session/provider state; (c) if any dynamic provider is consulted, return a typed JSON timeout/unavailable error instead of hanging; (d) add regression coverage proving cache help in JSON mode returns within a deterministic budget. **Why this matters:** cache inspection and cleanup are recovery/control-plane operations. If cache help hangs silently, claws cannot safely discover cache semantics before attempting cleanup, and automation stalls before it can choose a non-destructive cache action. Source: gaebal-gajae dogfood follow-up for the 03:00 nudge on rebuilt `./rust/target/debug/claw` `d95b230c`.
|
||||||
|
|
||||||
422. **`export --output-format json` and `--resume latest` report the same "no managed sessions" scenario using two different `kind` codes — `no_managed_sessions` vs `session_load_failed` — making "no session found" undetectable by a single kind-code check** — dogfooded 2026-04-30 KST (UTC+9) by Jobdori on `e939777f`. Running `claw export --output-format json` with no session present returns (on stderr, exit 1): `{"error":"no managed sessions found in .claw/sessions/<fingerprint>/","hint":"Start \`claw\` to create a session, then rerun with \`--resume latest\`.\nNote: claw partitions sessions per workspace fingerprint; sessions from other CWDs are invisible.","kind":"no_managed_sessions","type":"error"}`. Running `claw --resume latest /status --output-format json` with no session present returns (on stderr, exit 1): `{"error":"failed to restore session: no managed sessions found in .claw/sessions/<fingerprint>/","hint":"Start \`claw\` to create a session, then rerun with \`--resume latest\`.\nNote: claw partitions sessions per workspace fingerprint; sessions from other CWDs are invisible.","kind":"session_load_failed","type":"error"}`. Both describe the same root condition — there are no sessions to operate on — but they expose it via different `kind` discriminants. Automation that checks `kind == "no_managed_sessions"` to detect a cold workspace will miss the `--resume` path's `session_load_failed`, and vice versa. A wrapper that guards "run with --resume only if a session exists" must special-case both codes. The hint text is identical between them, suggesting the messages are logically equivalent. Additionally neither code matches the proposed canonical names `session_not_found` / `session_load_failed` as stable `ErrorKind` discriminants described in ROADMAP #77's fix shape, which explicitly proposes typed error-kind codes for session lifecycle failures. **Required fix shape:** (a) unify "no sessions found for this workspace fingerprint" under a single canonical `kind` code — either `no_managed_sessions` or `session_not_found` — used consistently by every command path that encounters an empty session registry; (b) if `session_load_failed` is a more general category (covering e.g. corrupt session files, IO errors, schema version mismatches), it should nest a concrete `reason:"no_managed_sessions"` or `reason:"session_not_found"` sub-field so callers can distinguish "empty registry" from "found but unreadable"; (c) align with the canonical error-kind contract proposed in #77; (d) add regression coverage proving `export` and `--resume latest` in an empty workspace both return an error with the same top-level `kind` code. **Why this matters:** session guard-rails in orchestration need a single stable `kind` to detect cold workspaces without enumerating all possible no-session synonyms. Two divergent codes for the same condition make defensive automation brittle and contradict the promise of machine-readable error envelopes. Source: Jobdori live dogfood, `e939777f`, 2026-04-30 KST (UTC+9).
|
412. **`bootstrap-plan --output-format json` returns `phases: string[]` of raw Rust enum variant names with no description, steps, duration, or dependency metadata — unusable by automation** — dogfooded 2026-04-30 by Jobdori on `e939777f`. Running `claw bootstrap-plan --output-format json` returns `{"kind":"bootstrap-plan","phases":["CliEntry","FastPathVersion","StartupProfiler","SystemPromptFastPath","ChromeMcpFastPath","DaemonWorkerFastPath","BridgeFastPath","DaemonFastPath","BackgroundSessionFastPath","TemplateFastPath","EnvironmentRunnerFastPath","MainRuntime"]}`. The envelope has only two keys: `kind` and `phases`. The `phases` array contains 12 raw Rust enum variant name strings — opaque identifiers with no `description`, no `label`, no `steps[]`, no `estimated_ms`, no `dependencies[]`, no `optional:bool`, and no `status` (enabled/disabled/skipped). Automation that calls `bootstrap-plan` to understand startup costs or profile initialization paths receives 12 name strings that reveal nothing about what each phase does, how long it takes, whether it depends on credentials/network/MCP, or which ones can be skipped. **Required fix shape:** (a) replace `phases: string[]` with `phases: [{id, label, description, optional, estimated_ms?, dependencies?, status?}]`; (b) add a top-level `total_phases` count; (c) mark network/credential-dependent phases with a `requires_auth:bool` or `deps:["network","credentials","mcp"]` field so automation can plan for unavailability; (d) add regression coverage proving each phase entry has at least `id`, `label`, and `description` fields and that the count matches the phases array length. **Why this matters:** bootstrap-plan is the startup-cost introspection surface. If its JSON output is 12 opaque variant name strings, automation cannot profile startup, identify slow phases, skip optional phases, or present meaningful startup diagnostics — the entire command serves only as a list of internal identifiers. Source: Jobdori live dogfood, `e939777f`, 2026-04-30.
|
||||||
|
|||||||
@@ -2627,15 +2627,12 @@ fn print_version(output_format: CliOutputFormat) -> Result<(), Box<dyn std::erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn version_json_value() -> serde_json::Value {
|
fn version_json_value() -> serde_json::Value {
|
||||||
let executable_path = env::current_exe().ok().map(|p| p.display().to_string());
|
|
||||||
json!({
|
json!({
|
||||||
"kind": "version",
|
"kind": "version",
|
||||||
"message": render_version_report(),
|
"message": render_version_report(),
|
||||||
"version": VERSION,
|
"version": VERSION,
|
||||||
"git_sha": GIT_SHA,
|
"git_sha": GIT_SHA,
|
||||||
"target": BUILD_TARGET,
|
"target": BUILD_TARGET,
|
||||||
"build_date": DEFAULT_DATE,
|
|
||||||
"executable_path": executable_path,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3526,10 +3523,10 @@ fn run_resume_command(
|
|||||||
Ok(ResumeCommandOutcome {
|
Ok(ResumeCommandOutcome {
|
||||||
session: session.clone(),
|
session: session.clone(),
|
||||||
message: Some(handle_agents_slash_command(args.as_deref(), &cwd)?),
|
message: Some(handle_agents_slash_command(args.as_deref(), &cwd)?),
|
||||||
json: Some(
|
json: Some(serde_json::json!({
|
||||||
serde_json::to_value(handle_agents_slash_command_json(args.as_deref(), &cwd)?)
|
"kind": "agents",
|
||||||
.unwrap_or_else(|_| serde_json::json!(null)),
|
"text": handle_agents_slash_command(args.as_deref(), &cwd)?,
|
||||||
),
|
})),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
SlashCommand::Skills { args } => {
|
SlashCommand::Skills { args } => {
|
||||||
|
|||||||
@@ -30,15 +30,6 @@ fn version_emits_json_when_requested() {
|
|||||||
let parsed = assert_json_command(&root, &["--output-format", "json", "version"]);
|
let parsed = assert_json_command(&root, &["--output-format", "json", "version"]);
|
||||||
assert_eq!(parsed["kind"], "version");
|
assert_eq!(parsed["kind"], "version");
|
||||||
assert_eq!(parsed["version"], env!("CARGO_PKG_VERSION"));
|
assert_eq!(parsed["version"], env!("CARGO_PKG_VERSION"));
|
||||||
// Provenance fields must be present for binary identification (#507).
|
|
||||||
assert!(
|
|
||||||
parsed["build_date"].is_string(),
|
|
||||||
"build_date must be a string in version JSON"
|
|
||||||
);
|
|
||||||
assert!(
|
|
||||||
parsed["executable_path"].is_string(),
|
|
||||||
"executable_path must be a string in version JSON so callers can identify which binary is running"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -114,18 +105,6 @@ fn inventory_commands_emit_structured_json_when_requested() {
|
|||||||
let skills = assert_json_command(&root, &["--output-format", "json", "skills"]);
|
let skills = assert_json_command(&root, &["--output-format", "json", "skills"]);
|
||||||
assert_eq!(skills["kind"], "skills");
|
assert_eq!(skills["kind"], "skills");
|
||||||
assert_eq!(skills["action"], "list");
|
assert_eq!(skills["action"], "list");
|
||||||
|
|
||||||
let plugins = assert_json_command(&root, &["--output-format", "json", "plugins"]);
|
|
||||||
assert_eq!(plugins["kind"], "plugin");
|
|
||||||
assert_eq!(plugins["action"], "list");
|
|
||||||
assert!(
|
|
||||||
plugins["reload_runtime"].is_boolean(),
|
|
||||||
"plugins reload_runtime should be a boolean"
|
|
||||||
);
|
|
||||||
assert!(
|
|
||||||
plugins["target"].is_null(),
|
|
||||||
"plugins target should be null when no plugin is targeted"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -369,34 +348,6 @@ fn resumed_inventory_commands_emit_structured_json_when_requested() {
|
|||||||
assert_eq!(skills["action"], "list");
|
assert_eq!(skills["action"], "list");
|
||||||
assert!(skills["summary"]["total"].is_number());
|
assert!(skills["summary"]["total"].is_number());
|
||||||
assert!(skills["skills"].is_array());
|
assert!(skills["skills"].is_array());
|
||||||
|
|
||||||
let agents = assert_json_command_with_env(
|
|
||||||
&root,
|
|
||||||
&[
|
|
||||||
"--output-format",
|
|
||||||
"json",
|
|
||||||
"--resume",
|
|
||||||
session_path.to_str().expect("utf8 session path"),
|
|
||||||
"/agents",
|
|
||||||
],
|
|
||||||
&[
|
|
||||||
(
|
|
||||||
"CLAW_CONFIG_HOME",
|
|
||||||
config_home.to_str().expect("utf8 config home"),
|
|
||||||
),
|
|
||||||
("HOME", home.to_str().expect("utf8 home")),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
assert_eq!(agents["kind"], "agents");
|
|
||||||
assert_eq!(agents["action"], "list");
|
|
||||||
assert!(
|
|
||||||
agents["agents"].is_array(),
|
|
||||||
"agents field must be a JSON array"
|
|
||||||
);
|
|
||||||
assert!(
|
|
||||||
agents["count"].is_number(),
|
|
||||||
"count must be a number, not a text render"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -227,8 +227,6 @@ fn resumed_status_command_emits_structured_json_when_requested() {
|
|||||||
// given
|
// given
|
||||||
let temp_dir = unique_temp_dir("resume-status-json");
|
let temp_dir = unique_temp_dir("resume-status-json");
|
||||||
fs::create_dir_all(&temp_dir).expect("temp dir should exist");
|
fs::create_dir_all(&temp_dir).expect("temp dir should exist");
|
||||||
let config_home = temp_dir.join("config-home");
|
|
||||||
fs::create_dir_all(&config_home).expect("isolated config home should exist");
|
|
||||||
let session_path = temp_dir.join("session.jsonl");
|
let session_path = temp_dir.join("session.jsonl");
|
||||||
|
|
||||||
let mut session = workspace_session(&temp_dir);
|
let mut session = workspace_session(&temp_dir);
|
||||||
@@ -240,9 +238,7 @@ fn resumed_status_command_emits_structured_json_when_requested() {
|
|||||||
.expect("session should persist");
|
.expect("session should persist");
|
||||||
|
|
||||||
// when
|
// when
|
||||||
// Use an isolated CLAW_CONFIG_HOME so ~/.claw/settings.json is not loaded,
|
let output = run_claw(
|
||||||
// which would cause loaded_config_files to be non-zero (#65).
|
|
||||||
let output = run_claw_with_env(
|
|
||||||
&temp_dir,
|
&temp_dir,
|
||||||
&[
|
&[
|
||||||
"--output-format",
|
"--output-format",
|
||||||
@@ -251,7 +247,6 @@ fn resumed_status_command_emits_structured_json_when_requested() {
|
|||||||
session_path.to_str().expect("utf8 path"),
|
session_path.to_str().expect("utf8 path"),
|
||||||
"/status",
|
"/status",
|
||||||
],
|
],
|
||||||
&[("CLAW_CONFIG_HOME", config_home.to_str().expect("utf8 path"))],
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
|
|||||||
Reference in New Issue
Block a user