@oss-autopilot/core 3.39.1 → 3.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/cli-registry.js +105 -1
  2. package/dist/cli.bundle.cjs +163 -144
  3. package/dist/commands/daily.d.ts +6 -1
  4. package/dist/commands/daily.js +29 -6
  5. package/dist/commands/dashboard-data.js +16 -7
  6. package/dist/commands/index.d.ts +3 -0
  7. package/dist/commands/index.js +2 -0
  8. package/dist/commands/scout-bridge.js +23 -1
  9. package/dist/commands/setup.js +2 -1
  10. package/dist/commands/vet-list.js +18 -1
  11. package/dist/commands/vet.js +7 -1
  12. package/dist/commands/work.d.ts +134 -0
  13. package/dist/commands/work.js +313 -0
  14. package/dist/core/config-registry.js +6 -0
  15. package/dist/core/daily-logic.d.ts +2 -1
  16. package/dist/core/daily-logic.js +12 -1
  17. package/dist/core/engaged-issue-lookup.d.ts +82 -0
  18. package/dist/core/engaged-issue-lookup.js +157 -0
  19. package/dist/core/engaged-issues.d.ts +3 -3
  20. package/dist/core/engaged-issues.js +5 -5
  21. package/dist/core/gist-state-store.js +6 -2
  22. package/dist/core/index.d.ts +2 -0
  23. package/dist/core/index.js +2 -0
  24. package/dist/core/issue-conversation.d.ts +68 -21
  25. package/dist/core/issue-conversation.js +157 -75
  26. package/dist/core/machine-id.d.ts +18 -0
  27. package/dist/core/machine-id.js +131 -0
  28. package/dist/core/paths.d.ts +8 -0
  29. package/dist/core/paths.js +10 -0
  30. package/dist/core/pr-graphql.d.ts +2 -0
  31. package/dist/core/pr-graphql.js +2 -2
  32. package/dist/core/state-persistence.d.ts +8 -0
  33. package/dist/core/state-persistence.js +14 -1
  34. package/dist/core/state-schema.d.ts +54 -1
  35. package/dist/core/state-schema.js +68 -0
  36. package/dist/core/state.d.ts +39 -1
  37. package/dist/core/state.js +86 -2
  38. package/dist/core/types.d.ts +1 -1
  39. package/dist/core/work-claims.d.ts +89 -0
  40. package/dist/core/work-claims.js +196 -0
  41. package/dist/formatters/json.d.ts +130 -1
  42. package/dist/formatters/json.js +26 -0
  43. package/package.json +1 -1
@@ -6,7 +6,7 @@
6
6
  * Domain logic lives in src/core/daily-logic.ts; this file is a thin
7
7
  * orchestration layer that wires up the phases and handles I/O.
8
8
  */
9
- import { type ClosedPRStatusUpdate, type MergedPRNotes, type ReviewedPRFollowUp, type AttentionSummary, type DailyDigest, type CommentedIssue, type PRCheckFailure, type RepoGroup } from '../core/index.js';
9
+ import { type WorkClaim, type ClosedPRStatusUpdate, type MergedPRNotes, type ReviewedPRFollowUp, type AttentionSummary, type DailyDigest, type CommentedIssue, type PRCheckFailure, type RepoGroup } from '../core/index.js';
10
10
  import { type StrategyResult } from '../core/strategy.js';
11
11
  import { type DailyOutput, type DailyWarning, type CapacityAssessment, type ActionableIssue, type ActionMenu, type MergedPRListUpdate, type PendingLearnings } from '../formatters/json.js';
12
12
  export { applyStatusOverrides, computeRepoSignals, groupPRsByRepo, assessCapacity, collectActionableIssues, computeActionMenu, toShelvedPRRef, formatBriefSummary, formatSummary, printDigest, CRITICAL_STATUSES, } from '../core/index.js';
@@ -68,6 +68,11 @@ export interface DailyCheckResult {
68
68
  * Raw excerpts here; `toDailyOutput` fences them.
69
69
  */
70
70
  reviewedPRs?: ReviewedPRFollowUp[];
71
+ /**
72
+ * Live work claims (#1856, #1852). Set only when at least one exists; see
73
+ * {@link DailyOutput.workClaims}.
74
+ */
75
+ workClaims?: WorkClaim[];
71
76
  }
72
77
  /**
73
78
  * Convert a full DailyCheckResult to the compact DailyOutput for JSON serialization (#287).
@@ -6,7 +6,7 @@
6
6
  * Domain logic lives in src/core/daily-logic.ts; this file is a thin
7
7
  * orchestration layer that wires up the phases and handles I/O.
8
8
  */
9
- import { getStateManager, parseGitHubUrl, issueRefKey, PRMonitor, IssueConversationMonitor, requireGitHubToken, renderGistWarning, CRITICAL_STATUSES, applyStatusOverrides, computeRepoSignals, computeLedgerRepoSignals, GistConcurrencyError, groupPRsByRepo, assessCapacity, collectActionableIssues, computeActionMenu, collectEngagedIssues, toShelvedPRRef, formatBriefSummary, formatSummary, summarizeAttentionBuckets, shouldSuggestClose, selectClosedPRStatusCandidates, toClosedPRStatusUpdate, } from '../core/index.js';
9
+ import { getStateManager, parseGitHubUrl, issueRefKey, PRMonitor, IssueConversationMonitor, requireGitHubToken, renderGistWarning, CRITICAL_STATUSES, applyStatusOverrides, computeRepoSignals, computeLedgerRepoSignals, GistConcurrencyError, groupPRsByRepo, assessCapacity, collectActionableIssues, computeActionMenu, collectEngagedIssues, toShelvedPRRef, formatBriefSummary, formatSummary, summarizeAttentionBuckets, shouldSuggestClose, selectClosedPRStatusCandidates, toClosedPRStatusUpdate, activeWorkClaims, finishedImplementations, } from '../core/index.js';
10
10
  import { errorMessage, isRateLimitOrAuthError } from '../core/errors.js';
11
11
  import { DEFAULT_CONCURRENCY, runWorkerPool } from '../core/concurrency.js';
12
12
  import { wrapUntrustedContent } from '../core/untrusted-content.js';
@@ -54,6 +54,25 @@ function successorGapsFor(pr, gaps) {
54
54
  * Retrieves open PRs, merged/closed counts, recently closed/merged PRs, and
55
55
  * issue conversation data — all in parallel where possible.
56
56
  */
57
+ /**
58
+ * Record the issue monitor's non-fatal notes under the fetch phase (#1862):
59
+ * its warnings (a gone issue, a truncated thread, issues past the
60
+ * comment-fetch cap) and, under their own operation, the engaged issues
61
+ * whose batched lookup failed and so were not checked at all this run. The
62
+ * per-issue detail is in `failures`; the rollup below counts them too.
63
+ */
64
+ function recordIssueMonitorNotes(warnings, result) {
65
+ for (const message of result.warnings) {
66
+ warnings.push({ phase: 'fetch', operation: 'fetch commented issues', message });
67
+ }
68
+ if (result.lookupFailures > 0) {
69
+ warnings.push({
70
+ phase: 'fetch',
71
+ operation: 'look up engaged issues',
72
+ message: `${result.lookupFailures} engaged issue lookup(s) failed; those issues were not checked this run`,
73
+ });
74
+ }
75
+ }
57
76
  async function fetchPRData(prMonitor, token, warnings) {
58
77
  // Fetch all open PRs fresh from GitHub
59
78
  const fetchResult = await prMonitor.fetchUserOpenPRs();
@@ -143,13 +162,12 @@ async function fetchPRData(prMonitor, token, warnings) {
143
162
  return {
144
163
  issues: [],
145
164
  failures: [{ issueUrl: 'N/A', error: `Issue conversation fetch failed: ${msg}` }],
165
+ lookupFailures: 0,
146
166
  warnings: [],
147
167
  };
148
168
  });
149
- const { issues: commentedIssues, warnings: issueMonitorWarnings } = issueConversationResult;
150
- for (const message of issueMonitorWarnings) {
151
- warnings.push({ phase: 'fetch', operation: 'fetch commented issues', message });
152
- }
169
+ const { issues: commentedIssues } = issueConversationResult;
170
+ recordIssueMonitorNotes(warnings, issueConversationResult);
153
171
  if (issueConversationResult.failures.length > 0) {
154
172
  warnings.push({
155
173
  phase: 'fetch',
@@ -502,12 +520,15 @@ function generateDigestOutput(digest, activePRs, shelvedPRs, commentedIssues, fa
502
520
  // Close candidates are usually dormant and auto-shelved, so count them over
503
521
  // all open PRs (digest.openPRs includes shelved), not activePRs.
504
522
  const closeSuggested = digest.openPRs.filter(shouldSuggestClose).length;
523
+ // Live claims (#1856): read, never written, so an expired claim stays in
524
+ // state until the next `work` write prunes it.
525
+ const workClaims = activeWorkClaims(stateManager.getState().workClaims ?? []);
505
526
  const actionMenu = computeActionMenu(actionableIssues, capacity, filteredCommentedIssues, { ...attention, closeSuggested }, unextractedMergeCount, closedPRStatusUpdates.length,
506
527
  // One action per entry the workflow handles on its own; covered
507
528
  // thanks-only entries ride along with their carrier.
508
529
  mergedPRNotes.filter((entry) => entry.ackCoveredBy === undefined).length,
509
530
  // Other people's PRs: a menu item, never a capacity or attention count.
510
- reviewedPRs.length);
531
+ reviewedPRs.length, finishedImplementations(workClaims).length);
511
532
  const repoGroups = groupPRsByRepo(activePRs);
512
533
  // Periodic strategy snapshot (#1270 Step 2). Cadence-gated to fire every
513
534
  // 30 days OR after 5+ PRs merge since the last snapshot, whichever comes
@@ -540,6 +561,7 @@ function generateDigestOutput(digest, activePRs, shelvedPRs, commentedIssues, fa
540
561
  failures,
541
562
  warnings,
542
563
  strategySummary,
564
+ ...(workClaims.length > 0 && { workClaims }),
543
565
  };
544
566
  }
545
567
  const CLOSED_PR_STATUS_OPERATION = 'closed-PR status updates';
@@ -768,6 +790,7 @@ export function toDailyOutput(result) {
768
790
  ...(result.closedPRStatusUpdates && { closedPRStatusUpdates: result.closedPRStatusUpdates }),
769
791
  ...(result.mergedPRNotes && { mergedPRNotes: result.mergedPRNotes.map((entry) => fenceMergedPRNotes(entry)) }),
770
792
  ...(result.reviewedPRs && { reviewedPRs: result.reviewedPRs.map((entry) => fenceReviewedPR(entry)) }),
793
+ ...(result.workClaims && { workClaims: result.workClaims }),
771
794
  };
772
795
  }
773
796
  /**
@@ -166,12 +166,20 @@ export function updateMonthlyAnalytics(prs, monthlyCounts, monthlyClosedCounts,
166
166
  return failures;
167
167
  }
168
168
  /**
169
- * The partial-data banner entry for the issue monitor's notices (#1862): the
170
- * direct-fetch cap, a gone issue, a truncated thread. The monitor already
171
- * logged each one; the banner lists operations, so they collapse to one label.
169
+ * The partial-data banner entries for the issue monitor's non-fatal notes
170
+ * (#1862). Its warnings (a gone issue, a truncated thread, an engagement
171
+ * time that does not parse, issues past the comment-fetch cap) collapse to
172
+ * one label: the monitor already logged each one, and the banner lists
173
+ * operations. Engaged issues whose batched lookup failed were not checked
174
+ * at all this run, so they get their own label.
172
175
  */
173
- function engagedScanLabels(issueMonitorWarnings) {
174
- return issueMonitorWarnings.length > 0 ? ['scan engaged issues'] : [];
176
+ function engagedScanLabels(result) {
177
+ const labels = [];
178
+ if (result.lookupFailures > 0)
179
+ labels.push('look up engaged issues');
180
+ if (result.warnings.length > 0)
181
+ labels.push('scan engaged issues');
182
+ return labels;
175
183
  }
176
184
  /**
177
185
  * Fetch fresh dashboard data from GitHub.
@@ -263,11 +271,12 @@ export async function fetchDashboardData(token) {
263
271
  return {
264
272
  issues: [],
265
273
  failures: [{ issueUrl: 'N/A', error: `Issue conversation fetch failed: ${msg}` }],
274
+ lookupFailures: 0,
266
275
  warnings: [],
267
276
  };
268
277
  });
269
- const { issues: commentedIssues, warnings: issueMonitorWarnings } = fetchedIssues;
270
- partialFailures.push(...engagedScanLabels(issueMonitorWarnings));
278
+ const { issues: commentedIssues } = fetchedIssues;
279
+ partialFailures.push(...engagedScanLabels(fetchedIssues));
271
280
  if (fetchedIssues.failures.length > 0) {
272
281
  warn(MODULE, `${fetchedIssues.failures.length} issue conversation check(s) failed`);
273
282
  }
@@ -50,6 +50,8 @@ export { runMove } from './move.js';
50
50
  export { runDismiss } from './dismiss.js';
51
51
  /** Restore a dismissed issue to notifications. */
52
52
  export { runUndismiss } from './dismiss.js';
53
+ /** Work claims (#1856, #1852): record, finish, release and list in-flight implementations and PR work. */
54
+ export { runWorkClaim, runWorkFinish, runWorkRelease, runWorkList } from './work.js';
53
55
  /** Fetch comments for tracked issues/PRs. */
54
56
  export { runComments } from './comments.js';
55
57
  /** Post a comment to a GitHub issue or PR. */
@@ -104,6 +106,7 @@ export type { ConfigOutput, DetectFormattersOutput, ParseIssueListOutput, Parsed
104
106
  export type { MoveOutput, MoveTarget } from './move.js';
105
107
  export type { GuidelinesListOutput, GuidelinesViewOutput, GuidelinesStoreOutput, GuidelinesResetOutput, FetchCorpusOutput, } from './guidelines.js';
106
108
  export type { DismissOutput, UndismissOutput } from './dismiss.js';
109
+ export type { WorkClaimOptions, WorkClaimOutcome, WorkClaimOutput, WorkFinishOptions, WorkFinishOutput, WorkReleaseOptions, WorkReleaseOutput, WorkListOutput, } from './work.js';
107
110
  export type { InitOutput } from './init.js';
108
111
  export type { ConfigSetOutput, ConfigCommandOutput } from './config.js';
109
112
  export type { SetupSetOutput, SetupCompleteOutput, SetupRequiredOutput, SetupOutput, CheckSetupOutput, } from './setup.js';
@@ -52,6 +52,8 @@ export { runMove } from './move.js';
52
52
  export { runDismiss } from './dismiss.js';
53
53
  /** Restore a dismissed issue to notifications. */
54
54
  export { runUndismiss } from './dismiss.js';
55
+ /** Work claims (#1856, #1852): record, finish, release and list in-flight implementations and PR work. */
56
+ export { runWorkClaim, runWorkFinish, runWorkRelease, runWorkList } from './work.js';
55
57
  // ── Issue & Comment Management ──────────────────────────────────────────────
56
58
  /** Fetch comments for tracked issues/PRs. */
57
59
  export { runComments } from './comments.js';
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import { reposAtCap } from '../core/repo-cap.js';
6
6
  import { createScout } from '@oss-scout/core';
7
- import { getStateManager, isLinkedPRStalled, parseGitHubUrl, requireGitHubToken } from '../core/index.js';
7
+ import { activeWorkClaims, getStateManager, isLinkedPRStalled, parseGitHubUrl, requireGitHubToken, } from '../core/index.js';
8
8
  import { SearchRotationSchema } from '../core/state-schema.js';
9
9
  import { computeStrategy } from '../core/strategy.js';
10
10
  import { loadSkippedIssuesDetailed } from './skip-file-parser.js';
@@ -104,6 +104,7 @@ export function buildScoutState(diagnostics) {
104
104
  if (skippedUrls.has(url) || !ISSUE_URL_PATTERN.test(url))
105
105
  continue;
106
106
  const parsed = parseGitHubUrl(url);
107
+ skippedUrls.add(url);
107
108
  skippedIssues.push({
108
109
  url,
109
110
  repo: parsed ? `${parsed.owner}/${parsed.repo}` : '',
@@ -115,6 +116,27 @@ export function buildScoutState(diagnostics) {
115
116
  permanent: true,
116
117
  });
117
118
  }
119
+ // Issues under a live implementation claim (#1856) are skipped the way
120
+ // issues with a linked PR are: a session is already building the fix, here
121
+ // or on another machine. Only live claims are forwarded, so the issue comes
122
+ // back once the claim is released or expires. `pr` claims sit on PR URLs,
123
+ // which scout cannot surface.
124
+ const liveClaims = activeWorkClaims(state.workClaims ?? []);
125
+ for (const claim of liveClaims) {
126
+ if (claim.kind !== 'implementation' || skippedUrls.has(claim.url) || !ISSUE_URL_PATTERN.test(claim.url))
127
+ continue;
128
+ const parsed = parseGitHubUrl(claim.url);
129
+ skippedUrls.add(claim.url);
130
+ skippedIssues.push({
131
+ url: claim.url,
132
+ repo: parsed ? `${parsed.owner}/${parsed.repo}` : '',
133
+ number: parsed?.number ?? 0,
134
+ title: '',
135
+ skippedAt: claim.startedAt,
136
+ reason: `implementation in progress (session ${claim.session})`,
137
+ permanent: true,
138
+ });
139
+ }
118
140
  // Strategy-derived personalization (#1464). `computeStrategy` returns null
119
141
  // below the merged-PR floor — empty lists then read as "no bias" on scout's
120
142
  // side. Baking the bias into the preferences (rather than only per-call
@@ -70,7 +70,8 @@ export async function runSetup(options) {
70
70
  }
71
71
  case 'maxActivePRs':
72
72
  case 'maxOpenPRsPerRepo':
73
- case 'maxOpenPRsColdRepo': {
73
+ case 'maxOpenPRsColdRepo':
74
+ case 'maxConcurrentImplementations': {
74
75
  const limit = parseNonNegativeInt(value, key);
75
76
  stateManager.updateConfig({ [key]: limit });
76
77
  results[key] = String(limit);
@@ -9,7 +9,7 @@ import { detectIssueList } from './startup.js';
9
9
  import { computeSuccessGrade, gradeFromCandidate, reconcileRecommendation } from '../core/issue-grading.js';
10
10
  import { repoCapField } from '../core/repo-cap.js';
11
11
  import { ValidationError } from '../core/errors.js';
12
- import { getStateManager, classifyLinkedPR, pickSnapshotFromVet, persistPickSnapshots, traitsFromVerification, isFirstInRepo, getOctokit, requireGitHubToken, parseGitHubUrl, verifyIssuesBatch, RULED_OUT_VERDICTS, } from '../core/index.js';
12
+ import { getStateManager, classifyLinkedPR, pickSnapshotFromVet, persistPickSnapshots, traitsFromVerification, isFirstInRepo, getOctokit, requireGitHubToken, parseGitHubUrl, verifyIssuesBatch, RULED_OUT_VERDICTS, workClaimVetFields, } from '../core/index.js';
13
13
  const UNKNOWN_GRADE = computeSuccessGrade({ avgResponseDays: null, mergeRate: null, daysSinceLastCommit: null });
14
14
  const KNOWN_SKIP_REASONS = new Set([
15
15
  'issue_closed',
@@ -261,6 +261,23 @@ export async function runVetList(options = {}) {
261
261
  };
262
262
  }
263
263
  async function processItem(item, verification) {
264
+ // A fix for this issue is already being built in some session (#1856):
265
+ // file it as claimed without grading it, the way a linked PR rules an
266
+ // issue out. The row comes back once the claim is released or expires.
267
+ const claimed = workClaimVetFields(getStateManager().getState().workClaims ?? [], item.url);
268
+ if (claimed) {
269
+ return {
270
+ issue: { repo: item.repo, number: item.number, title: item.title, url: item.url, labels: [] },
271
+ recommendation: 'skip',
272
+ reasonsToApprove: [],
273
+ reasonsToSkip: claimed.reasonsToSkip,
274
+ projectHealth: {},
275
+ vettingResult: {},
276
+ grade: UNKNOWN_GRADE,
277
+ listStatus: 'claimed',
278
+ workClaim: claimed.workClaim,
279
+ };
280
+ }
264
281
  // No authoritative verdict for this row: either verify errored, or the URL
265
282
  // was never enrolled (parse-list also accepts PR URLs, which `verify-issue`
266
283
  // can't classify). Either way `listStatus` falls back to scout's heuristic,
@@ -6,7 +6,7 @@ import { adaptScoutLinkedPR, buildCandidateLinkedPR, createAutopilotScout } from
6
6
  import { ISSUE_URL_PATTERN, validateGitHubUrl, validateUrl } from './validation.js';
7
7
  import { gradeFromCandidate, reconcileRecommendation } from '../core/issue-grading.js';
8
8
  import { repoCapField } from '../core/repo-cap.js';
9
- import { getStateManager, getOctokit, classifyLinkedPR, pickSnapshotFromVet, persistPickSnapshots, fetchIssueVerification, RULED_OUT_VERDICTS, traitsFromVerification, isFirstInRepo, requireGitHubToken, errorMessage, warn, } from '../core/index.js';
9
+ import { getStateManager, getOctokit, classifyLinkedPR, pickSnapshotFromVet, persistPickSnapshots, fetchIssueVerification, RULED_OUT_VERDICTS, traitsFromVerification, isFirstInRepo, requireGitHubToken, errorMessage, warn, workClaimVetFields, } from '../core/index.js';
10
10
  /**
11
11
  * Vet a specific GitHub issue for claimability and project health.
12
12
  *
@@ -51,6 +51,12 @@ export async function runVet(options) {
51
51
  grade,
52
52
  ...repoCapField(getStateManager().getState(), candidate.issue.repo),
53
53
  };
54
+ // A fix already being built somewhere (#1856) overrides the grade: the
55
+ // issue is skipped like one with a linked PR, and no pick is recorded.
56
+ const claimed = workClaimVetFields(getStateManager().getState().workClaims ?? [], options.issueUrl);
57
+ if (claimed) {
58
+ return { ...output, ...claimed, reasonsToSkip: [...output.reasonsToSkip, ...claimed.reasonsToSkip] };
59
+ }
54
60
  const pick = await pickFor(output);
55
61
  return { ...output, ...(await persistPickSnapshots(getStateManager(), pick ? [pick] : [])) };
56
62
  }
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Work claim commands (#1856, #1852 gap 2): `work claim`, `work finish`,
3
+ * `work release`, `work list`.
4
+ *
5
+ * A claim records that some session is working an item, so other sessions
6
+ * (same machine or another one via the Gist) see it instead of starting the
7
+ * same work. `implementation` claims sit on issue URLs while a fix is built
8
+ * in the background; `pr` claims sit on PR URLs while a session does Tier 2
9
+ * work there. Rules live in `core/work-claims.ts`; this file validates input,
10
+ * applies the state mutation and pushes it to the Gist.
11
+ *
12
+ * Each `run*` has a `*Work(stateManager, options)` twin that takes the
13
+ * manager explicitly, so the Gist concurrency tests can drive two machines
14
+ * through the real command path.
15
+ */
16
+ import { type StateManager, type WorkClaim, type WorkClaimKind } from '../core/index.js';
17
+ import { type DailyWarning } from '../formatters/json.js';
18
+ export interface WorkClaimOptions {
19
+ url: string;
20
+ kind: WorkClaimKind;
21
+ /** Name of the session taking the claim, e.g. `air/20261102T120733-3f9a`. */
22
+ session: string;
23
+ branch?: string;
24
+ /** Checkout the implementation runs in; required for a local implementation (one implementation per checkout). */
25
+ worktree?: string;
26
+ /** Remote worker run id; required for an implementation with no local worktree. */
27
+ runId?: string;
28
+ /** Claim lifetime in hours; defaults per kind (implementation 24, pr 12). */
29
+ ttlHours?: number;
30
+ /** Replace a live claim another session holds on the item. Without it such a claim is refused. */
31
+ takeover?: boolean;
32
+ }
33
+ /** What `work claim` did to the item: nothing was there, this session renewed its own claim, or another session's claim was replaced. */
34
+ export type WorkClaimOutcome = 'claimed' | 'renewed' | 'took-over';
35
+ export interface WorkClaimOutput {
36
+ claim: WorkClaim;
37
+ outcome: WorkClaimOutcome;
38
+ /**
39
+ * False when the claim exists on this machine only: the Gist push failed
40
+ * (`gistSyncWarning`) or Gist persistence is degraded. Other machines
41
+ * cannot see it, so a workflow should not treat the item as reserved.
42
+ */
43
+ synced: boolean;
44
+ /** Set when the post-mutation Gist checkpoint failed; the local mutation succeeded (#1370). */
45
+ gistSyncWarning?: string;
46
+ }
47
+ export interface WorkFinishOptions {
48
+ url: string;
49
+ /** When given, the live claim must belong to this session; a mismatch is refused instead of finishing someone else's run. */
50
+ session?: string;
51
+ }
52
+ export interface WorkFinishOutput {
53
+ url: string;
54
+ /** The claim as marked finished, or null when no live claim exists on the item. */
55
+ claim: WorkClaim | null;
56
+ gistSyncWarning?: string;
57
+ }
58
+ export interface WorkReleaseOptions {
59
+ url?: string;
60
+ /** Release every claim this session holds (optionally only `kind`). */
61
+ session?: string;
62
+ kind?: WorkClaimKind;
63
+ }
64
+ export interface WorkReleaseOutput {
65
+ /** URLs of the live claims released, in stored order. */
66
+ released: string[];
67
+ gistSyncWarning?: string;
68
+ }
69
+ export interface WorkListOutput {
70
+ /** Live claims, in stored order. */
71
+ claims: WorkClaim[];
72
+ /** Stored claims past `expiresAt`; pruned by the next claim write. */
73
+ expiredCount: number;
74
+ /** When the list was computed; `expiresAt` values compare against this. */
75
+ now: string;
76
+ /** Set when the list comes from a stale copy: the Gist refresh failed, so another machine's claims may be missing (#1193). */
77
+ warnings?: DailyWarning[];
78
+ }
79
+ /**
80
+ * Take (or renew) a claim on an item (#1856, #1852).
81
+ *
82
+ * An implementation claim needs a `worktree` or a `runId` so the
83
+ * one-implementation-per-checkout rule has something to compare, and it is
84
+ * refused when `maxConcurrentImplementations` running implementations
85
+ * already exist or another live implementation uses the same checkout on
86
+ * this machine. A live claim another session holds is refused unless `takeover`
87
+ * is set (the workflow asks first); this session's own claim is renewed.
88
+ *
89
+ * In Gist mode the checks run again on the Gist's copy when the push
90
+ * conflicts with another machine: if that copy refuses the claim, nothing is
91
+ * recorded and the refusal is thrown. The claim is `synced: false` when it
92
+ * exists locally only.
93
+ *
94
+ * @throws {ValidationError} On a malformed URL or kind mismatch, a missing
95
+ * location for an implementation, an out-of-range TTL, or when another
96
+ * session's claim, the cap or the checkout rule blocks the claim.
97
+ */
98
+ export declare function runWorkClaim(options: WorkClaimOptions): Promise<WorkClaimOutput>;
99
+ /** {@link runWorkClaim} against an explicit manager. */
100
+ export declare function claimWork(stateManager: StateManager, options: WorkClaimOptions): Promise<WorkClaimOutput>;
101
+ /**
102
+ * Mark the live claim on `url` finished (#1856): the implementation's branch
103
+ * is ready to collect. The claim stays (with its expiry extended to at least
104
+ * a week) until it is released or expires, so the action menu can offer
105
+ * "Collect finished implementations" and search keeps skipping the issue.
106
+ * With `session`, a claim another session holds is refused rather than
107
+ * finished on its behalf.
108
+ *
109
+ * @throws {ValidationError} When `session` is given and the live claim belongs to another session.
110
+ */
111
+ export declare function runWorkFinish(options: WorkFinishOptions): Promise<WorkFinishOutput>;
112
+ /** {@link runWorkFinish} against an explicit manager. */
113
+ export declare function finishWork(stateManager: StateManager, options: WorkFinishOptions): Promise<WorkFinishOutput>;
114
+ /**
115
+ * Drop claims (#1856, #1852): the claim on `url`, or every claim `session`
116
+ * holds (Session End releases that session's `pr` claims with
117
+ * `{ session, kind: 'pr' }`). Releasing an item nobody holds is not an
118
+ * error: `released` is simply empty.
119
+ *
120
+ * @throws {ValidationError} When neither `url` nor `session` is given.
121
+ */
122
+ export declare function runWorkRelease(options: WorkReleaseOptions): Promise<WorkReleaseOutput>;
123
+ /** {@link runWorkRelease} against an explicit manager. */
124
+ export declare function releaseWork(stateManager: StateManager, options: WorkReleaseOptions): Promise<WorkReleaseOutput>;
125
+ /**
126
+ * The live claims (#1856). Read-only: expired claims are counted, not
127
+ * pruned. In Gist mode the state is refreshed first (throttled to once per
128
+ * 30 s by the store; a failed fetch serves the cached copy and sets a
129
+ * `warnings` entry) so a claim another machine pushed since this process
130
+ * loaded state is visible.
131
+ */
132
+ export declare function runWorkList(): Promise<WorkListOutput>;
133
+ /** {@link runWorkList} against an explicit manager. */
134
+ export declare function listWork(stateManager: StateManager): Promise<WorkListOutput>;