gunk-dev/the-valley

bd-c4d069b-git-churn-from-task-state.md

source9ddf0d272106main's published tip history
3.7 KiB · Rendered
1---
2type: bug
3id: bd-c4d069b
4status: open
5title: Storing high-frequency task and lease state in git produces merge churn and packfile bloat
6created: 2026-09-01
7source: knowledge base design review, 2026-09-01
8---
9
10# Storing task and lease state in git produces merge churn and bloat
11
12The knowledge graph architecture places all project knowledge—outcomes, decisions, bugs, ideas, and
13discussion threads—into markdown files versioned in git ([architecture.md](../../design/architecture.md)).
14Sketches for autonomous agent execution ([[ida-eac723e]], [[ida-3145b7a]]) propose using frontmatter
15status mutations (such as transitioning an outcome to `status: in-progress` with run leases and
16heartbeat timestamps) as the concurrency lock for dispatching work. Storing high-frequency task
17execution state, leases, and discussion comments directly in git commits produces severe merge
18conflicts and rapid packfile bloat as agent concurrency increases.
19
20## Why git is poorly suited for fine-grained task leases
21
22Git is designed for durable, content-addressed trees of source code committed at human or
23milestone granularity. It is not designed to serve as an in-flight job queue or distributed lock
24manager.
25
26Using git commits to manage agent scheduling encounters three concrete failure modes:
27
281. **Frontmatter merge conflicts.** If two agents concurrently update different fields on an outcome
29 node (for instance, one updating a lease expiration while another appends a blocking edge or
30 status note), standard three-way git merges frequently conflict on adjacent frontmatter lines.
31 These conflicts reject integration requests, stalling automated progress.
322. **Packfile and tree bloat.** High-frequency state transitions (e.g., `open` $\rightarrow$
33 `in-progress` $\rightarrow$ heartbeat lease renewal $\rightarrow$ `done`) commit hundreds of
34 transient tree objects into the repository. This inflates `.git` storage, increases clone
35 times, and degrades the performance of every local `git log` and `git status` command.
363. **Query latency at scale.** Finding the unblocked frontier requires reading frontmatter across
37 all files in `outcomes/`. While scanning files with `grep` or filesystem traversal works at
38 fifty nodes, evaluating complex DAG dependencies across thousands of historical task nodes
39 imposes substantial I/O overhead on every scheduler tick.
40
41## Why this is acceptable today
42
43The live outcome graph currently contains fewer than ten nodes, and all outcome state transitions
44are authored manually by the operator. Automated dispatchers (klaus) do not yet write leases or
45execution state to git. The issue is structural to the scheduling design and will emerge as soon as
46the Phase 4 agent dispatch loop is automated.
47
48## Directions, not decisions
49
50- **Separate ephemeral leases from durable milestones.** In-flight dispatch leases, heartbeat
51 tokens, and agent execution logs belong on an ephemeral, low-latency store—such as NATS JetStream
52 KV or memory—rather than in git commits.
53- **Git records only terminal milestones.** An outcome is updated in git only upon creation, terminal
54 completion (`done`), or abandonment (`abandoned`), eliminating high-frequency operational churn
55 from git history.
56- **Out-of-band discussion and thread storage.** Consider storing rapid discussion threads and
57 agent reasoning traces in a dedicated append-only log or thread namespace, rather than embedding
58 every reply as a separate revision of a root markdown file.
59
60## Related
61
62- Outcome DAG scheduler: [[ida-eac723e]]
63 ([ida-eac723e-outcome-dag.md](../ideas/ida-eac723e-outcome-dag.md))
64- Demand pressure and leases: [[ida-3145b7a]]
65 ([ida-3145b7a-demand-pressure.md](../ideas/ida-3145b7a-demand-pressure.md))
66- Project knowledge architecture: [architecture.md](../../design/architecture.md)