fix(#802): four resume-mode and broad-cwd error envelopes now include hint field

This commit is contained in:
YeonGyu-Kim 2026-05-27 19:04:15 +09:00
parent 53953a8157
commit fcebf64468
2 changed files with 6 additions and 0 deletions

View File

@ -7768,3 +7768,5 @@ Original filing (2026-04-18): the session emitted `SessionStart hook (completed)
800. **`classify_error_kind` unit test coverage gap: `invalid_history_count` and `unknown_option` arms had zero assertions** — found 2026-05-27 on `efb1542a`. Audit of 39 distinct classifier return values vs 37 unit test assertions revealed 2 untested arms. Fix: added 3 `assert_eq!` covering both arms (invalid_history_count prefix + contains paths, unknown_option prefix). Committed as `6ee67d6c`. All 39 return values now have unit test coverage. [SCOPE: claw-code] 800. **`classify_error_kind` unit test coverage gap: `invalid_history_count` and `unknown_option` arms had zero assertions** — found 2026-05-27 on `efb1542a`. Audit of 39 distinct classifier return values vs 37 unit test assertions revealed 2 untested arms. Fix: added 3 `assert_eq!` covering both arms (invalid_history_count prefix + contains paths, unknown_option prefix). Committed as `6ee67d6c`. All 39 return values now have unit test coverage. [SCOPE: claw-code]
801. **`claw --output-format json diff` in a non-git directory was missing `error_kind`, `hint`, and `message` fields** — dogfooded 2026-05-27 on `1201dc60`. The diff handler's no-git-repo JSON branch constructed a custom object with only `status:"error"` + `result:"no_git_repo"` + `detail`, violating the error envelope contract that every error has `error_kind` + `hint`. Fix: added `error_kind: "no_git_repo"`, `hint: "Run git init..."`, and `message` fields. Integration test `diff_non_git_dir_has_error_kind_and_hint_801`. 62 CLI contract tests pass. [SCOPE: claw-code] Source: Jobdori non-git-dir probe on `1201dc60`, 2026-05-27. 801. **`claw --output-format json diff` in a non-git directory was missing `error_kind`, `hint`, and `message` fields** — dogfooded 2026-05-27 on `1201dc60`. The diff handler's no-git-repo JSON branch constructed a custom object with only `status:"error"` + `result:"no_git_repo"` + `detail`, violating the error envelope contract that every error has `error_kind` + `hint`. Fix: added `error_kind: "no_git_repo"`, `hint: "Run git init..."`, and `message` fields. Integration test `diff_non_git_dir_has_error_kind_and_hint_801`. 62 CLI contract tests pass. [SCOPE: claw-code] Source: Jobdori non-git-dir probe on `1201dc60`, 2026-05-27.
802. **Four `status:"error"` JSON sites in resume-mode and broad-cwd handlers were missing `hint` field** — found 2026-05-27 on `53953a81` via source audit of all `"status": "error"` sites in main.rs. The resume `unsupported_command` (L3433), `unsupported_resumed_command` (L3455), `cli_parse` (L3474), and `broad_cwd` (L4838) handlers all emitted JSON error envelopes with `error_kind` but no `hint` field. Fix: added contextual `hint` string to all four sites. Source audit now shows 0 `status:"error"` JSON objects missing `hint` across entire main.rs. 62 CLI contract tests pass. [SCOPE: claw-code] Source: Jobdori source-level audit of all error JSON sites, 2026-05-27.

View File

@ -3433,6 +3433,7 @@ fn resume_session(session_path: &Path, commands: &[String], output_format: CliOu
"status": "error", "status": "error",
"error_kind": "unsupported_command", "error_kind": "unsupported_command",
"error": format!("/{cmd_root} is not yet implemented in this build"), "error": format!("/{cmd_root} is not yet implemented in this build"),
"hint": "This command is not available in the current build. Update claw or use a different command.",
"exit_code": 2, "exit_code": 2,
"command": raw_command, "command": raw_command,
}) })
@ -3455,6 +3456,7 @@ fn resume_session(session_path: &Path, commands: &[String], output_format: CliOu
"status": "error", "status": "error",
"error_kind": "unsupported_resumed_command", "error_kind": "unsupported_resumed_command",
"error": format!("unsupported resumed command: {raw_command}"), "error": format!("unsupported resumed command: {raw_command}"),
"hint": "This command cannot be used with --resume. Use it in an interactive REPL session instead.",
"exit_code": 2, "exit_code": 2,
"command": raw_command, "command": raw_command,
}) })
@ -3474,6 +3476,7 @@ fn resume_session(session_path: &Path, commands: &[String], output_format: CliOu
"status": "error", "status": "error",
"error_kind": "cli_parse", "error_kind": "cli_parse",
"error": error.to_string(), "error": error.to_string(),
"hint": "Run `claw --help` for usage.",
"exit_code": 2, "exit_code": 2,
"command": raw_command, "command": raw_command,
}) })
@ -4838,6 +4841,7 @@ fn enforce_broad_cwd_policy(
"status": "error", "status": "error",
"error_kind": "broad_cwd", "error_kind": "broad_cwd",
"error": message, "error": message,
"hint": "Change to a more specific project directory, or use --cwd to set the workspace root.",
"exit_code": 1, "exit_code": 1,
}) })
); );