Repository navigation
Closed
Labels
cliCLI commands and interfacecomplexHigh complexity featureenhancementNew feature or requestplannedImplementation plan approvedready-for-reviewReady for code review
Description
Problem
sequant status reads exclusively from .sequant/state.json, a local snapshot frozen at run time. It never reconciles with GitHub, causing persistent staleness:
- Titles are generic — state stores
"title": "Issue #390"instead of real GitHub titles - No awareness of untracked issues — issues on GitHub that haven't been through
sequant runare invisible - PR state goes stale — a PR merged in the browser stays
ready_for_mergein state until--cleanupis manually run - Issue open/closed state ignored — issues closed on GitHub still show as
in_progress - Worktree existence not verified — deleted worktrees still listed
- MCP
sequant_statustool has the same problem — returns raw state.json data without reconciliation
The --cleanup and --rebuild flags exist but require manual invocation. Users expect sequant status to show current reality, not a stale cache.
Design
Core principle: reconcile on read
Follow the pattern established by every well-designed CLI (gh, kubectl, docker ps, Terraform):
Current: state.json → render
Proposed: state.json + GitHub API + filesystem → reconcile → render
Data source ownership
Split data by authoritative source:
| Data | Source of truth | Rationale |
|---|---|---|
| Issue title, open/closed, labels | GitHub API | Changes outside sequant |
| PR state (open/merged/closed) | GitHub API | Merges happen in browser |
| Phase progress, QA verdict, ACs | state.json | Sequant-specific |
| Worktree existence | Filesystem | Can be deleted manually |
| Run in progress | Run registry | Process-level truth |
Reconciliation behavior
On every sequant status invocation:
- Read state.json — fast, local, sequant-specific data
- Batch query GitHub — single
ghcall for all tracked issue/PR states (not N+1 queries) - Check filesystem — verify worktree paths exist
- Auto-heal unambiguous drift:
- PR merged on GitHub → status =
merged - Issue closed on GitHub → status =
abandoned(ormergedif PR was merged) - Worktree path missing → clear worktree field, note in output
- PR merged on GitHub → status =
- Flag ambiguous drift — e.g., issue still open but worktree deleted and no PR exists
- Write back — persist reconciled state so subsequent reads start closer to truth
Staleness communication
Following Kubernetes conditions pattern and Temporal's relative timestamps:
- Always show
Last synced: 2 minutes agowith relative timestamps - Show data age per-issue when GitHub is unreachable (offline mode)
--offlineflag to skip GitHub queries (pure state.json, current behavior)
Next-action hints
Following git status gold standard — tell the user what to do next:
#413 Spec skill: Design Review qa failed → sequant run 413 --phase qa
#404 Default execution mode ready to merge → gh pr merge 419
#422 AC parser: bold format not tracked → sequant run 422
Acceptance Criteria
- AC-1:
sequant statusfetches live issue titles, open/closed state, and PR merge state from GitHub on every invocation (batch query, not N+1) - AC-2: Unambiguous drift is auto-healed: merged PRs update status to
merged, closed issues update toabandoned, missing worktrees clear the worktree field - AC-3: Each issue row shows a next-action hint based on current state (e.g., "run qa", "merge PR", "start run")
- AC-4: Relative timestamps shown for last activity (
2 hours ago) with aLast syncedindicator - AC-5:
--offlineflag preserves current behavior (pure state.json, no GitHub queries) for air-gapped or rate-limited scenarios - AC-6: MCP
sequant_statustool returns reconciled data (same logic as CLI), not raw state.json - AC-7: GitHub query failure degrades gracefully — shows cached data with a staleness warning, does not error out
- AC-8: Batch GitHub queries complete in <2s for up to 20 tracked issues (use GraphQL or single
ghcall with multiple issue numbers) - AC-9: Existing
--cleanup,--rebuild,--jsonflags continue to work unchanged - AC-10: Ambiguous drift (e.g., worktree deleted but issue still open, no PR) is flagged to the user rather than silently auto-healed
Design references
Industry patterns informing this design:
- Terraform
plan -refresh-only— reconcile local state against remote truth on read, present drift as diff, require confirmation for ambiguous changes gh pr status— always live, GitHub API is sole source of truth, zero local state for issue/PR datakubectl get— always queries API server live, never serves cached resource stategit status— gold standard for suggesting next actions based on current state- Kubernetes conditions — timestamped observations with
lastTransitionTimefor staleness detection - Fly.io
fly status—--watchfor continuous monitoring, graceful degradation
Implementation notes
- The existing
refreshMergedStatuses()instatus.ts:45-62already does a subset of this (PR merge detection forready_for_mergeissues). Extend this pattern to cover all reconciliation. checkPRMergeStatus()inpr-status.tsqueries one PR at a time viagh pr view. Replace with batch GraphQL query for performance.- The
reconcileStateAtStartup()function instate-cleanup.tsis a lightweight version of what we need. Consider unifying these reconciliation paths. state-manager.tsalready has atomic write support (temp file + rename + file locking) — reconciliation writes go through this.- The MCP tool in
src/mcp/tools/status.tscurrently returns raw state. Wire it through the same reconciliation pipeline. - Phase progress, QA verdicts, and AC data remain authoritative in state.json — GitHub reconciliation only touches status, title, PR state, and worktree existence.
Out of scope
- Showing untracked GitHub issues (issues that have never been through
sequant run). This would require querying all open issues and filtering, which is a different UX pattern (closer tosequant assess). Could be a follow-up. --watchmode for continuous polling. Valuable but separate concern.- Displaying AC items, scope assessment, or loop iteration in status output. These are display enhancements orthogonal to reconciliation.
Metadata
Metadata
Assignees
Labels
cliCLI commands and interfacecomplexHigh complexity featureenhancementNew feature or requestplannedImplementation plan approvedready-for-reviewReady for code review
Activity
admarble commentedon Mar 25, 2026
Spec Plan — Issue #423
AC Quality Check
9/10 AC items clear and testable. AC-8 ("<2s for 20 issues") is environment-dependent — test should measure and log but use generous threshold in CI.
Scope Assessment
Non-Goals (from issue)
--watchmode for continuous pollingAcceptance Criteria with Verification
Last syncedindicator--offlineflag skips GitHub queriessequant_statusreturns reconciled data--cleanup,--rebuild,--jsonunchangedDerived ACs:
refreshMergedStatuses()+reconcileStateAtStartup()into reconciliation moduleImplementation Plan
Phase 1: Batch GitHub Reconciliation Engine (AC-1, AC-7, AC-8)
batchFetchIssueAndPRStatus()toGitHubProvider— single GraphQL query with REST fallbacksrc/lib/workflow/reconcile.ts—reconcileState()orchestrates batch query → filesystem check → drift detection → state updatePhase 2: Auto-heal & Drift Detection (AC-2, AC-10)
3. Implement drift classification — unambiguous (auto-heal) vs ambiguous (warn user)
Phase 3: Display Enhancements (AC-3, AC-4)
4. Add
getNextActionHint()+ hint column to table output5. Add
Last syncedfooter indicatorPhase 4: Offline Mode & CLI Wiring (AC-5, AC-9)
6. Add
--offlineflag, wire through reconciliation, preserve existing flagsPhase 5: MCP Integration (AC-6)
7. Wire MCP status tool through
reconcileState()Design Review
src/lib/workflow/reconcile.tsfor the engine; display changes insrc/commands/status.ts; batch query inGitHubProviderreconcileState()function called at top ofstatusCommand()and MCP handler. No daemon, no caching layer, no event system.refreshMergedStatuses()(status.ts:45-62) andreconcileStateAtStartup()(state-cleanup.ts:251-331)Conflict Risk
src/mcp/tools/status.tsbin/cli.tsRecommended Workflow
Phases: spec → testgen → exec → qa
Quality Loop: enabled (auto — scope warning, 10 ACs)
Open Questions
lastSyncedtoWorkflowStateadmarble commentedon Mar 25, 2026
Test Stubs Generated
Unit Test Stubs
File:
src/lib/workflow/reconcile.test.tsTotal: 31 unit test stubs
Integration Test Stubs
File:
__tests__/integration/status-reconcile.integration.test.tsTotal: 15 integration test stubs
Assumptions to validate before implementation:
ghCLI is authenticated and available in test environmentlastSyncedfield (schema update may be needed)Next steps:
throw new Error(...)with actual test logic)/exec 423to implement the featurenpm testGenerated with Claude Code
feat(#423): reconcile sequant status with GitHub on every read
admarble commentedon Mar 25, 2026
Exec Phase Complete — PR #428
AC Coverage
Key Files
src/lib/workflow/reconcile.ts— Reconciliation engine (classifyDrift, getNextActionHint, formatRelativeTime, reconcileState)src/lib/workflow/platforms/github.ts— batchFetchIssueAndPRStatus() batch GraphQL methodsrc/commands/status.ts— Replaced refreshMergedStatuses with reconcileStatesrc/mcp/tools/status.ts— Wired through reconciliation pipelinesrc/lib/workflow/state-schema.ts— Added lastSynced to WorkflowStatebin/cli.ts— Added --offline flagQuality
Quality Plan Alignment
N/A — No quality plan in issue
PR: #428
admarble commentedon Mar 25, 2026
QA Review for Issue #423
AC Coverage
batchFetchIssueAndPRStatusbuilds single GraphQL query with aliases; test verifies exactly 1 call for multiple issuesmerged, closed issues →abandoned, missing worktrees → cleared; precedence correct (merged > abandoned)getNextActionHintcovers all 7 statuses; hints include specific commands (sequant run N,gh pr merge N)formatRelativeTimehandles minutes/hours/days/unknown/future;lastSyncedfooter shown in status output--offlineflagbin/cli.ts, wired throughreconcileState({ offline: true }), skips GitHub queriessequant_statusreconciled dataregisterStatusToolcallsreconcileState()before reading state; returnslastSynced,githubReachable,warningsbatchFetchIssueAndPRStatussetsgithubReachable=false, proceeds with cached data, shows warningspawnSyncwith 15s timeout; no N+1 pattern--cleanup,--rebuild,--jsonunchanged--rebuild/--cleanupbefore reconciliation; JSON output enriched withnextAction/lastSyncedambiguouswarning; abandoned locally + open on GitHub →flag_status_mismatchCoverage: 10/10 AC items fully met
Quality Plan Verification
N/A - No quality plan found in issue comments
CI Status
build (20.x)build (22.x)typecheckvalidate-skillsvalidate-pluginCI Summary: 5 passed, 0 pending, 0 failed
Quality Metrics
any)Test Coverage Analysis
src/lib/workflow/reconcile.tsreconcile.test.ts(30 tests)src/commands/status.tssrc/lib/workflow/platforms/github.tsspawnSyncforgh)src/mcp/tools/status.tssrc/lib/workflow/state-schema.tssrc/lib/workflow/state-utils.tsbin/cli.tsCHANGELOG.mdCoverage: 1/4 changed source files have direct tests (reconcile.ts covers core logic)
Code Review
Strengths:
reconcile.ts) is independent of display (status.ts) and MCP (status.ts)lastSyncedpersisted to state enables future staleness trackingstate-utils.tsproperly rename conflicting types fromstate-cleanup.tsIssues:
Suggestions (non-blocking):
batchFetchIssueAndPRStatusmethod is synchronous (usesspawnSync). Consider making it async withspawnfor better UX on slow networks — but this is fine for v1reconcileStatefunction creates a newGitHubProvider()on every call. For the current single-use pattern this is fine, but if called repeatedly it could be passed as a parameterTest Quality Review
GitHubProvidermocked (external dependency); filesystem used directlyAnti-Pattern Detection
Code Patterns
No anti-patterns detected:
awaitin loops (worktree check uses syncexistsSync, appropriate for local paths)Call-Site Review
New exported functions detected: 4
classifyDrift()reconcile.ts:286getNextActionHint()status.ts:235,410,418,440,mcp/status.ts:87formatRelativeTime()status.ts:184,366,459reconcileState()status.ts:56,mcp/status.ts:50CLI Registration Verification
Option files modified: Yes (
bin/cli.ts)offlineoptions.offline(status.ts:57,77,367,460)--offlinein bin/cli.tsVerification Status: Passed
Execution Evidence
N/A - No scripts modified; CLI changes are additive option only
CHANGELOG Verification
Result: CHANGELOG requirements met
Self-Evaluation
gh repo viewwhich handles itVerdict: READY_FOR_MERGE
All 10 AC items are met. Implementation is clean, well-tested (30 tests), and follows the reconcile-on-read pattern specified in the issue design. GraphQL batch query avoids N+1, drift classification correctly separates unambiguous (auto-heal) from ambiguous (warn user), and MCP tool uses the same reconciliation pipeline.
Documentation
Next Steps
batchFetchIssueAndPRStatusif latency becomes an issueDocumentation: Before merging, run
/docs 423to generate feature documentation.admarble commentedon Mar 25, 2026
QA Review for Issue #423
AC Coverage
batchFetchIssueAndPRStatusbuilds single GraphQL query with aliases; test verifies exactly 1 call for multiple issuesmerged, closed issues →abandoned, missing worktrees → cleared; precedence correct (merged > abandoned)getNextActionHintcovers all 7 statuses; hints include specific commandsformatRelativeTimehandles minutes/hours/days/unknown/future;lastSyncedfooter in output--offlineflagbin/cli.ts, wired throughreconcileState({ offline: true })sequant_statusreconciled dataregisterStatusToolcallsreconcileState()before reading state; returnslastSynced,githubReachable,warningsbatchFetchIssueAndPRStatussetsgithubReachable=false, proceeds with cached dataspawnSyncwith 15s timeout; no N+1 pattern--cleanup,--rebuild,--jsonunchanged--rebuild/--cleanupbefore reconciliation; JSON output enriched withnextAction/lastSyncedambiguouswarning; abandoned locally + open on GitHub →flag_status_mismatchCoverage: 10/10 AC items fully met
Quality Plan Verification
N/A - No quality plan found in issue comments
CI Status
build (20.x)build (22.x)typecheckvalidate-skillsvalidate-pluginCI Summary: 5 passed, 0 pending, 0 failed
Quality Metrics
any)Test Coverage Analysis
src/lib/workflow/reconcile.tsreconcile.test.ts(30 tests)src/commands/status.tssrc/lib/workflow/platforms/github.tsspawnSyncwrappersrc/mcp/tools/status.tssrc/lib/workflow/state-schema.tssrc/lib/workflow/state-utils.tsbin/cli.ts.option()additionCHANGELOG.mdCoverage: 1/4 changed source files have direct tests. Core reconciliation logic is well-tested; untested files are thin wrappers/rendering.
Critical paths without tests: None
Code Review
Strengths:
reconcile.ts), display (status.ts), and MCP (status.ts)classifyDrift) is pure, well-typed, and independently testablelastSyncedpersisted to state enables future staleness trackingstate-utils.tshandle naming conflict cleanly (ReconcileOptions→StartupReconcileOptions)stateManager.clearCache()called after reconciliation to ensure display reads fresh dataIssues:
Suggestions (non-blocking):
batchFetchIssueAndPRStatusis synchronous (spawnSync). Fine for v1 but could be async for better UX on slow networks in a follow-upreconcileStatecreates a newGitHubProvider()on every call — acceptable for current single-use patternTest Quality Review
GitHubProvidermocked (external); filesystem used directly with temp dirsAnti-Pattern Detection
Code Patterns
No anti-patterns detected:
awaitin loops (worktreeexistsSyncis sync, appropriate for local paths)Call-Site Review
New exported functions detected: 4
reconcileState()status.ts:56,mcp/status.ts:50classifyDrift()reconcile.ts:286getNextActionHint()status.ts:235,410,418,440,mcp/status.ts:87formatRelativeTime()status.ts:184,366,459CLI Registration Verification
offlineoptions.offline(status.ts:57,77,367,460)--offlinein bin/cli.tsVerification Status: Passed
Execution Evidence
N/A - No scripts modified
CHANGELOG Verification
Result: CHANGELOG requirements met
Build Verification
N/A - Build passed
Self-Evaluation
gh repo viewoutput is already sanitizedVerdict: READY_FOR_MERGE
All 10 AC items are met. Implementation is clean, well-tested (30 tests), and follows the reconcile-on-read design specified in the issue. Key design decisions are sound: single GraphQL batch query avoids N+1, drift classification cleanly separates unambiguous (auto-heal) from ambiguous (warn), MCP tool uses the same reconciliation pipeline, and graceful degradation handles GitHub unavailability without crashing. No test regressions — the 5 test failures on the feature branch are all pre-existing (verified same failures on main).
Documentation
Next Steps
batchFetchIssueAndPRStatusfor better network latency handlingDocumentation: Before merging, run
/docs 423to generate feature documentation.fix(#423): distinguish unknown vs confirmed-open state in drift warnings
admarble commentedon Mar 25, 2026
Documentation Generated
File:
docs/features/status-reconciliation.mdSections Included:
--offlineusage)Next Steps:
Ready to merge!
docs(#423): add status reconciliation feature documentation
feat(#423): reconcile sequant status with GitHub on every read (#428)
chore(#420): resolve merge conflicts with main
chore(#421): resolve merge conflicts with origin/main
docs: generate feature docs for #325, #413, and update MCP server doc…