Skip to content

fix: check provider HTTP status; drive-letter paths in git add jail - #124

Merged
ajianaz merged 1 commit into
developfrom
fix/provider-git-jails
Sep 22, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/provider-git-jails

Conversation

@ajianaz

@ajianaz ajianaz commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

What (description of the change)

  1. openai.rs complete() checks the HTTP status BEFORE parsing the body: a non-2xx response now surfaces as ProviderError("http status: <N> — <scrubbed body snippet>") instead of the body being mangled by read_json into a misleading malformed response error. The http status: phrasing is deliberately kept — the turn loop's transient-retry classification (feat: usage ledger wiring, 429 retry classification, no per-step transcript clone #66) matches on it, so 429/5xx keep auto-retrying.
  2. git.rs add jail rejects Windows drive-letter absolute paths (C:\evil, C:/evil): the second byte : check closes the gap where such paths passed both the /-prefix and .. separator checks (cora full-scan chore: add .cora.yaml review config and document cora workflow #30). A colon NOT at position 1 (weird:name.txt) remains legal.

Why (the problem you're solving)

Closes #119 (cora full-scan MAJORs #46 and #30). Wrong error surfaces cost real debugging time (a proxy HTML page reported as "malformed response" hides the actual 502), and the git lexical jail must be host-OS-honest for workspaces synced to/from Windows hosts.

Testing (how you verified this works)

  • add_jail_rejects_absolute_and_drive_letter_paths: all four absolute shapes refused (/etc/passwd, \Windows\evil, C:\Windows\evil, C:/Users/evil), relative paths pass, mid-name colon passes.
  • Full existing suites green (the retry-once classification tests still pass with the new error text); mobile (--no-default-features) green; clippy -D warnings clean.
  • Live corroboration from today's earlier session: the 502 mid-replay incident produced exactly the retryable classification this change preserves.

…119)

- openai complete(): a non-2xx response is now surfaced as
  'http status: N — <scrubbed body snippet>' instead of being mangled
  by read_json into a misleading 'malformed response'. The phrasing
  is load-bearing: the turn loop's transient-retry classification
  (#66) matches 'http status:' so 429/5xx keep auto-retrying.
- git add lexical jail: reject Windows drive-letter absolute paths
  (C:\..., C:/...) that slipped past the '/'/'\\' checks (cora
  full-scan #30); colon at position 1 only, 'weird:name.txt' stays
  legal. Unit tests cover all four absolute shapes + relative pass.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 59946b2 into develop Sep 22, 2026
16 checks passed
@ajianaz
ajianaz deleted the fix/provider-git-jails branch September 22, 2026 15:28
ajianaz added a commit that referenced this pull request Oct 28, 2026
Cora (alert #124): the index fallback resumed project A's session with
project B's cwd, workspace jail, config and trust, so its tools could
act on the wrong tree under an untrusted config. `tole resume <id>` for
a session of another project now refuses and prints the command to run
in that project (`cd <project> && tole resume <id>`, plus
--sessions-dir when it is not the default), so that project's own
config and trust gate apply.
ajianaz added a commit that referenced this pull request Oct 28, 2026
… dir (#454)

## What

A global session index so sessions can be found and resumed across
projects: `tole sessions --all [--grep <text>]`, and `tole resume <id>`
naming the project a session belongs to.

Closes #439.

## Why

Sessions live per cwd (`.tole/sessions/`); on a multi-project machine
there was no way to find which project a session was in, and resuming
required remembering the cwd.

## Changes

- `tole-cli/src/session_index.rs` (new):
`$CODECORA_HOME/tole/sessions-index.jsonl` (next to the trust store,
rather than XDG, so all tole state shares one root). One line per
session START — id, absolute session file, cwd, face, start time —
written in one append-mode `write`, owner-only (0600); the last line per
id wins, malformed/torn lines are skipped. **No prompt text in the
index:** preview, status and turn count are read from the session file
when listing. Recording is best effort (never fails a session);
`TOLE_NO_SESSION_INDEX=1` disables it.
- Recorded by `run`, `chat` (new sessions), `mission` and the session
host (serve / ACP / MCP).
- `tole sessions --all` — newest first, id, name, pc, turns, start time,
cwd and a sanitized one-line preview; sessions whose file is gone are
hidden. `--grep` (requires `--all`) filters case-insensitively on first
prompt, name or cwd.
- `tole resume <id>`: when the id is not in the current sessions dir but
the index knows it, resume REFUSES and prints the command to run in the
owning project (`cd <project> && tole resume <id>`, with
`--sessions-dir` when non-default). Deliberate deviation from the
issue's "cwd-independent resume" (Cora alert #124): resuming from here
would apply this directory's workspace jail, project config and trust to
another project's session. A missing local sessions dir is now "no local
match" instead of an error. The index fallback only accepts a valid id
whose indexed file is `<dir>/<id>.jsonl`, and the index is read as raw
byte lines (a non-UTF-8 line is skipped) — Cora alerts #122/#123.
- Docs: README, CHANGELOG, `docs/epics.md`, `docs/threat-model.md`.
- Not in this PR: `chat --resume` does not consult the index yet.

## Testing

- Unit: last-line-wins, newest-first, torn/foreign lines skipped,
owner-only mode; rows read from the session file, gone sessions hidden,
preview bounded and one-line, grep on prompt/cwd, `find` ignores gone
files.
- E2E (real binary, isolated `CODECORA_HOME`, mock provider): a session
started in project A is invisible to B's `sessions`, listed by `sessions
--all` with A's cwd and preview, matched by `--grep`, `resume <id>` from
B refused with the exact `cd <A> && tole resume <id>` command and
nothing written, then resumed from A; the index holds no prompt text;
`TOLE_NO_SESSION_INDEX=1` records nothing; `--grep` without `--all` is
refused.
- `cargo fmt`, clippy (workspace all-targets, bare, shell-tools, mcp),
`cargo test --workspace`: green (one run hit the known load-sensitive
`web::fetch_and_search_round_trip_against_local_mock` flake, untouched
here; green on rerun). Cora agent review (prepare + finalize): 0
findings, `should_block: false`.

Note: e2e tests elsewhere that do not isolate `CODECORA_HOME` add their
temp sessions to a developer's real index; `--all` hides them once their
files are deleted.

---------

Co-authored-by: ajianaz <[email protected]>
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.

provider + git jail: check HTTP status in complete(); drive-letter paths in add jail

1 participant