TODO: drop snapshot blob from md-tracking; use git for diff source
Some checks are pending
CI / detect-changes (push) Waiting to run
CI / docs-check (push) Blocked by required conditions
CI / lint (push) Blocked by required conditions
CI / build (push) Blocked by required conditions
CI / integration-tests (push) Blocked by required conditions
CI / windows-portability (push) Blocked by required conditions
CI / rtk-portability (linux, blacksmith-4vcpu-ubuntu-2404) (push) Blocked by required conditions
CI / rtk-portability (macos, macos-15) (push) Blocked by required conditions
CI / rtk-portability (windows, blacksmith-4vcpu-windows-2025) (push) Blocked by required conditions

Per follow-up: SF generates many of these .md files itself (.sf/wiki/*,
.sf/milestones/**/*.md, docs/plans/**), so storing gzipped snapshots in
the DB would duplicate disk + git for no benefit.

Simpler design: store only the sha + meta in sf.db; compute diffs
on demand against `git show HEAD:<path>`. Naturally handles both
"working-tree edit not yet committed" and "another agent committed
while SF wasn't running".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mikael Hugo 2026-05-11 19:46:06 +02:00
parent faecdc828c
commit 296054b1d4

36
TODO.md
View file

@ -118,31 +118,45 @@ Explicit out of scope:
is expected, no signal in tracking.
- `node_modules`, `dist`, vendored copies — irrelevant.
Storage in `sf.db`:
Storage in `sf.db`**shas only, no content snapshots**. SF generates
many of these files itself; caching their contents in the DB would
duplicate disk + git for no benefit:
```sql
CREATE TABLE tracked_md_files (
relpath TEXT PRIMARY KEY, -- repo-relative path
sha256 TEXT NOT NULL,
sha256 TEXT NOT NULL, -- hash of last-seen content
size_bytes INTEGER NOT NULL,
last_seen_at TEXT NOT NULL,
snapshot BLOB, -- gzipped content, optional
category TEXT -- 'meta'|'wiki'|'milestone'|'adr'|'plan'
);
```
For diff source, use **git** (these are all tracked files; if they're
not, the agent should add them or skip tracking that path):
```
git show HEAD:<relpath> ← what was committed
<relpath> ← what's on disk now
diff the two ← what changed since the last commit
```
This naturally handles "the operator edited but hasn't committed yet"
(diff shows the working-tree change) and "another agent committed and
SF wasn't running" (diff shows the new commit).
On session start + each autonomous-cycle entry, walk the configured
glob set, hash each file, diff against `tracked_md_files.sha256`.
For each changed file:
1. Compute diff against `snapshot` (or `git show HEAD:<path>` if the
file is tracked).
2. Surface to operator: "**N** files changed since last seen — review
or accept?" with per-file inline diffs.
3. On accept → update sha + snapshot. On reject → restore from
snapshot.
4. New files (sha not in DB) → import + classify by glob category.
5. Deleted files → archive (don't purge until operator confirms).
1. Surface to operator: "**N** files changed since SF last saw — review
or accept?" with per-file diff (computed from git, not from a DB
blob).
2. On accept → update sha + last_seen_at. No content stored.
3. New files (sha not in DB) → classify by glob category, store sha,
continue.
4. Deleted files → archive the DB row (mark inactive); don't purge
until operator confirms.
Useful for:
- hand-edits / cross-agent edits / git pulls (the original