fix(core): expose master persistence degradation - #698
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughMasterOrchestrator now tracks persistence health via internal ChangesPersistence Health Tracking
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
📊 Coverage ReportCoverage report not available
Generated by PR Automation (Story 6.1) |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/core/master-orchestrator.test.js (1)
291-310: ⚡ Quick winAdd a fail→success recovery assertion for persistence health
This test validates degradation, but it doesn’t verify that a subsequent successful
saveState()clears the degraded signal. Add one extra successful save/assert cycle so the reset behavior is locked in.As per coding guidelines, “Verify test coverage exists for new/modified functions.”
🤖 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 `@tests/core/master-orchestrator.test.js` around lines 291 - 310, After mocking fs.writeJson to fail once and asserting degradation, add a recovery step: change the spy (writeJsonSpy) to resolve successfully for a subsequent call (e.g., mockResolvedValueOnce or replace the mock) and invoke orchestrator.saveState() again, then assert orchestrator.isPersistenceAvailable() is true, orchestrator.getPersistenceError() is null/empty, and that orchestrator.getStatus().persistence and orchestrator.finalize().persistence reflect available: true with no error; keep using the same writeJsonSpy and restore it in the finally block as before and locate behavior around orchestrator.saveState(), orchestrator.isPersistenceAvailable(), orchestrator.getPersistenceError(), getStatus(), and finalize().
🤖 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 @.aiox-core/core/orchestration/master-orchestrator.js:
- Around line 1133-1136: The persisted persistence snapshot is built from
this._persistenceAvailable and this._persistenceError before those flags are
reset after writeJson, so a successful retry can still write a stale {
available: false, lastError: ... } to disk; fix by ensuring the snapshot
reflects the post-save state: either reset/clear this._persistenceAvailable and
this._persistenceError before constructing the persistence object, or
(preferably) only update the persisted snapshot after writeJson succeeds (i.e.,
set persistence.available = true and persistence.lastError = null and then
writeJson), making the change around the writeJson call in
master-orchestrator.js where persistence is assembled and flags are reset.
---
Nitpick comments:
In `@tests/core/master-orchestrator.test.js`:
- Around line 291-310: After mocking fs.writeJson to fail once and asserting
degradation, add a recovery step: change the spy (writeJsonSpy) to resolve
successfully for a subsequent call (e.g., mockResolvedValueOnce or replace the
mock) and invoke orchestrator.saveState() again, then assert
orchestrator.isPersistenceAvailable() is true,
orchestrator.getPersistenceError() is null/empty, and that
orchestrator.getStatus().persistence and orchestrator.finalize().persistence
reflect available: true with no error; keep using the same writeJsonSpy and
restore it in the finally block as before and locate behavior around
orchestrator.saveState(), orchestrator.isPersistenceAvailable(),
orchestrator.getPersistenceError(), getStatus(), and finalize().
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 39f2db55-d09b-4b64-a2cf-6ed6158ed3ca
📒 Files selected for processing (4)
.aiox-core/core/orchestration/master-orchestrator.js.aiox-core/data/entity-registry.yaml.aiox-core/install-manifest.yamltests/core/master-orchestrator.test.js
* fix(core): expose master persistence degradation * fix(core): persist recovered master health
Summary
MasterOrchestratorso failed state saves are visible through status/finalization APIs instead of only a warn log.Issue
Part of #621, specifically the concrete
MasterOrchestratorsilent-persistence-failure slice.Validation
node -c .aiox-core/core/orchestration/master-orchestrator.jsnpm test -- tests/core/master-orchestrator.test.js --runInBand— 57 passednpm run generate:manifestnpm run validate:manifestgit diff --checkAdditional battery already run on this same slice before the final one-line normalized-log adjustment:
npm run lint— pass, 0 errors / 114 baseline warningsnpm run typecheck— passnode scripts/validate-package-completeness.js— pass, 34/34node bin/utils/validate-publish.js— pass, 4199 files in packagenpm test -- --runInBand --forceExit— 330 passed suites, 11 skipped; 8347 passed tests, 149 skippedSummary by CodeRabbit
New Features
Tests