Skip to content

Write a per-run fetch log beside the evidence index - #12

Merged
samrusani merged 1 commit into
mainfrom
fetch-log
Aug 20, 2026
Merged

Write a per-run fetch log beside the evidence index#12
samrusani merged 1 commit into
mainfrom
fetch-log

Conversation

@samrusani

@samrusani samrusani commented Aug 20, 2026

Copy link
Copy Markdown
Owner

Summary

  • A screen writes fetch_log.json at the case-directory root: one row per persisted fetch, with sanitized params and from_cache.
  • The evidence index stays a file manifest. No bodies, no keys. --no-write and rerun do not touch the log.
  • A symlink at fetch_log.json is refused before any other owned file moves.

Test plan

  • Five gates green locally: 766 tests, ruff, mypy, language check
  • CI on this PR (pytest matrix, wheel install, pip-audit)

The evidence index is a file manifest with timestamps. A screen now also writes fetch_log.json with sanitized params and cache flags so an operator can see what this run actually fetched, without bodies or keys.

Co-authored-by: Cursor <cursoragent@cursor.com>
@greptile-apps

greptile-apps Bot commented Aug 20, 2026

Copy link
Copy Markdown

Greptile Summary

The PR adds a per-screen fetch_log.json containing sanitized request metadata and cache status while preserving evidence/index.json as a file manifest.

  • Adds fetch-log serialization and guarded persistence beside the casefile and memo.
  • Extends overwrite preflight checks to include the new owned path.
  • Keeps rerun and no-write flows from creating or modifying the log.
  • Documents the new audit artifact and adds CLI, MCP, cache, overwrite, and symlink regression coverage.

Confidence Score: 4/5

The overwrite path should be fixed before merging because a failed fetch-log write can leave an existing case with artifacts from different runs.

The new log is written after overwrite has replaced the evidence and index but before the casefile and memo, while preflight rejects only symlinks, so an invalid non-symlink log path leaves a concretely inconsistent audit pack.

Files Needing Attention: src/coldscreen/casedir.py, src/coldscreen/pipeline.py

Important Files Changed

Filename Overview
src/coldscreen/casedir.py Adds fetch-log serialization and owned-path preflight, but an unwritable non-symlink log path can fail after evidence has already been replaced.
src/coldscreen/pipeline.py Integrates group preflight before overwrite cleanup, though the subsequent multi-file write remains partially destructive if the new log write fails.
tests/test_casedir.py Covers log contents and symlink refusal but does not cover a directory or other unwritable non-symlink at fetch_log.json.
tests/test_cli.py Verifies normal screen, no-write, rerun, cache-hit, and evidence-index behavior for the new log.
tests/test_mcp_server.py Extends MCP persistence and overwrite symlink coverage for fetch_log.json.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Screen gathers NamedRecord entries] --> B{no_write?}
  B -->|Yes| C[Return result without case writes]
  B -->|No| D[Preflight owned paths]
  D --> E{overwrite existing evidence?}
  E -->|Yes| F[Remove old evidence directory]
  E -->|No| G[Write evidence records]
  F --> G
  G --> H[Write evidence index]
  H --> I[Write fetch_log.json]
  I --> J[Write casefile.json]
  J --> K[Write memo.md]
Loading
Prompt To Fix All With AI
### Issue 1
src/coldscreen/casedir.py:193-196
**Partial overwrite corrupts audit pack**

When an overwrite encounters a directory or other unwritable non-symlink at `fetch_log.json`, the symlink-only preflight accepts it and the log write fails after the new evidence and index have been persisted, leaving them alongside the previous `casefile.json` and `memo.md`.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "Write a per-run fetch log beside the evi..." | Re-trigger Greptile

Comment thread src/coldscreen/casedir.py
Comment on lines +193 to +196
write_case_text(
case_dir / "fetch_log.json",
json.dumps([fetch_log_row(named) for named in records], indent=2) + "\n",
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Partial overwrite corrupts audit pack

When an overwrite encounters a directory or other unwritable non-symlink at fetch_log.json, the symlink-only preflight accepts it and the log write fails after the new evidence and index have been persisted, leaving them alongside the previous casefile.json and memo.md.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/coldscreen/casedir.py
Line: 193-196

Comment:
**Partial overwrite corrupts audit pack**

When an overwrite encounters a directory or other unwritable non-symlink at `fetch_log.json`, the symlink-only preflight accepts it and the log write fails after the new evidence and index have been persisted, leaving them alongside the previous `casefile.json` and `memo.md`.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

@samrusani
samrusani merged commit ea83c1c into main Aug 20, 2026
5 checks passed
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.

1 participant