Skip to content

Close cache and chaos polish followups#2

Open
HardcoreMonk wants to merge 21 commits into
mainfrom
small-polish-batch
Open

Close cache and chaos polish followups#2
HardcoreMonk wants to merge 21 commits into
mainfrom
small-polish-batch

Conversation

@HardcoreMonk

@HardcoreMonk HardcoreMonk commented May 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add optional max-entry cap and LRU eviction for the edge CoordClient lookup cache.
  • Wire EDGE_COORD_LOOKUP_CACHE_MAX_ENTRIES / --coord-lookup-cache-max-entries.
  • Tighten quorum-loss chaos Phase D to verify Phase-A keys remain present and Phase-C keys remain absent on the survivor.
  • Update README/GUIDE/HTML/FOLLOWUP for the closed P6-12 and P8-05 items.

Test Plan

  • go test ./internal/edge -run 'TestCoordClient_LookupCache' -count=1\n- [x] go test ./cmd/kvfs-edge ./internal/edge\n- [x] bash -n scripts/chaos-coord-quorum-loss.sh\n- [x] go test ./...\n- [x] go vet ./...\n- [x] ./scripts/check-doc-drift.sh\n- [x] git diff --check\n- [x] stale-marker scan from AGENTS.md\n- [x] ./scripts/chaos-coord-quorum-loss.sh --keys 3 --down-sec 6\n\n## Note\norigin/main is behind local main, so this PR includes the shared local documentation history leading up to this branch as well as the four small-polish implementation commits.

Summary by CodeRabbit

  • New Features

    • Added EDGE_COORD_LOOKUP_CACHE_MAX_ENTRIES environment variable to configure lookup cache capacity limits.
  • Documentation

    • Clarified production MVP track scope, requirements, and compatibility gates.
    • Updated architecture guidance with production deployment topology and API boundaries.
    • Documented P9 production MVP profile with single-region, S3-compatible scope and operational constraints.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 17, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR introduces the P9 production MVP track for kvfs as an internal MinIO/S3-compatible replacement, finalizes governance alignment, and delivers two polish items. The changes span governance docs (ADR-064, project identity), cache bounding for CoordClient (LRU eviction), chaos script identity checking, and comprehensive planning artifacts for future P9 slices.

Changes

Governance Charter & Project Identity

Layer / File(s) Summary
Production MVP charter definition
docs/adr/ADR-064-production-mvp-profile.md, AGENTS.md, docs/superpowers/specs/2026-05-15-project-design-governance-design.md, docs/superpowers/specs/2026-05-16-production-mvp-replacement-design.md, docs/superpowers/grill-me/2026-05-15-project-design-governance.md, docs/superpowers/grill-me/2026-05-16-production-mvp-replacement.md
ADR-064 establishes the 3-daemon production topology, S3 compatibility contract, security gates (TLS/mTLS/WAL/SigV4), and explicit non-goals (no IAM parity, cross-region, POSIX, multi-tenancy). AGENTS.md adds safety rules against overclaiming current-revision readiness and prohibits weakening security gates without a superseding ADR. Governance specs and decision records document the charter scope, boundaries, and rationale.
Project identity & public docs
README.md, docs/GUIDE.md, docs/guide.html, docs/ARCHITECTURE.md, docs/FOLLOWUP.md, docs/adr/ADR-015-coordinator-daemon-split.md, docs/adr/ADR-032-nfs-gateway-deferred.md, docs/adr/README.md
README and GUIDE clarify P9 as an internal single-region MinIO/S3-compatible replacement track; ADR count incremented from 59 to 60. ARCHITECTURE.md specifies 3-daemon coord-proxy production topology and clarifies S3 client contract (front-door via edge, metadata ownership in coord). FOLLOWUP.md refreshed with P9 status and implementation roadmap. ADR-015 and ADR-032 normalized from "Proposed" to "Accepted" status.
Lifecycle artifacts & planning docs
docs/operations/2026-05-15-project-design-governance-handoff.md, docs/operations/2026-05-16-production-mvp-charter-supersede-handoff.md, docs/superpowers/plans/2026-05-15-project-design-governance.md, docs/superpowers/plans/2026-05-16-production-mvp-charter-supersede.md, docs/superpowers/plans/2026-05-16-s3-compatibility-foundation.md, docs/superpowers/plans/2026-05-16-small-polish-batch.md, docs/superpowers/specs/2026-05-16-small-polish-batch-design.md, docs/superpowers/grill-me/2026-05-16-s3-compatibility-foundation.md
Governance alignment and production MVP handoff docs record design decisions, verification steps, and release scope (documentation-only, no Go behavior changes). Planning documents enumerate tasks for P9-01 charter supersede, P9-02 S3 foundation, and small polish batch with step-by-step checklists and verification criteria. Specs define architecture boundaries, testing strategy, and success criteria for each phase.
Repository configuration
.gitignore
.worktrees/ directory added to ignore rules.

CoordClient Cache & Chaos Script Hardening

Layer / File(s) Summary
Lookup cache capacity bounding
internal/edge/coord_client.go
CoordClient cache extended with cacheMaxEntries cap and per-entry lastUsed tracking via monotonic cacheTick. New public method SetLookupCacheWithLimit(ttl, maxEntries) enables bounded caching with LRU eviction; SetLookupCache(ttl) remains as unbounded convenience wrapper. cacheGet updated to refresh lastUsed (now requires exclusive lock). cachePut enforces capacity limit via cacheEnforceLimitLocked and removes expired entries before insertion via cacheRemoveExpiredLocked.
Cache tests & wiring
internal/edge/coord_client_test.go, cmd/kvfs-edge/main.go
Two new tests verify LRU eviction under capacity pressure and expiry cleanup before cap enforcement using deterministic coord server and direct cache inspection. main.go imports strconv, parses EDGE_COORD_LOOKUP_CACHE_MAX_ENTRIES env var with validation (fatal on invalid/negative), and wires cache cap via SetLookupCacheWithLimit(ttl, cap) when TTL is enabled. Documentation adds env var table entry describing cache behavior and 0=unbounded semantics.
Chaos script Phase D identity validation
scripts/chaos-coord-quorum-loss.sh, docs/FOLLOWUP.md
Phase D enhanced with JSON-based identity checks: new helpers coord_objects_json() and object_json_has_key() validate Phase-A key presence and Phase-C key absence during quorum loss. Replaces count-only drift detection with per-key identity validation; extends summary output and exit logic to fail on identity drift (ADR-040 violation). FOLLOWUP.md marks P6-12 and P8-05 complete with updated verification narrative.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A rabbit hops through governance gates,
With cache bounds and chaos that validates,
P9's MVP now set in stone—
Production track has found its home!
From ADR-064 to identity checks,
The polish batch removes defects. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Close cache and chaos polish followups' accurately summarizes the main changes: it addresses the cache bounding feature (P6-12) and quorum-loss chaos hardening (P8-05), which are the primary implementation commits in this PR.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch small-polish-batch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cmd/kvfs-edge/main.go`:
- Around line 364-379: The code parses EDGE_COORD_LOOKUP_CACHE_MAX_ENTRIES (via
strconv.Atoi into lookupCacheMax) even when EDGE_COORD_LOOKUP_CACHE_TTL
(flagLookupCache) is empty; move the strconv.Atoi call and the lookupCacheMax <
0 check inside the TTL-enabled branch so that lookupCacheMax is only parsed and
validated when *flagLookupCache != ""; then keep the existing time.ParseDuration
for flagLookupCache and call coordClient.SetLookupCacheWithLimit(ttl,
lookupCacheMax) as before.

In `@docs/superpowers/plans/2026-05-15-project-design-governance.md`:
- Line 13: The heading "### Task 1: Lifecycle Artifacts" jumps from an H1,
violating markdownlint; change that heading to "## Task 1: Lifecycle Artifacts"
and update the other task headings that follow (e.g., any "### Task 2..." / "###
Task 3...") to the same level so the document uses H1 -> H2 -> H3 progression
consistently, ensuring subsequent subtask headings remain one level deeper if
needed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: b3d79e4b-79a3-4d88-a503-a812fb67b8e5

📥 Commits

Reviewing files that changed from the base of the PR and between ace7842 and 4702ce2.

📒 Files selected for processing (27)
  • .gitignore
  • AGENTS.md
  • README.md
  • cmd/kvfs-edge/main.go
  • docs/ARCHITECTURE.md
  • docs/FOLLOWUP.md
  • docs/GUIDE.md
  • docs/adr/ADR-015-coordinator-daemon-split.md
  • docs/adr/ADR-032-nfs-gateway-deferred.md
  • docs/adr/ADR-064-production-mvp-profile.md
  • docs/adr/README.md
  • docs/guide.html
  • docs/operations/2026-05-15-project-design-governance-handoff.md
  • docs/operations/2026-05-16-production-mvp-charter-supersede-handoff.md
  • docs/superpowers/grill-me/2026-05-15-project-design-governance.md
  • docs/superpowers/grill-me/2026-05-16-production-mvp-replacement.md
  • docs/superpowers/grill-me/2026-05-16-s3-compatibility-foundation.md
  • docs/superpowers/plans/2026-05-15-project-design-governance.md
  • docs/superpowers/plans/2026-05-16-production-mvp-charter-supersede.md
  • docs/superpowers/plans/2026-05-16-s3-compatibility-foundation.md
  • docs/superpowers/plans/2026-05-16-small-polish-batch.md
  • docs/superpowers/specs/2026-05-15-project-design-governance-design.md
  • docs/superpowers/specs/2026-05-16-production-mvp-replacement-design.md
  • docs/superpowers/specs/2026-05-16-small-polish-batch-design.md
  • internal/edge/coord_client.go
  • internal/edge/coord_client_test.go
  • scripts/chaos-coord-quorum-loss.sh

Comment thread cmd/kvfs-edge/main.go
Comment on lines +364 to 379
lookupCacheMax, perr := strconv.Atoi(*flagLookupCacheMax)
if perr != nil {
fatal("EDGE_COORD_LOOKUP_CACHE_MAX_ENTRIES parse: " + perr.Error())
}
if lookupCacheMax < 0 {
fatal("EDGE_COORD_LOOKUP_CACHE_MAX_ENTRIES must be >= 0")
}
// P6-10/P6-12 opt-in cache.
if *flagLookupCache != "" {
ttl, perr := time.ParseDuration(*flagLookupCache)
if perr != nil {
fatal("EDGE_COORD_LOOKUP_CACHE_TTL parse: " + perr.Error())
}
coordClient.SetLookupCache(ttl)
log.Info("coord lookup cache enabled (P6-10)", "ttl", ttl)
coordClient.SetLookupCacheWithLimit(ttl, lookupCacheMax)
log.Info("coord lookup cache enabled (P6-10/P6-12)", "ttl", ttl, "max_entries", lookupCacheMax)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Gate max-entry parsing behind TTL-enabled cache config.

EDGE_COORD_LOOKUP_CACHE_MAX_ENTRIES is currently parsed/fatal even when lookup cache TTL is unset, despite being documented as TTL-gated. This can fail startup for an unused setting.

💡 Proposed fix
-		lookupCacheMax, perr := strconv.Atoi(*flagLookupCacheMax)
-		if perr != nil {
-			fatal("EDGE_COORD_LOOKUP_CACHE_MAX_ENTRIES parse: " + perr.Error())
-		}
-		if lookupCacheMax < 0 {
-			fatal("EDGE_COORD_LOOKUP_CACHE_MAX_ENTRIES must be >= 0")
-		}
-		// P6-10/P6-12 opt-in cache.
-		if *flagLookupCache != "" {
+		// P6-10/P6-12 opt-in cache.
+		if *flagLookupCache != "" {
+			lookupCacheMax, perr := strconv.Atoi(*flagLookupCacheMax)
+			if perr != nil {
+				fatal("EDGE_COORD_LOOKUP_CACHE_MAX_ENTRIES parse: " + perr.Error())
+			}
+			if lookupCacheMax < 0 {
+				fatal("EDGE_COORD_LOOKUP_CACHE_MAX_ENTRIES must be >= 0")
+			}
 			ttl, perr := time.ParseDuration(*flagLookupCache)
 			if perr != nil {
 				fatal("EDGE_COORD_LOOKUP_CACHE_TTL parse: " + perr.Error())
 			}
 			coordClient.SetLookupCacheWithLimit(ttl, lookupCacheMax)
 			log.Info("coord lookup cache enabled (P6-10/P6-12)", "ttl", ttl, "max_entries", lookupCacheMax)
 		}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/kvfs-edge/main.go` around lines 364 - 379, The code parses
EDGE_COORD_LOOKUP_CACHE_MAX_ENTRIES (via strconv.Atoi into lookupCacheMax) even
when EDGE_COORD_LOOKUP_CACHE_TTL (flagLookupCache) is empty; move the
strconv.Atoi call and the lookupCacheMax < 0 check inside the TTL-enabled branch
so that lookupCacheMax is only parsed and validated when *flagLookupCache != "";
then keep the existing time.ParseDuration for flagLookupCache and call
coordClient.SetLookupCacheWithLimit(ttl, lookupCacheMax) as before.


---

### Task 1: Lifecycle Artifacts

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fix heading level jump to satisfy markdownlint.

Line 13 starts at ### directly under an # heading, which violates heading increment rules (h1 -> h3). Use ## here (and keep subsequent task headings consistent).

Suggested patch
-### Task 1: Lifecycle Artifacts
+## Task 1: Lifecycle Artifacts
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
### Task 1: Lifecycle Artifacts
## Task 1: Lifecycle Artifacts
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 13-13: Heading levels should only increment by one level at a time
Expected: h2; Actual: h3

(MD001, heading-increment)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/superpowers/plans/2026-05-15-project-design-governance.md` at line 13,
The heading "### Task 1: Lifecycle Artifacts" jumps from an H1, violating
markdownlint; change that heading to "## Task 1: Lifecycle Artifacts" and update
the other task headings that follow (e.g., any "### Task 2..." / "### Task
3...") to the same level so the document uses H1 -> H2 -> H3 progression
consistently, ensuring subsequent subtask headings remain one level deeper if
needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant