Research CLI: alias --status complete to the stored done value (#2515)
`odysseus-research list --status complete` returns an empty result on
any real corpus. The CLI accepts `complete` as a `--status` choice (the
user-facing label), but the writer in
`services/research/research_handler.py` stores `status="done"` when a
run finishes (and the legacy `src/research_handler.py` copy does the
same). The list filter at `scripts/odysseus-research` was a literal
string compare:
if args.status and (data.get("status") or "") != args.status:
continue
so `--status complete` filtered every finished record out, and the user
saw nothing — even though `odysseus-research list` (no filter) listed
them fine and `show RP_ID` worked on the same files. The other
documented choices — `running`, `cancelled`, `error` — are stored
verbatim by the writer, so the surface mismatch is just on `complete`.
Add a small `_STATUS_CLI_TO_STORED = {"complete": "done"}` map and run
`data.get("status")` through `_status_matches(...)` before comparing.
The other CLI choices fall through unchanged, so the filter still
matches them verbatim. A `None` or non-string `status` (corrupt JSON)
is coerced to `""` and never matches `complete`, so a half-written
record can't sneak past the filter.
`tests/test_research_cli_status_filter.py` covers all four documented
choices, the non-string / missing status case, and pins that the
verbatim choices are NOT rewritten — a blanket mapping that turned
every CLI choice into a stored variant would just re-introduce the
empty-result bug on the running/cancelled/error paths.
Part of #2122.
This commit is contained in:
@@ -25,6 +25,24 @@ from pathlib import Path
|
||||
|
||||
_DATA_DIR = _REPO_ROOT / "data" / "deep_research"
|
||||
|
||||
# The CLI's --status takes the user-facing label "complete", but the writer
|
||||
# in services/research/research_handler.py stores `status="done"` when a run
|
||||
# finishes (and the legacy src/research_handler.py does the same). Without
|
||||
# this alias, --status complete filters every finished record out and the
|
||||
# user sees an empty list. Map at filter time so the on-disk corpus is the
|
||||
# source of truth and the CLI surface stays the friendlier word. The other
|
||||
# choices ("running", "cancelled", "error") are stored verbatim, so they
|
||||
# fall through unchanged.
|
||||
_STATUS_CLI_TO_STORED = {"complete": "done"}
|
||||
|
||||
|
||||
def _status_matches(stored, requested: str) -> bool:
|
||||
stored = (stored or "")
|
||||
if not isinstance(stored, str):
|
||||
stored = ""
|
||||
target = _STATUS_CLI_TO_STORED.get(requested, requested)
|
||||
return stored == target
|
||||
|
||||
|
||||
def _load_path(path: Path) -> dict | None:
|
||||
try:
|
||||
@@ -72,7 +90,7 @@ def cmd_list(args):
|
||||
data = _load_path(path)
|
||||
if data is None:
|
||||
continue
|
||||
if args.status and (data.get("status") or "") != args.status:
|
||||
if args.status and not _status_matches(data.get("status"), args.status):
|
||||
continue
|
||||
out.append(_summarize(rp_id, data))
|
||||
out.sort(key=lambda r: r.get("started_at") or "", reverse=True)
|
||||
|
||||
Reference in New Issue
Block a user