Repository navigation
feat(host-runtime): add archive health inspection and safe force-archive entry (Refs #424) - #614
Draft
Tericerice wants to merge 7 commits into
Draft
Tericerice wants to merge 7 commits into
Tericerice wants to merge 7 commits into
Conversation
…ive entry (BytePioneer-AI#424) - Add ArchiveHealthService to inspect inconsistent external threads (failed release, session unavailable, uncommitted provisional records, orphaned runtime entries) - Detect live codex CLI processes occupying official Codex sessions with actionable remediation hints - Provide safe force-archive entry (codexhost/archive/force) updating MappingStore metadata and detaching runtime session without deleting turns or data - Expose console RPC methods codexhost/archive/health and codexhost/archive/force with REST endpoints /api/archive/health and /api/archive/force - Add unit tests for ArchiveHealthService and RPC integration tests in console-server and app-server-host Co-Authored-By: Claude Code <noreply@anthropic.com>
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
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 |
…rchive (BytePioneer-AI#424) - Address Round 1 review findings from Codex and Pi: - Guard forceArchive: safely close loaded sessions, drain output tasks, and reject active running turns or busy background work (-32072) - Allow forceArchive to detach orphaned in-memory instances without MappingStore records - Skip already archived records during inspection, and align provisional records with 'creating' state - Refine process inspection: strictly match codex CLI executables, filter out Electron renderers/helpers and codexhost child processes, and support PowerShell on Windows - Map console REST errors to appropriate HTTP status codes (404/409/500) - Sync OpenSpec with archive health inspection and safe forced archive requirements - Fix test type errors in server.test.ts and archive-health-service.test.ts Co-Authored-By: Claude Code <noreply@anthropic.com>
…iving (BytePioneer-AI#424) Round 2 review findings from Codex and Pi: - forceArchive now rejects active turns and background work (-32072), then closes the session and drains the output task under a 60s bound; a failed or timed-out close keeps the instance loaded and returns -32075 so recovery cannot open a second writer - Console force-archive joins the per-thread request queue and idle-release operation tracking, so it can no longer interleave with Desktop requests on the same Thread - A MappingStore read failure returns -32081 instead of being mistaken for a pure in-memory orphan, which previously archived without any durable write - Process detection matches the real executable (rejecting Codex.app bundles, helpers, and any codexhost-owned process) and excludes the Host's whole process subtree - Notifications after a durable archive write are best-effort, so a dropped Desktop connection no longer reports a completed archive as failed - Tests cover close rejection, store read failure, busy threads, orphans, prewarm drafts, process recognition, and argument parsing Co-Authored-By: Claude Code <noreply@anthropic.com>
… quoted scripts (BytePioneer-AI#424) Round 3 review findings from Codex: - Reject force-archive requests whose Thread ID carries surrounding whitespace, and key the console lane by the canonical ID, so a padded ID cannot open a second per-Thread queue while operating on the same instance - Parse interpreter script arguments on quote boundaries, so `node "/opt/my tools/codex.js" app-server` is recognised as a Codex CLI - Add tests for a whitespace Thread ID through the real RPC entry point, for a close that never settles, for an output drain that never settles, and for quoted scripts Co-Authored-By: Claude Code <noreply@anthropic.com>
…PC fast (BytePioneer-AI#424) The cross-platform CI run showed the archive-health RPC test timing out on Windows: the inspection shells out to powershell/ps, which can exceed the fixture's 10s wait. Two fixes: - Summaries now carry processScan = ok | failed | skipped, so a scan that could not run is never reported as 'no official sessions occupied', and includeOfficial=false reports skipped rather than a silent zero - Bound the scan to 10s and keep the RPC integration test on includeOfficial=false, so it asserts Host routing rather than the runner's process table Co-Authored-By: Claude Code <noreply@anthropic.com>
…or mapping (BytePioneer-AI#424) Round 2 Pi findings that still applied to the head: - Persist archived=true before detaching the instance; a failed archive write returns -32081 and leaves the Thread registered, so a caller never sees 'archived' while the durable state says otherwise - Drop the never-produced occupyingPid/occupyingCommand fields and the 'official' kind from the inconsistent-thread contract - Cover the console REST error mapping (-32602 → 404, -32072 → 409, other → 500) and the archive-write failure path - Document both archive entries, their failure codes, and processScan in docs/operations/codexhost-console.md Co-Authored-By: Claude Code <noreply@anthropic.com>
…ytePioneer-AI#424) Pi's round-3 review found the identity guard checked only the Thread object, which a delegation request can revive in place by swapping thread.session while the archive write is in flight. Detaching then dropped a live native session with no owner, and the next resume would open a second writer on it. - Record the Session that was closed and only detach while the Thread still owns it; a revival now returns -32076 and keeps the live Session registered - Mirror the delete path by forgetting route observation once a Thread is detached - Exclude Desktop's own CLI copies (app/resources/codex.exe, CodexCLI.app, cached OpenAI/Codex/bin) from process detection, so Windows no longer reports Desktop's helper as an occupying process with a kill hint - Report a Mapping Store read failure from health inspection as -32081, not -32603 - Hide the PowerShell window the Windows scan spawns - Share one idle policy between idle release and forced archive - Correct the console doc that still said no Thread operations are accepted Co-Authored-By: Claude Code <noreply@anthropic.com>
Owner
|
感谢贡献!我们已关注到这个 PR,会尽快安排审查。 |
Owner
|
感谢你的贡献!想确认一下,这个 PR 当前是否已经准备好转为正式 PR(Ready for review),进入评审? 如果已经准备好,欢迎取消草稿状态;如果仍在开发、存在阻塞或希望暂缓,也欢迎简单说明当前进展,方便我们安排后续评审。谢谢! |
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
Adds archive health inspection and a safe force-archive entry point to CodexHost, so users and tools can diagnose inconsistent or failed archive states and recover threads without data loss.
Part 2 of Issue #424 resolution.
1. Archive health inspection (
codexhost/archive/health·GET /api/archive/health)creatingrecords, and in-memory instances with no persisted record. Already-archived records and healthy prewarm drafts are not reported.totalInconsistent,officialOccupied,externalRecoverable.2. Safe force-archive (
codexhost/archive/force·POST /api/archive/force)-32072.-32075, so recovery can never open a second writer on the same native session.archived=true, and emitthread/archived. No transcript, Turn mapping, or native history is modified or deleted.-32081; only a successful read returning nothing is treated as "not found" (-32602).-32602), so a padded ID cannot open a second per-Thread queue for the same instance.3. Console integration and serialization
codexhost/archive/healthandcodexhost/archive/forceadded toCONSOLE_HOST_METHODSand exposed as REST routes.200with an error envelope.4. OpenSpec and tests
openspec/specs/external-thread-list-archive-routing/spec.mdgains archive-health and forced-archive requirements and scenarios.Refs #424
🤖 Generated with Claude Code