feat(engram): add DataDirService (copy/move/delete) and InjectWithOptions#486
Closed
tonyblu331 wants to merge 4 commits into
Closed
feat(engram): add DataDirService (copy/move/delete) and InjectWithOptions#486tonyblu331 wants to merge 4 commits into
tonyblu331 wants to merge 4 commits into
Conversation
This was referenced May 9, 2026
Contributor
Author
|
👋 Maintainer request: could you please add the `type:feature` label? Also a note on the size check: this PR is part of a 7-PR chain (
Each PR's check will turn green as soon as its predecessor merges. All seven are independently within the 400-line budget. |
2 tasks
Adds internal/storage package with: - FormatBytes: human-readable sizes using 1024-based units (B/KiB/MiB/GiB) - AvailableBytes: platform-gated disk space check (syscall.Statfs on Unix, GetDiskFreeSpaceExW on Windows) No Engram coupling. Used by the upcoming data-directory domain layer.
…r helpers Introduces the foundational types and location-discovery layer for Engram data-directory management (issue Gentleman-Programming#346, PR B1 of B1+B2+B3): - DataDirRef: future-proof path type with Resolve(homeDir), DefaultDir, DBPath helpers - SuggestLocations: ordered candidate list with deduplication and free-space labels - Platform-specific volume discovery (Statfs on Unix, GetDiskFreeSpaceEx on Windows) - FormatDirLine / FormatSpaceWarning presenter helpers (no Bubbletea dep) 10 unit tests cover all location and label behaviours. Depends on PR A (feat/storage-utils).
Adds the copy primitive for Engram data-directory operations (issue Gentleman-Programming#346, PR B2 of B1+B2+B3): - CopyDB(src, dst string) error: writes to a .tmp sibling then os.Rename for atomicity; uses io.Copy which activates sendfile/splice on Linux and macOS automatically — no manual buffer needed - Size verification before rename catches truncated writes - Deferred os.Remove on the tmp file is cancelled only on successful rename - 5 unit tests cover happy path, idempotency, missing source, and dir creation Depends on PR B1 (feat/engram-domain-types).
…ions Completes the engram domain layer for data-directory management (issue Gentleman-Programming#346, PR B3 of B1+B2+B3): - DataDirService.CopyTo / MoveTo / Delete: snapshot-guarded operations that call backup.Snapshotter.Create before touching data; return snapshot ID - DiskSpaceOK: pre-flight check before CopyTo/MoveTo - InjectWithOptions: backward-compatible extension of Inject that accepts InjectOptions{DataDir} to include ENGRAM_DATA_DIR in MCP env config; existing Inject() delegates to InjectWithOptions with zero options unchanged - 6 service unit tests + inject backward-compat coverage Depends on PR B2 (feat/engram-domain-copy).
a90feec to
3c99d6c
Compare
Contributor
Author
|
Superseded by the ≤400 LOC chain (no \size:exception).
This draft exceeded the 400-line review budget vs \main. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary Completes the engram domain layer for data-directory management (issue #346, PR B3 of B1+B2+B3): -
DataDirService.CopyTo / MoveTo / Delete— snapshot-guarded operations that callbackup.Snapshotter.Createbefore touching data; return(snapshotID, err)-DiskSpaceOK— pre-flight free-space check beforeCopyTo/MoveTo-InjectWithOptions— backward-compatible extension: acceptsInjectOptions{DataDir}to includeENGRAM_DATA_DIRin MCP env config; existingInject()delegates to it with zero options unchanged ## Changes | File | Type | Lines | |------|------|-------| |internal/components/engram/service.go| New | +99 | |internal/components/engram/service_test.go| New | +160 | |internal/components/engram/inject.go| Modified | +89 / −22 | | Total | | +348 / −22 = 370 / budget: 400 ✅ | ## Test plan - [x]go test ./internal/components/engram/... -run "TestDataDirService|TestInjectWith"— 6 service tests pass - [x]go build ./...— clean build - [x] Full repogo test ./...— ✅ Pass — CI run - [x] E2Ecd e2e && ./docker-test.sh(ubuntu / arch / fedora) — ✅ Pass — same workflow ## PR Chain — Closes #346 | # | PR | Lines | |---|----|-------| | A | #465 | 152 ✅ | | B1 | #484 | 340 ✅ | | B2 | #485 | 171 ✅ | | B3 | this PR | 370 ✅ | | C | #487 | 33 ✅ | | D1 | #488 | 282 ✅ | | D2 | #489 | 340 ✅ | --- ## CI status (GitHub Actions) — latest (ci: trigger unit and e2e workflows) Checks: https://github.com/Gentleman-Programming/gentle-ai/pull/486/checks Unit + E2E workflow: https://github.com/Gentleman-Programming/gentle-ai/actions/runs/25600335320 | Gate | Status | |------|--------| | Unit Tests (go test ./...) | ✅ Pass | | E2E (ubuntu) | ✅ Pass | | E2E (arch) | ✅ Pass | | E2E (fedora) | ✅ Pass | | Issue reference (Closes #346) +status:approved| ✅ Pass | | PR cognitive load vsmain| ⚠️ Fails while stack is open (full diff vsmain); this slice ≤400 lines ✅ | | Exactly onetype:*label | ⚠️ Maintainer applies |bash go test ./... cd e2e && ./docker-test.sh🤖 Generated with Claude CodeChain Context (SDD - stacked PRs targeting main)
The Summary / Changes tables above describe the scoped review unit for this numbered PR. GitHub diff vs main is cumulative while every PR still targets main, so totals grow down-chain even though each PR narrative stays slice-focused.
Merge-order diagram
main -> PR #465 -> PR #484 -> PR #485 -> [THIS] PR #486 -> PR #487 -> PR #488 -> PR #489Autonomy