@hearsay-tools/squawk 0.18.0-dev.6646 → 0.18.0-dev.6703
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.
- package/dist/agent-config/seed.js +1 -6
- package/dist/agent-config/seed.js.map +1 -1
- package/dist/autosave-git.js +3 -4
- package/dist/autosave-git.js.map +1 -1
- package/dist/ci-wait/controller.d.ts +37 -37
- package/dist/ci-wait/tool-catalog.js +1 -1
- package/dist/ci-wait/tool-catalog.js.map +1 -1
- package/dist/contract/attention.d.ts +8 -0
- package/dist/contract/index.js +14 -0
- package/dist/contract/runs.d.ts +15 -0
- package/dist/core/backend-detect.js +2 -1
- package/dist/core/backend-detect.js.map +1 -1
- package/dist/core/codex-hook-mapper.js +2 -1
- package/dist/core/codex-hook-mapper.js.map +1 -1
- package/dist/core/codex-ui-mapper.js +2 -2
- package/dist/core/codex-ui-mapper.js.map +1 -1
- package/dist/core/cursor-print-runner.js +2 -1
- package/dist/core/cursor-print-runner.js.map +1 -1
- package/dist/core/omp-runner.js +4 -5
- package/dist/core/omp-runner.js.map +1 -1
- package/dist/core/omp-subagent-rows.js +2 -1
- package/dist/core/omp-subagent-rows.js.map +1 -1
- package/dist/core/opencode-ui-mapper.js +2 -2
- package/dist/core/opencode-ui-mapper.js.map +1 -1
- package/dist/core/own-lookup.d.ts +5 -0
- package/dist/core/own-lookup.js +8 -0
- package/dist/core/own-lookup.js.map +1 -0
- package/dist/data-gitignore.js +2 -2
- package/dist/data-gitignore.js.map +1 -1
- package/dist/delegation/cli.js +2 -2
- package/dist/delegation/cli.js.map +1 -1
- package/dist/delegation/context.js +7 -11
- package/dist/delegation/context.js.map +1 -1
- package/dist/delegation/conversations.d.ts +4 -2
- package/dist/delegation/park-notice.d.ts +5 -1
- package/dist/delegation/park-notice.js +7 -0
- package/dist/delegation/park-notice.js.map +1 -1
- package/dist/delegation/results.js +2 -2
- package/dist/delegation/results.js.map +1 -1
- package/dist/delegation/routes.d.ts +11 -11
- package/dist/delegation/scratch-cleanup.js +6 -3
- package/dist/delegation/scratch-cleanup.js.map +1 -1
- package/dist/delegation/service.js +2 -4
- package/dist/delegation/service.js.map +1 -1
- package/dist/delegation/transport.d.ts +77 -77
- package/dist/git-command.d.ts +29 -0
- package/dist/git-command.js +27 -1
- package/dist/git-command.js.map +1 -1
- package/dist/git-worktree-lock-helper.d.ts +2 -0
- package/dist/git-worktree-lock-helper.js +12 -14
- package/dist/git-worktree-lock-helper.js.map +1 -1
- package/dist/git-worktree-lock.js +3 -10
- package/dist/git-worktree-lock.js.map +1 -1
- package/dist/home/command.js +1 -1
- package/dist/home/command.js.map +1 -1
- package/dist/jobs/cli.js +4 -2
- package/dist/jobs/cli.js.map +1 -1
- package/dist/jobs/job.d.ts +7 -0
- package/dist/jobs/job.js +32 -3
- package/dist/jobs/job.js.map +1 -1
- package/dist/project-migration/containment.js +2 -4
- package/dist/project-migration/containment.js.map +1 -1
- package/dist/project-migration/plan.js +2 -4
- package/dist/project-migration/plan.js.map +1 -1
- package/dist/release/publication.js +2 -2
- package/dist/release/publication.js.map +1 -1
- package/dist/runs/agent-tmpdir.d.ts +3 -2
- package/dist/runs/agent-tmpdir.js +11 -4
- package/dist/runs/agent-tmpdir.js.map +1 -1
- package/dist/runs/automation-runs.js +4 -3
- package/dist/runs/automation-runs.js.map +1 -1
- package/dist/runs/conversation-members.js +3 -2
- package/dist/runs/conversation-members.js.map +1 -1
- package/dist/runs/guarded-json-sql.d.ts +8 -0
- package/dist/runs/guarded-json-sql.js +11 -0
- package/dist/runs/guarded-json-sql.js.map +1 -0
- package/dist/runs/run-database-peer-page.js +3 -4
- package/dist/runs/run-database-peer-page.js.map +1 -1
- package/dist/runs/run-database-version.d.ts +1 -1
- package/dist/runs/run-database-version.js +2 -1
- package/dist/runs/run-database-version.js.map +1 -1
- package/dist/runs/run-database.js +5 -4
- package/dist/runs/run-database.js.map +1 -1
- package/dist/runs/run-exits.d.ts +15 -6
- package/dist/runs/run-exits.js +13 -4
- package/dist/runs/run-exits.js.map +1 -1
- package/dist/runs/run-index.js +1 -2
- package/dist/runs/run-index.js.map +1 -1
- package/dist/runs/store.d.ts +11 -5
- package/dist/runs/store.js +21 -20
- package/dist/runs/store.js.map +1 -1
- package/dist/serve-boot.d.ts +1 -2
- package/dist/serve-command.js +25 -15
- package/dist/serve-command.js.map +1 -1
- package/dist/serve-stop.d.ts +41 -0
- package/dist/serve-stop.js +42 -0
- package/dist/serve-stop.js.map +1 -0
- package/dist/server/activity-routes.d.ts +23 -23
- package/dist/server/checkout.d.ts +1 -1
- package/dist/server/checkout.js +5 -5
- package/dist/server/checkout.js.map +1 -1
- package/dist/server/create-project.js +9 -10
- package/dist/server/create-project.js.map +1 -1
- package/dist/server/forge/draft-pr.js +17 -13
- package/dist/server/forge/draft-pr.js.map +1 -1
- package/dist/server/git.js +2 -4
- package/dist/server/git.js.map +1 -1
- package/dist/server/health-cache.d.ts +39 -0
- package/dist/server/health-cache.js +66 -0
- package/dist/server/health-cache.js.map +1 -0
- package/dist/server/repo-pull.js +3 -7
- package/dist/server/repo-pull.js.map +1 -1
- package/dist/server/server.d.ts +368 -341
- package/dist/server/server.js +39 -98
- package/dist/server/server.js.map +1 -1
- package/dist/server/workspace-live-routes.d.ts +6 -6
- package/dist/server-install/platforms/macosx-migration.js +1 -1
- package/dist/server-install/platforms/macosx-migration.js.map +1 -1
- package/dist/server-install/platforms/ubuntu-vps-migration.js +1 -1
- package/dist/server-install/platforms/ubuntu-vps-migration.js.map +1 -1
- package/dist/skills-remote.js +8 -12
- package/dist/skills-remote.js.map +1 -1
- package/dist/task-branch-head.js +2 -4
- package/dist/task-branch-head.js.map +1 -1
- package/dist/task-cli/discovery.js +2 -4
- package/dist/task-cli/discovery.js.map +1 -1
- package/dist/ui-state.d.ts +7 -6
- package/dist/ui-state.js +31 -6
- package/dist/ui-state.js.map +1 -1
- package/dist/workflows/continuation-admission.d.ts +2 -1
- package/dist/workflows/run/attachment-writer.d.ts +5 -4
- package/dist/workflows/run/attachment-writer.js +9 -7
- package/dist/workflows/run/attachment-writer.js.map +1 -1
- package/dist/workflows/run/compose.d.ts +4 -1
- package/dist/workflows/run/compose.js +14 -10
- package/dist/workflows/run/compose.js.map +1 -1
- package/dist/workflows/run/continuation-acceptance.d.ts +4 -1
- package/dist/workflows/run/continuation-acceptance.js +4 -1
- package/dist/workflows/run/continuation-acceptance.js.map +1 -1
- package/dist/workflows/run/family-reconciler.d.ts +4 -0
- package/dist/workflows/run/family-reconciler.js +4 -0
- package/dist/workflows/run/family-reconciler.js.map +1 -1
- package/dist/workflows/run/inbox-claims.d.ts +2 -0
- package/dist/workflows/run/inbox-claims.js +2 -0
- package/dist/workflows/run/inbox-claims.js.map +1 -1
- package/dist/workflows/run/maintenance-claims.d.ts +2 -0
- package/dist/workflows/run/maintenance-claims.js +2 -0
- package/dist/workflows/run/maintenance-claims.js.map +1 -1
- package/dist/workflows/run/memory-guard.d.ts +6 -6
- package/dist/workflows/run/memory-guard.js +8 -8
- package/dist/workflows/run/memory-guard.js.map +1 -1
- package/dist/workflows/run/prompts.js +1 -1
- package/dist/workflows/run/prompts.js.map +1 -1
- package/dist/workflows/run/queued-input.d.ts +12 -10
- package/dist/workflows/run/queued-input.js +17 -16
- package/dist/workflows/run/queued-input.js.map +1 -1
- package/dist/workflows/run/run-line.d.ts +5 -4
- package/dist/workflows/run/run-line.js +11 -6
- package/dist/workflows/run/run-line.js.map +1 -1
- package/dist/workflows/run/run-memory.d.ts +52 -0
- package/dist/workflows/run/run-memory.js +58 -0
- package/dist/workflows/run/run-memory.js.map +1 -0
- package/dist/workflows/run/run-settlement.d.ts +21 -4
- package/dist/workflows/run/run-settlement.js +60 -22
- package/dist/workflows/run/run-settlement.js.map +1 -1
- package/dist/workflows/run/session-events.d.ts +2 -0
- package/dist/workflows/run/session-events.js +2 -2
- package/dist/workflows/run/session-events.js.map +1 -1
- package/dist/workflows/run/step-loop.js +1 -1
- package/dist/workflows/run/step-loop.js.map +1 -1
- package/dist/workflows/run/turn-bookkeeping.d.ts +5 -5
- package/dist/workflows/run/turn-bookkeeping.js +7 -7
- package/dist/workflows/run/turn-bookkeeping.js.map +1 -1
- package/dist/workflows/run/turn-settler.d.ts +3 -0
- package/dist/workflows/run/turn-settler.js +7 -3
- package/dist/workflows/run/turn-settler.js.map +1 -1
- package/dist/workflows/run/wait-engine.d.ts +2 -1
- package/dist/workflows/run/wait-registry.d.ts +1 -0
- package/dist/workflows/run/wait-registry.js +1 -0
- package/dist/workflows/run/wait-registry.js.map +1 -1
- package/dist/workflows/run/wake-retries.d.ts +10 -6
- package/dist/workflows/run/wake-retries.js +14 -10
- package/dist/workflows/run/wake-retries.js.map +1 -1
- package/dist/workflows/run/worker-executions.d.ts +11 -2
- package/dist/workflows/run/worker-executions.js +15 -6
- package/dist/workflows/run/worker-executions.js.map +1 -1
- package/dist/workflows/run/worker-orphans.js +2 -0
- package/dist/workflows/run/worker-orphans.js.map +1 -1
- package/dist/workflows/run/worker-questions.d.ts +3 -2
- package/dist/workflows/run/worker-questions.js +6 -5
- package/dist/workflows/run/worker-questions.js.map +1 -1
- package/dist/workflows/run/worktree-autosave.d.ts +2 -1
- package/dist/workflows/run/worktree-autosave.js +2 -1
- package/dist/workflows/run/worktree-autosave.js.map +1 -1
- package/dist/workflows/run-states.js +3 -3
- package/dist/workflows/run-states.js.map +1 -1
- package/dist/workflows/run.d.ts +2 -0
- package/dist/workflows/run.js +12 -3
- package/dist/workflows/run.js.map +1 -1
- package/dist/workspace/projects.d.ts +2 -0
- package/dist/workspace/projects.js +3 -4
- package/dist/workspace/projects.js.map +1 -1
- package/dist/worktree-manifest.js +2 -4
- package/dist/worktree-manifest.js.map +1 -1
- package/package.json +4 -4
- package/scripts/measure-transcript-facts-health.mjs +13 -6
- package/scripts/mock-ask-answer.mjs +19 -0
- package/scripts/mock-codex-app-server.mjs +16 -4
- package/scripts/mock-opencode-questions.mjs +89 -0
- package/scripts/mock-opencode-serve.mjs +6 -72
- package/web/dist/assets/activity-motion-DhLXb8Pt.js +2 -0
- package/web/dist/assets/{activity-route--Qj4NT9h.js → activity-route-CpwAMYLn.js} +1 -1
- package/web/dist/assets/{agent-accounts-BxpWcFS3.js → agent-accounts-Bc0LJ4SB.js} +1 -1
- package/web/dist/assets/attention-BF8NA1XM.js +1 -0
- package/web/dist/assets/{commit-diff-panel-DOgakNKv.js → commit-diff-panel-B1KZl0GP.js} +1 -1
- package/web/dist/assets/{diff-MoyKcT8Q.js → diff-Ci-qd1lU.js} +2 -2
- package/web/dist/assets/{diff-view-BFQcOCEf.js → diff-view-CWZElKoD.js} +1 -1
- package/web/dist/assets/{file-preview-BancpZHA.js → file-preview-CoWRr13R.js} +1 -1
- package/web/dist/assets/{git-toolbar-ClMasBRM.js → git-toolbar-BYIni94R.js} +1 -1
- package/web/dist/assets/{github-BVZ01nJq.js → github-CAPNq5vY.js} +1 -1
- package/web/dist/assets/{global-activity-route-DTgywy--.js → global-activity-route-DLEwsMA7.js} +1 -1
- package/web/dist/assets/index-CpwAOct4.js +17 -0
- package/web/dist/assets/{preview-pane-connected-B5PCWA9a.js → preview-pane-connected-CGw_9VuF.js} +2 -2
- package/web/dist/assets/{project-router-CiB1O_5A.js → project-router-oKsNlPN6.js} +1 -1
- package/web/dist/assets/{project-scope-context-CSPQyWoO.js → project-scope-context-BBVJVcJp.js} +1 -1
- package/web/dist/assets/{prompt-template-menu-VwBcsbqE.js → prompt-template-menu-BZTz2mIG.js} +1 -1
- package/web/dist/assets/queries-Be8VyHam.js +1 -0
- package/web/dist/assets/{reference-chip-DT-_ninM.js → reference-chip-Ht4xX9-k.js} +1 -1
- package/web/dist/assets/{repo-git-7KuJaDRk.js → repo-git-CzVLCWig.js} +1 -1
- package/web/dist/assets/{report-reader-CgY75QM2.js → report-reader-iTBkUgg-.js} +1 -1
- package/web/dist/assets/reports-BJF1Cl3C.js +1 -0
- package/web/dist/assets/run-header-BxB6gyt1.js +2 -0
- package/web/dist/assets/{skills-Dnrta_-m.js → skills-DvgHKWgK.js} +1 -1
- package/web/dist/assets/{tab-link-BPBiho7-.js → tab-link-Buy1fRFO.js} +1 -1
- package/web/dist/assets/{task-changes-C6sDd3Le.js → task-changes-CStxhLFG.js} +1 -1
- package/web/dist/assets/{task-commits-CQHxnFJ5.js → task-commits-DhpOAdOf.js} +1 -1
- package/web/dist/assets/{task-files-DK8Demuc.js → task-files-COmKUUfN.js} +1 -1
- package/web/dist/assets/{task-github-item-DgmmFFtN.js → task-github-item-BNLeAz58.js} +1 -1
- package/web/dist/assets/{task-thread-Dg9VWJq6.js → task-thread-DjSFvEQe.js} +6 -6
- package/web/dist/assets/{thread-state-DIMUAyFk.js → thread-state-B5tTsVNm.js} +1 -1
- package/web/dist/assets/use-desktop-BPWIJ0Kw.js +1 -0
- package/web/dist/assets/{use-hand-to-agent-state-D-yaVRRx.js → use-hand-to-agent-state-Ce6QW2j_.js} +1 -1
- package/web/dist/assets/{useInfiniteQuery-Q8eFXz-L.js → useInfiniteQuery-Yn58_Fkn.js} +1 -1
- package/web/dist/assets/useQuery-C1xFF0nd.js +1 -0
- package/web/dist/assets/{workflows-W_uriBcj.js → workflows-CN8uKYnY.js} +1 -1
- package/web/dist/assets/{ws-B-tB133E.js → ws-DbXGHAke.js} +1 -1
- package/web/dist/index.html +12 -12
- package/web/dist/assets/activity-motion-CEnf2rDh.js +0 -2
- package/web/dist/assets/attention-BDa7opY9.js +0 -1
- package/web/dist/assets/index-CsOa03VW.js +0 -17
- package/web/dist/assets/queries-pj368bmB.js +0 -1
- package/web/dist/assets/reports-CxTUchWh.js +0 -1
- package/web/dist/assets/run-header-BcX23gw7.js +0 -2
- package/web/dist/assets/use-desktop-Bq_Qh5ur.js +0 -1
- package/web/dist/assets/useQuery-BoLjCS2U.js +0 -1
package/dist/runs/store.js
CHANGED
|
@@ -14,6 +14,7 @@ import { autosaveCleanupBlocker, clearAutosaveCleanup } from '../autosave-cleanu
|
|
|
14
14
|
import { EventEmitter } from 'node:events';
|
|
15
15
|
import { admissibleExecution, holderRefusal, SPAWN_NEXT, WorkerAdmissionRefusal, workerEvidenceRunIds, workerExecutionSchema } from './worker-execution.js';
|
|
16
16
|
import { agentTmpDirLocations, agentTmpDirMayExist, agentTmpDirOwnershipProven, removeAgentTmpDir } from './agent-tmpdir.js';
|
|
17
|
+
import { jobRunsIn } from '../jobs/job.js';
|
|
17
18
|
import { removeArtifacts } from '../artifacts/lifecycle.js';
|
|
18
19
|
import { randomUUID, createHash } from 'node:crypto';
|
|
19
20
|
import { isDeepStrictEqual } from 'node:util';
|
|
@@ -47,6 +48,7 @@ export { ConversationIdInUseError } from './conversation-identity.js';
|
|
|
47
48
|
import { RUNNER_IDS } from '../core/agent-runner.js';
|
|
48
49
|
import { ARCHIVED_ROOT, RUNS_DB_FILE, RUNS_IMPORT_COMPLETE_KEY, RunConflictError, RunDatabase, RunDatabaseBusyError, } from './run-database.js';
|
|
49
50
|
import { listBranchOwners } from './branch-owners.js';
|
|
51
|
+
import { guardedJsonSql } from './guarded-json-sql.js';
|
|
50
52
|
import { restoreLostReferencedPullRequest } from './loaded-run-healing.js';
|
|
51
53
|
import { failLoadedInterruptedRun, restoreLoadedUsageLimitHold, settleLoadedStop } from './loaded-run-exits.js';
|
|
52
54
|
import { hasLegacyWaitFields, upgradeLegacyWaits, UNREADABLE_WAIT } from './legacy-waits.js';
|
|
@@ -98,9 +100,9 @@ export const runRecordSchema = contractRunRecordSchema.extend({
|
|
|
98
100
|
webhook: contractRunRecordSchema.shape.webhook.catch(undefined),
|
|
99
101
|
destroyRetry: contractRunRecordSchema.shape.destroyRetry.catch(undefined),
|
|
100
102
|
stopping: contractRunRecordSchema.shape.stopping.catch(undefined),
|
|
101
|
-
hasPendingPermission: contractRunRecordSchema.shape.hasPendingPermission.catch(undefined),
|
|
102
103
|
autoResumeAt: z.string().datetime().optional().catch(undefined),
|
|
103
104
|
autoResumeAttempts: z.number().int().min(0).optional().catch(undefined), autoResumeReason: contractRunRecordSchema.shape.autoResumeReason.catch(undefined),
|
|
105
|
+
parkReason: contractRunRecordSchema.shape.parkReason.catch(undefined), hasPendingPermission: contractRunRecordSchema.shape.hasPendingPermission.catch(undefined),
|
|
104
106
|
pullRequests: z.preprocess((value) => Array.isArray(value)
|
|
105
107
|
? value.flatMap((entry) => {
|
|
106
108
|
const parsed = runPullRequestSchema.safeParse(entry);
|
|
@@ -289,11 +291,11 @@ function importLegacyIndex(db, dataDir) {
|
|
|
289
291
|
/**
|
|
290
292
|
* Finished rows whose stored summary an open-time normalization would still change: a referenced
|
|
291
293
|
* PR an older Squawk's created-PR declaration erased, or issue attribution displaced by a
|
|
292
|
-
* follow-up declaration (see `reconcileLoadedRun`). Not live, so not
|
|
294
|
+
* follow-up declaration (see `reconcileLoadedRun`), or a summary that is not JSON. Not live, so not
|
|
293
295
|
* in the `live` column; open decodes these few and keeps the ones it actually repaired.
|
|
294
296
|
*/
|
|
295
|
-
const LEGACY_REFERENCE_HEAL_SQL = "(json_extract(summary, '$.markerRefs.pr') IS NOT NULL AND json_extract(summary, '$.referencedPullRequestUrl') IS NULL)" +
|
|
296
|
-
" OR (NOT EXISTS (SELECT 1 FROM meta WHERE key = 'issue-attribution:' || runs.id AND value = CAST(runs.revision AS TEXT)) AND json_extract(summary, '$.markerRefs.issue') IS NOT NULL)";
|
|
297
|
+
const LEGACY_REFERENCE_HEAL_SQL = guardedJsonSql("(json_extract(summary, '$.markerRefs.pr') IS NOT NULL AND json_extract(summary, '$.referencedPullRequestUrl') IS NULL)" +
|
|
298
|
+
" OR (NOT EXISTS (SELECT 1 FROM meta WHERE key = 'issue-attribution:' || runs.id AND value = CAST(runs.revision AS TEXT)) AND json_extract(summary, '$.markerRefs.issue') IS NOT NULL)", 1);
|
|
297
299
|
/**
|
|
298
300
|
* The rows whose stored summary reading their record can change, as SQL over `runs`: the rows
|
|
299
301
|
* `open` decodes to normalize (the `live` column it loads by, then `LEGACY_REFERENCE_HEAL_SQL`).
|
|
@@ -311,8 +313,8 @@ export const LOAD_REPAIR_SQL = `live = 1 OR ${LEGACY_REFERENCE_HEAL_SQL}`;
|
|
|
311
313
|
* finished task nobody has opened since the upgrade. `instr` keeps the JSON parse off every
|
|
312
314
|
* other row.
|
|
313
315
|
*/
|
|
314
|
-
const AUTOMATION_ORIGIN_HEAL_SQL =
|
|
315
|
-
" AND (json_extract(data, '$.automation.automationId') IS NOT NULL OR json_extract(data, '$.automationTrigger.automationId') IS NOT NULL)"
|
|
316
|
+
const AUTOMATION_ORIGIN_HEAL_SQL = `instr(data, '"automation') > 0 AND ${guardedJsonSql("json_extract(summary, '$.automationId') IS NULL" +
|
|
317
|
+
" AND (json_extract(data, '$.automation.automationId') IS NOT NULL OR json_extract(data, '$.automationTrigger.automationId') IS NOT NULL)", 0, ['summary', 'data'])}`;
|
|
316
318
|
export { branchOwnerOf } from './branch-owners.js';
|
|
317
319
|
/** The one answer every control gives for a run another Squawk process owns (`409 { error }`). */
|
|
318
320
|
export const RUN_IN_USE_ELSEWHERE = `run is in use by another ${productName('cezar')} process`;
|
|
@@ -662,8 +664,8 @@ export class RunStore extends EventEmitter {
|
|
|
662
664
|
/** Normalize a record just read from `row` (see `reconcileLoadedRun`) and hold it. Marks the row
|
|
663
665
|
* dirty only when normalization changed it, so the next save persists exactly the runs open()
|
|
664
666
|
* rewrote. A row read up from schema-3 wait fields counts as changed: its rewrite drops them
|
|
665
|
-
* and recomputes its summary and live column (`upgradeLegacyWaits`)
|
|
666
|
-
* the row's family. */
|
|
667
|
+
* and recomputes its summary and live column (`upgradeLegacyWaits`), as does a summary that does
|
|
668
|
+
* not parse (hearsay-tools/squawk#3530). The caller has claimed the row's family. */
|
|
667
669
|
adoptLoadedRun({ run, extras, upgraded }, opts, row) {
|
|
668
670
|
if (this.db?.familyHasFallback(rowFamily(row)))
|
|
669
671
|
return;
|
|
@@ -674,7 +676,7 @@ export class RunStore extends EventEmitter {
|
|
|
674
676
|
settleOrphanedRun(run, { stop: opts.stop });
|
|
675
677
|
else
|
|
676
678
|
reconcileLoadedRun(run, opts);
|
|
677
|
-
const changed = upgraded === true || JSON.stringify(run) !== before;
|
|
679
|
+
const changed = upgraded === true || JSON.stringify(run) !== before || parseStoredSummary(row.summary) === undefined;
|
|
678
680
|
if (opts.onlyIfChanged && !changed)
|
|
679
681
|
return;
|
|
680
682
|
this.held.set(run.id, run);
|
|
@@ -983,7 +985,7 @@ export class RunStore extends EventEmitter {
|
|
|
983
985
|
// `touch` per healed run: the cockpit is already live when the handle lands, so a corrected
|
|
984
986
|
// chip has to reach the open page over SSE, not just the next `runs.json` write.
|
|
985
987
|
let healed = false;
|
|
986
|
-
const stored = this.db?.listWhere(`${REFERENCED_RUN_RULE.sql} OR json_extract(summary, '$.pullRequests') IS NOT NULL
|
|
988
|
+
const stored = this.db?.listWhere(guardedJsonSql(`${REFERENCED_RUN_RULE.sql} OR json_extract(summary, '$.pullRequests') IS NOT NULL`, 0)).filter((row) => {
|
|
987
989
|
if (this.held.has(row.id) || this.deleted.has(row.id))
|
|
988
990
|
return false;
|
|
989
991
|
const summary = parseStoredSummary(row.summary);
|
|
@@ -1288,7 +1290,7 @@ export class RunStore extends EventEmitter {
|
|
|
1288
1290
|
/** The id of every run whose delegation is quarantined (`invalid`), held or stored: its stored
|
|
1289
1291
|
* summary says so, so nothing is decoded (scratch cleanup). */
|
|
1290
1292
|
listQuarantinedRunIds() {
|
|
1291
|
-
const ids = new Set((this.db?.listKeysWhere("json_extract(summary, '$.delegation.role') = 'invalid'") ?? []).map((key) => key.id));
|
|
1293
|
+
const ids = new Set((this.db?.listKeysWhere(guardedJsonSql("json_extract(summary, '$.delegation.role') = 'invalid'", 0)) ?? []).map((key) => key.id));
|
|
1292
1294
|
for (const id of this.deleted)
|
|
1293
1295
|
ids.delete(id);
|
|
1294
1296
|
for (const [id, run] of this.held) {
|
|
@@ -1335,13 +1337,13 @@ export class RunStore extends EventEmitter {
|
|
|
1335
1337
|
return run.id;
|
|
1336
1338
|
// Secondary references are record-only: query them in SQLite rather than hydrating every
|
|
1337
1339
|
// finished transcript or relying on the slim summary's primary issue number.
|
|
1338
|
-
const where = `archived = 0 AND (
|
|
1340
|
+
const where = `archived = 0 AND ${guardedJsonSql(`
|
|
1339
1341
|
json_extract(data, '$.issueNumber') = ? OR json_extract(data, '$.markerRefs.issue') = ?
|
|
1340
1342
|
OR lower(rtrim(json_extract(data, '$.referencedIssueUrl'), '/')) = ?
|
|
1341
1343
|
OR EXISTS (SELECT 1 FROM json_each(data, '$.referencedIssueCandidates') WHERE lower(rtrim(value, '/')) = ?)
|
|
1342
1344
|
OR (json_extract(data, '$.automation.event') LIKE 'issue.%' AND lower(rtrim(json_extract(data, '$.automation.githubUrl'), '/')) = ?)
|
|
1343
1345
|
OR instr(lower(json_extract(data, '$.task')), ?) > 0
|
|
1344
|
-
)`;
|
|
1346
|
+
`, 0, ['data'])}`;
|
|
1345
1347
|
for (const key of this.db?.listKeysWhere(where, [number, number, url, url, url, url]) ?? []) {
|
|
1346
1348
|
if (this.held.has(key.id) || this.deleted.has(key.id) || this.unreadable.has(key.id))
|
|
1347
1349
|
continue;
|
|
@@ -1417,7 +1419,7 @@ export class RunStore extends EventEmitter {
|
|
|
1417
1419
|
* no record. Held runs answer from memory.
|
|
1418
1420
|
*/
|
|
1419
1421
|
listBranchOwners() {
|
|
1420
|
-
const rows = (this.db?.listBranchOwners(
|
|
1422
|
+
const rows = (this.db?.listBranchOwners(`branch IS NOT NULL OR ${guardedJsonSql("json_extract(summary, '$.pullRequestUrl') IS NOT NULL", 0)}`) ?? [])
|
|
1421
1423
|
.filter((row) => !this.deleted.has(row.id) && !this.held.has(row.id));
|
|
1422
1424
|
return listBranchOwners(rows, [...this.held.values()], (id) => this.getRun(id));
|
|
1423
1425
|
}
|
|
@@ -2406,7 +2408,7 @@ export class RunStore extends EventEmitter {
|
|
|
2406
2408
|
// Runs not in memory are picked by the same rule over their stored summary, then re-checked
|
|
2407
2409
|
// on the record before they are stamped.
|
|
2408
2410
|
const candidates = [...this.held.values()];
|
|
2409
|
-
const stored = (this.db?.listWhere(UNREAD_RUN_RULE.sql) ?? []).filter((row) => !this.held.has(row.id) && !this.deleted.has(row.id));
|
|
2411
|
+
const stored = (this.db?.listWhere(guardedJsonSql(UNREAD_RUN_RULE.sql, 0)) ?? []).filter((row) => !this.held.has(row.id) && !this.deleted.has(row.id));
|
|
2410
2412
|
// One claim transaction for them all; another process's runs are skipped (`record` refuses).
|
|
2411
2413
|
this.claimFamilies(stored.map(rowFamily));
|
|
2412
2414
|
for (const row of stored) {
|
|
@@ -3211,7 +3213,7 @@ export class RunStore extends EventEmitter {
|
|
|
3211
3213
|
const cold = overflow.filter((id) => !this.held.has(id) && !this.hasFallbackRun(id));
|
|
3212
3214
|
if (cold.length > 0) {
|
|
3213
3215
|
// Another process's runs are its own to keep or archive (#779, plan step 3).
|
|
3214
|
-
const rows = this.db.listWhere(RETENTION_RUN_RULE.sql, [JSON.stringify(cold)]);
|
|
3216
|
+
const rows = this.db.listWhere(guardedJsonSql(RETENTION_RUN_RULE.sql, 0), [JSON.stringify(cold)]);
|
|
3215
3217
|
const writable = this.claimFamilies(rows.map(rowFamily));
|
|
3216
3218
|
for (const row of rows)
|
|
3217
3219
|
if (writable.has(rowFamily(row)))
|
|
@@ -3230,11 +3232,10 @@ export class RunStore extends EventEmitter {
|
|
|
3230
3232
|
const workers = this.listWorkersOf(root.id), family = [root, ...workers];
|
|
3231
3233
|
if (family.some((run) => isLiveRecord(run) || run.pinned) || (root.delegation?.role === 'root' && root.delegation.historyDeletion))
|
|
3232
3234
|
return;
|
|
3233
|
-
for (const member of [root, ...workers.flatMap((worker) => this.record(worker.id) ?? [])]) {
|
|
3234
|
-
if (member.archived)
|
|
3235
|
-
continue;
|
|
3235
|
+
for (const member of [root, ...workers.flatMap((worker) => this.record(worker.id) ?? [])].filter((run) => !run.archived)) {
|
|
3236
3236
|
this.applyArchived(member, true);
|
|
3237
|
-
|
|
3237
|
+
if (!jobRunsIn(agentTmpDirLocations(this.dataDir, member.id)))
|
|
3238
|
+
removeAgentTmpDir(this.dataDir, member.id);
|
|
3238
3239
|
}
|
|
3239
3240
|
}
|
|
3240
3241
|
/** Debounced so token-usage updates don't rewrite a row per event. Nothing to schedule without
|