Skip to content

feat: assign, queue, S3 events, dependency-aware locking (#12 #13 #15 #17)#19

Merged
pszymkowiak merged 16 commits into
masterfrom
feat/all-issues
Apr 6, 2026
Merged

feat: assign, queue, S3 events, dependency-aware locking (#12 #13 #15 #17)#19
pszymkowiak merged 16 commits into
masterfrom
feat/all-issues

Conversation

@pszymkowiak
Copy link
Copy Markdown
Contributor

Summary

Implements the 4 remaining open issues in a single PR (#16 was already done):

Changes

File Lines What
src/cli/mod.rs +363 assign, queue, watch --poll, --with-deps, --queue commands
src/db/mod.rs +237 lock_queue table, deps methods, transitive CTE
src/parser/mod.rs +232 Call graph extraction, scan_with_deps

Test plan

  • 72 tests pass (10 new: queue FIFO, deps transitive, call extraction for Rust/TS/Python)
  • Release build succeeds
  • Manual: grit init on a repo with function calls → verify deps count > 0
  • Manual: grit claim --queue when blocked → verify queue position
  • Manual: grit claim --with-deps → verify callees locked as read
  • Manual: grit assign -f pattern → verify auto-pick works
  • Manual: grit watch --poll 2 → verify events printed on lock changes

Closes #12, closes #13, closes #15, closes #17

🤖 Generated with Claude Code

… deps

#15 assign: auto-pick and claim a free symbol from a file pattern
  - `grit assign -a agent -i intent --file pattern`
  - Picks first unlocked symbol, claims it, creates worktree

#12 queue: FIFO lock queue for contested symbols
  - `--queue` flag on claim: enqueue instead of failing when blocked
  - Auto-promotion: next agent in queue gets the lock on release/done
  - `grit queue list` / `grit queue cancel` management commands
  - New lock_queue table in schema

#13 S3 distributed events: poll-based watch for distributed agents
  - `grit watch --poll <secs>` diffs lock state periodically
  - Auto-detects S3 backend and defaults to polling mode

#17 dependency-aware locking: call graph extraction + transitive locks
  - Parser extracts function calls from AST (13 languages)
  - Populates deps table during `grit init`
  - `--with-deps` flag on claim: auto-locks transitive callees as read
  - `grit plan` shows dependencies and suggests --with-deps
  - Recursive CTE for transitive dependency resolution

72 tests pass (10 new tests for queue, deps, and call extraction).
scripts/ai-agents/  — launch N claude/gemini agents in parallel via grit
scripts/synthetic/  — no-AI merge conflict stress test (grit vs raw git)
scripts/sweep/      — multi-config sweep across agent counts & projects
scripts/lib/        — shared helpers (setup, modify, reporting)
- Use git -C instead of cd to avoid cwd invalidation after rm -rf
- Use set +e in subshells to prevent silent exit on grit claim failure
- Fix grep -c pattern with || true instead of || echo "0"
- Separate setup_git_repo (no grit) from setup_work_repo (with grit)
- Remove set -e from synthetic bench (incompatible with || patterns)
- Use git -C instead of cd everywhere
- set +e in grit subshells
- grep || true pattern for conflict/merge counting
- Remove set -e (incompatible with || fallback patterns)
Add add_file_header() that prepends a unique comment to every modified
file. This forces real git merge conflicts (agents branch from same
commit, all prepend to same file -> line 1 conflict).

Results:
  10 agents: git 80% fail, grit 0% fail
  20 agents: git 82% fail, grit 0% fail
  50 agents: git 70% fail, grit 0% fail, 175 conflict files vs 0
…icts

New scripts/throughput/ benchmark that measures what users care about:
how many features actually ship vs how many are LOST to conflicts.

Git workflow: all agents branch from same commit (realistic parallel
work), then merge sequentially. Conflicts = work thrown away.

Results on ts-api:
  10 agents: git 70% work lost, grit 0%
  20 agents: git 75% work lost, grit 0%
  30 agents: git 83% work lost, grit 0%
  50 agents: git 90% work lost, grit 0%
- New banner matching RTK/ICM/VOX visual style
- Feature throughput benchmark results (70-90% work wasted with git)
- 13 language support table with extracted symbol types
- New commands: assign, queue, watch --poll, claim --with-deps
- RTK AI ecosystem section
Run systematic benchmarks (1,2,5,10,15,20,25,30,40,50 agents) across
ts-api, pi-calc, and rust-service projects (3 rounds each).

Generated charts showing:
- Merge failure rate by agent count (per project + grit always 0%)
- Work wasted to conflicts (area chart: git vs grit)
- Successful merges bar chart

Key finding: git wastes 50-80% of work at 2+ agents. Grit: always 0%.
If-None-Match conditional PUT only works on AWS S3 and Cloudflare R2.
MinIO, GCS (S3-compat), and Azure (S3 gateway) return errors instead
of 412. Fall back to GET-then-PUT for these providers.

Tested with MinIO: claim/block/release cycle works end-to-end.
For providers without conditional PUT (MinIO, GCS), use optimistic
write-then-verify pattern. Tested with MinIO (works), GCS (race
condition in sequential claims due to last-writer-wins semantics).

Note: GCS and Azure need native API clients for true atomic locking.
S3-compatible fallback works for MinIO and low-contention scenarios.
Providers with conditional PUT (AWS S3, Cloudflare R2) are unaffected.
Add azure_store.rs using Azure SDK (not S3-compat) with:
- If-None-Match: * for atomic lock acquisition (no race conditions)
- Native blob list/get/put/delete
- Automatic Event Grid integration (free: BlobCreated/BlobDeleted events)

Tested end-to-end on real Azure Storage:
  agent-1 claim login  → Granted
  agent-2 claim login  → BLOCKED (atomic conditional PUT)
  agent-2 claim logout → Granted
  agent-1 done         → merge + release
  agent-2 retry login  → Granted

grit config set-azure --account <name> --access-key <key> --container <name>
- Azure Blob tested with 10/20/30/50 agents: 0 conflicts, 0 orphan blobs
- Backend comparison table: Azure (atomic + Event Grid), S3 (atomic), MinIO (fallback)
- Event system docs: Azure Event Grid fires free events on every claim/release
- Reorganized Backends section with setup commands for each provider
@pszymkowiak pszymkowiak merged commit a2c4873 into master Apr 6, 2026
0 of 3 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

1 participant