story: DGR-032 Implement deterministic fake ShardEngine

This commit is contained in:
Dobromir Popov
2026-07-23 11:09:16 +03:00
parent c34ab059cc
commit 25e53bfeab
6 changed files with 847 additions and 13 deletions

View File

@@ -1444,3 +1444,78 @@ Max iterations: unlimited
[11:00:31] [INFO] [agent] DGR-031 is complete: I added `packages/node/meshnet_node/shard_engine.py` (the `ShardEngine` ABC with load/capabilities/prefill/decode/cancel/release/health/metrics, project-owned tensor/bundle/token-output types, reserved-but-disabled MTP and architecture aux-state hooks), a reusable `tests/shard_engine_contract.py` lifecycle contract for DGR-032/DGR-037 to reuse, `tests/test_shard_engine.py` proving it against a minimal reference engine, and the evidence README/prd.json/issue markdown updates. All targeted tests (12 new + 95 dependency-adjacent) pass, `compileall` and `git diff --check` are clean, and the pre-existing 27-module collection failure in `tests/` was confirmed unrelated via `git stash`.
[11:00:31] [INFO] [agent] [ScheduleWakeup]
[11:00:32] [INFO] [agent] <promise>COMPLETE</promise>
[11:00:33] [INFO] [progress] Iteration 2 finished. Task DGR-031: COMPLETED. Duration: 564s
[11:00:33] [INFO] [tracker] Task DGR-031 completed in iteration 2
[11:00:34] [INFO] [progress] Iteration 3/∞: Working on DGR-032 - Implement deterministic fake `ShardEngine`
[11:00:38] [INFO] [agent] I'll start by reading the context files and the DGR-031 ShardEngine interface this task builds on.
[11:00:39] [INFO] [agent] [Bash] $ cat .scratch/distributed-gguf-runtime/RALPH-CONTEXT.md 2>/dev/null | head -100
[11:00:40] [INFO] [agent] [Bash] $ find . -path ./node_modules -prune -o -iname "*shard_engine*" -print 2>/dev/null
[11:00:43] [INFO] [agent] [Read] /run/media/popov/d/DEV/repos/d-popov.com/AI/.claude/worktrees/distributed-gguf-runtime/packages/node/meshnet_node/shard_engine.py
[11:00:44] [INFO] [agent] [Read] /run/media/popov/d/DEV/repos/d-popov.com/AI/.claude/worktrees/distributed-gguf-runtime/tests/shard_engine_contract.py
[11:00:45] [INFO] [agent] [Read] /run/media/popov/d/DEV/repos/d-popov.com/AI/.claude/worktrees/distributed-gguf-runtime/tests/test_shard_engine.py
[11:00:49] [INFO] [agent] [Bash] $ ls .scratch/distributed-gguf-runtime/evidence/ 2>/dev/null
[11:00:51] [INFO] [agent] [Read] /run/media/popov/d/DEV/repos/d-popov.com/AI/.claude/worktrees/distributed-gguf-runtime/packages/node/meshnet_node/shard_lifecycle.py
[11:00:55] [INFO] [agent] Now let me check the DGR-031 evidence README and prd.json entry for DGR-032 to understand exact expectations, plus check existing test directory structure and conventions.
[11:00:56] [INFO] [agent] [Read] /run/media/popov/d/DEV/repos/d-popov.com/AI/.claude/worktrees/distributed-gguf-runtime/.scratch/distributed-gguf-runtime/evidence/DGR-031/README.md
[11:00:57] [INFO] [agent] [Bash] $ python3 -c " import json data = json.load(open('.scratch/distributed-gguf-runtime/prd.json')) storie...
[11:01:00] [INFO] [agent] [Bash] $ python3 -c " import json data = json.load(open('.scratch/distributed-gguf-runtime/prd.json')) print(...
[11:01:03] [INFO] [agent] [Bash] $ python3 -c " import json data = json.load(open('.scratch/distributed-gguf-runtime/prd.json')) for s ...
[11:01:10] [INFO] [agent] [Bash] $ ls tests/ | sort | grep -v __pycache__
[11:01:14] [INFO] [agent] [Read] /run/media/popov/d/DEV/repos/d-popov.com/AI/.claude/worktrees/distributed-gguf-runtime/packages/node/meshnet_node/testing.py
[11:01:23] [INFO] [agent] [Bash] $ grep -n "ShardEngine\|shard_engine\|fake\|Fake" packages/node/meshnet_node/shard_runtime_server.py |...
[11:01:25] [INFO] [agent] [Read] /run/media/popov/d/DEV/repos/d-popov.com/AI/.claude/worktrees/distributed-gguf-runtime/.scratch/distributed-gguf-runtime/issues/033-build-a-standalone-fake-c-grpc-shard-worker.md
[11:01:38] [INFO] [agent] [Bash] $ grep -n "class \|def __init__\|Servicer\|import" packages/node/meshnet_node/shard_runtime_server.py ...
[11:02:45] [INFO] [agent] [Bash] $ grep -rn "dtype_size\|bfloat16\|itemsize\|byte_size\|dtype ==" packages/node/meshnet_node/protocol.p...
[11:05:05] [INFO] [agent] Now I have a clear picture. Let me write the fake `ShardEngine` module.
[11:05:45] [INFO] [agent] [Write] /run/media/popov/d/DEV/repos/d-popov.com/AI/.claude/worktrees/distributed-gguf-runtime/packages/node/meshnet_node/fake_shard_engine.py """"Deterministic fake ``ShardEngine`` fixture (DGR-032).
[11:05:45] [INFO] [agent] ``FakeShardEngine`` is a pure-Python, allocation-cheap subclass of
[11:05:45] [INFO] [agent] :class:`~meshnet_node.shard_engine.ShardEngine`: no llama.cpp, no native
[11:05:45] [INFO] [agent] bu... (12102 chars)"
[11:05:48] [INFO] [agent] Now let me write the test file covering the DGR-032-specific behaviors.
[11:06:17] [INFO] [agent] [Write] /run/media/popov/d/DEV/repos/d-popov.com/AI/.claude/worktrees/distributed-gguf-runtime/tests/test_fake_shard_engine.py """"DGR-032 ``FakeShardEngine`` tests.
[11:06:17] [INFO] [agent] ``FakeShardEngine`` obeys the exact same lifecycle contract every
[11:06:17] [INFO] [agent] ``ShardEngine`` implementation must (see ``shard_engine_contract.py``); the
[11:06:17] [INFO] [agent] tests here addition... (8385 chars)"
[11:06:20] [INFO] [agent] Now let's run the tests.
[11:06:21] [INFO] [agent] [Bash] $ .venv/bin/python3 -m pytest -q tests/test_fake_shard_engine.py tests/test_shard_engine.py 2>&1 | tai...
[11:06:28] [INFO] [agent] [Edit] /run/media/popov/d/DEV/repos/d-popov.com/AI/.claude/worktrees/distributed-gguf-runtime/tests/test_fake_shard_engine.py edit: " engine = FakeShardEngine(FakeShardEngineConfig..." → " engine = FakeShardEngine(FakeShardEngineConfig..."
[11:06:31] [INFO] [agent] [Bash] $ .venv/bin/python3 -m pytest -q tests/test_fake_shard_engine.py tests/test_shard_engine.py 2>&1 | tai...
[11:06:35] [INFO] [agent] All 26 tests pass. Now let's run the full targeted suite plus compileall and git diff --check.
[11:06:36] [INFO] [agent] [Bash] $ \ PYTHONPATH=packages/node:packages/tracker .venv/bin/python3 -m pytest -q \ tests/test_fake_shard...
[11:06:44] [INFO] [agent] [Bash] $ echo "exit: $?"
[11:06:48] [INFO] [agent] [Bash] $ echo "rc=$?"
[11:06:52] [INFO] [agent] Also run the broader `python -m compileall packages tests` gate as required.
[11:06:52] [INFO] [agent] [Bash] $ echo "rc=$?"
[11:06:54] [INFO] [agent] Clean. Now let's update `prd.json`, regenerate the issue markdown, and write the evidence README.
[11:06:55] [INFO] [agent] [Bash] $ python3 scripts/ralph_prd_schema.py --help 2>&1 | head -30
[11:06:58] [INFO] [agent] [Bash] $ python3 -c " import json data = json.load(open('.scratch/distributed-gguf-runtime/prd.json')) for s ...
[11:07:04] [INFO] [agent] Now let's write the evidence README before updating prd.json.
[11:08:00] [INFO] [agent] [Write] /run/media/popov/d/DEV/repos/d-popov.com/AI/.claude/worktrees/distributed-gguf-runtime/.scratch/distributed-gguf-runtime/evidence/DGR-032/README.md "# DGR-032 evidence — deterministic fake `ShardEngine`
[11:08:00] [INFO] [agent] **Completed:** 2026-07-23
[11:08:00] [INFO] [agent] **Branch:** `ralph/distributed-gguf-runtime`
[11:08:00] [INFO] [agent] **Authority:** `.scratch/distributed-gguf-runtime/prd.json`
[11:08:00] [INFO] [agent] **Dependencies... (13965 chars)"
[11:08:03] [INFO] [agent] Now let's update `prd.json` to mark DGR-032 as passing, then regenerate the issue markdown.
[11:08:05] [INFO] [agent] [Bash] $ python3 -c " import json path = '.scratch/distributed-gguf-runtime/prd.json' with open(path) as f: ...
[11:08:07] [INFO] [agent] [Bash] $ python3 scripts/ralph_prd_schema.py validate .scratch/distributed-gguf-runtime/prd.json 2>&1 | tail ...
[11:08:10] [INFO] [agent] [Bash] $ python3 scripts/ralph_prd_schema.py render .scratch/distributed-gguf-runtime/prd.json DGR-032 > .scr...
[11:08:12] [INFO] [agent] Good, that matches the pattern. Let's do a final check of `git status` and `git diff --check`.
[11:08:13] [INFO] [agent] [Bash] $ echo "diffcheck_rc=$?"
[11:08:18] [INFO] [agent] Now let's append learnings to `.ralph-tui/progress.md` as instructed.
[11:08:19] [INFO] [agent] [Bash] $ ls -la .ralph-tui/progress.md 2>&1
[11:08:25] [INFO] [agent] [Read] /run/media/popov/d/DEV/repos/d-popov.com/AI/.claude/worktrees/distributed-gguf-runtime/.ralph-tui/progress.md
[11:08:28] [INFO] [agent] Now let me append a new pattern and the DGR-032 completion entry.
[11:08:28] [INFO] [agent] [Bash] $ wc -l .ralph-tui/progress.md
[11:08:34] [INFO] [agent] [Read] /run/media/popov/d/DEV/repos/d-popov.com/AI/.claude/worktrees/distributed-gguf-runtime/.ralph-tui/progress.md
[11:08:47] [INFO] [agent] [Edit] /run/media/popov/d/DEV/repos/d-popov.com/AI/.claude/worktrees/distributed-gguf-runtime/.ralph-tui/progress.md edit: "- **Proving "this module imports no forbidden depe..." → "- **Proving "this module imports no forbidden depe..."
[11:08:49] [INFO] [agent] Now append the DGR-032 entry at the end of the file.
[11:08:50] [INFO] [agent] [Read] /run/media/popov/d/DEV/repos/d-popov.com/AI/.claude/worktrees/distributed-gguf-runtime/.ralph-tui/progress.md
[11:08:53] [INFO] [agent] [Read] /run/media/popov/d/DEV/repos/d-popov.com/AI/.claude/worktrees/distributed-gguf-runtime/.ralph-tui/progress.md
[11:09:06] [INFO] [agent] [Edit] /run/media/popov/d/DEV/repos/d-popov.com/AI/.claude/worktrees/distributed-gguf-runtime/.ralph-tui/progress.md edit: "- `tests/` as a whole still fails to collect in th..." → "- `tests/` as a whole still fails to collect in th..."
[11:09:15] [INFO] [agent] All acceptance criteria are met and evidence is documented. Summary of the work:
[11:09:15] [INFO] [agent] **Implemented DGR-032** — `FakeShardEngine`, a deterministic fixture `ShardEngine` subclass:
[11:09:15] [INFO] [agent] - `packages/node/meshnet_node/fake_shard_engine.py` (new) — SHA-256-hash-derived deterministic output per `(range, inputs, idempotency_step)`; head/middle/tail boundary-point tagging with token-ID sideband pass-through; isolated per-session epoch/cancel state; four opt-in fault-injection knobs via `FakeShardEngineConfig` (delay, memory-pressure budget, malformed-but-valid output, crash-after-N-calls raising a raw uncaught exception); `EVIDENCE_CLASS = "fixture"` marker for DGR-036's future fixture-vs-real comparison.
[11:09:15] [INFO] [agent] - `tests/test_fake_shard_engine.py` (new) — 15 tests covering the shared contract, head/middle/tail shape, session isolation, and each fault-injection knob (26 tests total combined with DGR-031's suite, all passing).
[11:09:15] [INFO] [agent] - `.scratch/distributed-gguf-runtime/evidence/DGR-032/README.md` (new), `prd.json` marked `passes: true`, issue markdown regenerated.
[11:09:15] [INFO] [agent] Quality gates: targeted pytest (109 passed, 3 skipped, pre-existing/unrelated), `python -m compileall packages tests` clean, `git diff --check` clean. No commit was made per instructions — the engine will commit automatically.
[11:09:15] [INFO] [agent] <promise>COMPLETE</promise>