wicked-crew 0.18.17 → 0.18.19
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/api/capture.d.ts.map +1 -1
- package/dist/api/capture.js +5 -0
- package/dist/api/capture.js.map +1 -1
- package/dist/api/chat-jobs.d.ts +30 -0
- package/dist/api/chat-jobs.d.ts.map +1 -1
- package/dist/api/chat-jobs.js +74 -7
- package/dist/api/chat-jobs.js.map +1 -1
- package/dist/api/chat-proposals.d.ts +38 -3
- package/dist/api/chat-proposals.d.ts.map +1 -1
- package/dist/api/chat-proposals.js +162 -21
- package/dist/api/chat-proposals.js.map +1 -1
- package/dist/api/chat-scope.d.ts +9 -0
- package/dist/api/chat-scope.d.ts.map +1 -1
- package/dist/api/chat-scope.js +35 -4
- package/dist/api/chat-scope.js.map +1 -1
- package/dist/api/delivery-index.d.ts.map +1 -1
- package/dist/api/delivery-index.js +13 -0
- package/dist/api/delivery-index.js.map +1 -1
- package/dist/api/mcp.js +1 -1
- package/dist/api/mcp.js.map +1 -1
- package/dist/api/needs.js +1 -1
- package/dist/api/needs.js.map +1 -1
- package/dist/api/post-hoc-deliver.d.ts +9 -0
- package/dist/api/post-hoc-deliver.d.ts.map +1 -1
- package/dist/api/post-hoc-deliver.js +32 -3
- package/dist/api/post-hoc-deliver.js.map +1 -1
- package/dist/api/redeliver.d.ts +48 -0
- package/dist/api/redeliver.d.ts.map +1 -0
- package/dist/api/redeliver.js +178 -0
- package/dist/api/redeliver.js.map +1 -0
- package/dist/api/roster-standing.d.ts +10 -1
- package/dist/api/roster-standing.d.ts.map +1 -1
- package/dist/api/roster-standing.js +34 -4
- package/dist/api/roster-standing.js.map +1 -1
- package/dist/api/routes.d.ts +14 -6
- package/dist/api/routes.d.ts.map +1 -1
- package/dist/api/routes.js +468 -210
- package/dist/api/routes.js.map +1 -1
- package/dist/api/run-base-notice.d.ts +5 -0
- package/dist/api/run-base-notice.d.ts.map +1 -0
- package/dist/api/run-base-notice.js +15 -0
- package/dist/api/run-base-notice.js.map +1 -0
- package/dist/api/run-files.d.ts.map +1 -1
- package/dist/api/run-files.js +41 -2
- package/dist/api/run-files.js.map +1 -1
- package/dist/api/seat-agents.d.ts +3 -1
- package/dist/api/seat-agents.d.ts.map +1 -1
- package/dist/api/seat-agents.js +8 -2
- package/dist/api/seat-agents.js.map +1 -1
- package/dist/api/seat-images.d.ts +54 -0
- package/dist/api/seat-images.d.ts.map +1 -1
- package/dist/api/seat-images.js +132 -8
- package/dist/api/seat-images.js.map +1 -1
- package/dist/api/seat-probe.d.ts +6 -5
- package/dist/api/seat-probe.d.ts.map +1 -1
- package/dist/api/seat-probe.js +11 -7
- package/dist/api/seat-probe.js.map +1 -1
- package/dist/api/seat-standing.d.ts +3 -0
- package/dist/api/seat-standing.d.ts.map +1 -1
- package/dist/api/seat-standing.js +9 -4
- package/dist/api/seat-standing.js.map +1 -1
- package/dist/api/server.d.ts.map +1 -1
- package/dist/api/server.js +16 -6
- package/dist/api/server.js.map +1 -1
- package/dist/api/system-snapshot.d.ts.map +1 -1
- package/dist/api/system-snapshot.js +4 -2
- package/dist/api/system-snapshot.js.map +1 -1
- package/dist/api/ui-text.d.ts +2 -0
- package/dist/api/ui-text.d.ts.map +1 -1
- package/dist/api/ui-text.js +2 -0
- package/dist/api/ui-text.js.map +1 -1
- package/dist/apps-server/server/lib/bundle/server.mjs +227 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +2 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/service.d.ts +2 -0
- package/dist/cli/service.d.ts.map +1 -1
- package/dist/cli/service.js +14 -0
- package/dist/cli/service.js.map +1 -1
- package/dist/core/adapter.d.ts +27 -3
- package/dist/core/adapter.d.ts.map +1 -1
- package/dist/core/adapter.js +89 -10
- package/dist/core/adapter.js.map +1 -1
- package/dist/core/bridge-reaper.d.ts +4 -3
- package/dist/core/bridge-reaper.d.ts.map +1 -1
- package/dist/core/bridge-reaper.js +24 -8
- package/dist/core/bridge-reaper.js.map +1 -1
- package/dist/core/deliver-exclusions.d.ts +32 -0
- package/dist/core/deliver-exclusions.d.ts.map +1 -1
- package/dist/core/deliver-exclusions.js +47 -0
- package/dist/core/deliver-exclusions.js.map +1 -1
- package/dist/core/deliver-text.d.ts.map +1 -1
- package/dist/core/deliver-text.js +11 -2
- package/dist/core/deliver-text.js.map +1 -1
- package/dist/core/deliver.d.ts +34 -1
- package/dist/core/deliver.d.ts.map +1 -1
- package/dist/core/deliver.js +277 -49
- package/dist/core/deliver.js.map +1 -1
- package/dist/core/job-seats.d.ts +23 -0
- package/dist/core/job-seats.d.ts.map +1 -0
- package/dist/core/job-seats.js +38 -0
- package/dist/core/job-seats.js.map +1 -0
- package/dist/core/launch-posture.d.ts +75 -0
- package/dist/core/launch-posture.d.ts.map +1 -0
- package/dist/core/launch-posture.js +88 -0
- package/dist/core/launch-posture.js.map +1 -0
- package/dist/core/pr-checks-helper.d.ts +51 -0
- package/dist/core/pr-checks-helper.d.ts.map +1 -0
- package/dist/core/pr-checks-helper.js +172 -0
- package/dist/core/pr-checks-helper.js.map +1 -0
- package/dist/core/redeliver.d.ts +16 -0
- package/dist/core/redeliver.d.ts.map +1 -0
- package/dist/core/redeliver.js +64 -0
- package/dist/core/redeliver.js.map +1 -0
- package/dist/core/threadpool.d.ts +3 -0
- package/dist/core/threadpool.d.ts.map +1 -0
- package/dist/core/threadpool.js +14 -0
- package/dist/core/threadpool.js.map +1 -0
- package/dist/insights/review-service.d.ts +10 -0
- package/dist/insights/review-service.d.ts.map +1 -1
- package/dist/insights/review-service.js +27 -3
- package/dist/insights/review-service.js.map +1 -1
- package/dist/interactive/council-outcome.js +1 -1
- package/dist/interactive/council-outcome.js.map +1 -1
- package/dist/learnings/extract.d.ts +7 -12
- package/dist/learnings/extract.d.ts.map +1 -1
- package/dist/learnings/extract.js +9 -40
- package/dist/learnings/extract.js.map +1 -1
- package/dist/learnings/recall.d.ts +11 -1
- package/dist/learnings/recall.d.ts.map +1 -1
- package/dist/learnings/recall.js +20 -4
- package/dist/learnings/recall.js.map +1 -1
- package/dist/learnings/replacement-lineage.d.ts +22 -0
- package/dist/learnings/replacement-lineage.d.ts.map +1 -0
- package/dist/learnings/replacement-lineage.js +41 -0
- package/dist/learnings/replacement-lineage.js.map +1 -0
- package/dist/learnings/service.d.ts +12 -15
- package/dist/learnings/service.d.ts.map +1 -1
- package/dist/learnings/service.js +23 -43
- package/dist/learnings/service.js.map +1 -1
- package/dist/mcp/env.js +3 -3
- package/dist/mcp/env.js.map +1 -1
- package/dist/mcp/registry.js +3 -3
- package/dist/mcp/registry.js.map +1 -1
- package/dist/projects/auto-refresh.d.ts +21 -0
- package/dist/projects/auto-refresh.d.ts.map +1 -1
- package/dist/projects/auto-refresh.js +55 -1
- package/dist/projects/auto-refresh.js.map +1 -1
- package/dist/projects/graph.d.ts +39 -0
- package/dist/projects/graph.d.ts.map +1 -1
- package/dist/projects/graph.js +144 -13
- package/dist/projects/graph.js.map +1 -1
- package/dist/schedules/routes.d.ts.map +1 -1
- package/dist/schedules/routes.js +5 -0
- package/dist/schedules/routes.js.map +1 -1
- package/dist/schedules/scheduler.d.ts +40 -1
- package/dist/schedules/scheduler.d.ts.map +1 -1
- package/dist/schedules/scheduler.js +175 -13
- package/dist/schedules/scheduler.js.map +1 -1
- package/dist/schedules/store.d.ts +20 -0
- package/dist/schedules/store.d.ts.map +1 -1
- package/dist/schedules/store.js +17 -0
- package/dist/schedules/store.js.map +1 -1
- package/dist/setup/delivery-readiness.d.ts +117 -0
- package/dist/setup/delivery-readiness.d.ts.map +1 -0
- package/dist/setup/delivery-readiness.js +262 -0
- package/dist/setup/delivery-readiness.js.map +1 -0
- package/dist/setup/known.d.ts +27 -0
- package/dist/setup/known.d.ts.map +1 -1
- package/dist/setup/known.js +47 -0
- package/dist/setup/known.js.map +1 -1
- package/dist/setup/routes.d.ts +5 -3
- package/dist/setup/routes.d.ts.map +1 -1
- package/dist/setup/routes.js +9 -3
- package/dist/setup/routes.js.map +1 -1
- package/dist/sources/routes.js +1 -1
- package/dist/sources/routes.js.map +1 -1
- package/dist/standing-orders/parse.js +1 -1
- package/dist/standing-orders/parse.js.map +1 -1
- package/dist/studio/apps-standalone/fixture.js +3 -3
- package/dist/studio/apps-standalone/runtime.js +1 -1
- package/dist/studio/assets/{KnowledgeGraph-BekDGaZW.js → KnowledgeGraph-DWw0I8RJ.js} +1 -1
- package/dist/studio/assets/index-C4Xj-zxa.css +32 -0
- package/dist/studio/assets/{index-D5r5wtIa.js → index-CrNY3d06.js} +305 -305
- package/dist/studio/editors/wicked-apps/editor.json +1 -1
- package/dist/studio/editors/wicked-apps/index.html +2 -2
- package/dist/studio/editors/wicked-deck/editor.json +1 -1
- package/dist/studio/editors/wicked-deck/index.html +13 -13
- package/dist/studio/editors/wicked-doc/editor.json +1 -1
- package/dist/studio/editors/wicked-doc/index.html +12 -12
- package/dist/studio/editors/wicked-insights/editor.json +1 -1
- package/dist/studio/editors/wicked-insights/index.html +2 -2
- package/dist/studio/editors/wicked-page/editor.json +1 -1
- package/dist/studio/editors/wicked-page/index.html +12 -12
- package/dist/studio/editors/wicked-video/editor.json +1 -1
- package/dist/studio/editors/wicked-video/index.html +10 -10
- package/dist/studio/index.html +2 -2
- package/dist/studio/testid-inventory.json +69 -3
- package/dist/working-doc/event-lines.d.ts +4 -0
- package/dist/working-doc/event-lines.d.ts.map +1 -1
- package/dist/working-doc/event-lines.js +8 -2
- package/dist/working-doc/event-lines.js.map +1 -1
- package/dist/working-doc/notes-index.d.ts.map +1 -1
- package/dist/working-doc/notes-index.js +2 -2
- package/dist/working-doc/notes-index.js.map +1 -1
- package/endpoint-manifest.json +36 -1
- package/package.json +4 -4
- package/workflows/distill-learnings.json +2 -2
- package/dist/studio/assets/index-CkosDNYp.css +0 -32
package/dist/api/routes.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { registerRedeliverRoutes } from './redeliver.js';
|
|
1
2
|
import { REVIEW_WORKFLOW } from '../insights/workflow.js';
|
|
2
3
|
import { runUsageCost } from '../insights/run-facts.js';
|
|
3
4
|
import { appsRuntimeDir, appsServerArtifact, containerEngineKnown } from '../apps/publish/artifacts.js';
|
|
@@ -13,7 +14,7 @@ import { promises as fsp } from 'node:fs';
|
|
|
13
14
|
import { basename, isAbsolute, join, relative, resolve } from 'node:path';
|
|
14
15
|
import { fileURLToPath } from 'node:url';
|
|
15
16
|
import { videoPalette } from '../appearance/video-palette.js';
|
|
16
|
-
import { CampaignsUnsupportedError, ChatUnsupportedError, CoreAdapter, ElicitationUnsupportedError, GovernanceReplayUnsupportedError, PlanGateNoteUnsupportedError, PlanLaunchUnsupportedError, SteeringUnsupportedError, addonSupportsQeOverride, addonSupportsReducedAssurance, humanGatePhaseIds, settingsFilePath, wickedDir } from '../core/adapter.js';
|
|
17
|
+
import { CampaignsUnsupportedError, ChatUnsupportedError, CoreAdapter, ElicitationUnsupportedError, GovernanceReplayUnsupportedError, PlanGateNoteUnsupportedError, PlanLaunchUnsupportedError, SteeringUnsupportedError, addonSupportsQeOverride, addonSupportsReducedAssurance, humanGatePhaseIds, readNewWorkSeats, settingsFilePath, wickedDir } from '../core/adapter.js';
|
|
17
18
|
import { codeGraphDb, codeGraphErrorStatus, repoFolderMissing, repoFolderMissingBody } from '../core/repoPaths.js';
|
|
18
19
|
import { resolveCursorUnit } from '../core/cursor.js';
|
|
19
20
|
/** Create `dir` (private) when missing and answer it — a read root must exist when a run launches. */
|
|
@@ -56,6 +57,8 @@ import { attemptUnavailableReason, capturedAttempts, outputUnavailableReason, re
|
|
|
56
57
|
import { execCapped, ExecOutputTooLarge } from '../core/exec.js';
|
|
57
58
|
import { callEstateTool, EstateMcpError, ESTATE_INSTALL_HINT, memoryStoreInfo } from '../core/estate-mcp-client.js';
|
|
58
59
|
import { NO_LEARNINGS_WORKFLOWS } from '../learnings/service.js';
|
|
60
|
+
import { APPROVED_MEMORY_PREFIX } from '../learnings/recall.js';
|
|
61
|
+
import { REPLACES_KEY, refuseStaleReplacement, replacesOf } from '../learnings/replacement-lineage.js';
|
|
59
62
|
import { matchRulesForJob, stripRulesBrief, withRulesBrief } from '../decisions/rules-brief.js';
|
|
60
63
|
import { SeatHealthTracker } from './seat-health.js';
|
|
61
64
|
import { applyWorkerConfigRoot, signedInHeuristic } from './seat-signin.js';
|
|
@@ -66,7 +69,7 @@ import { chatSeatAdmission, homeless } from './seat-standing.js';
|
|
|
66
69
|
import { seatGovernanceDiagnostics, seatGovernanceWarnings, } from './seat-governance.js';
|
|
67
70
|
import { seatWorkDefaultNow } from './seat-work-default.js';
|
|
68
71
|
import { ROSTER_REFRESH_WAIT_MS, rosterWithStandingFactory } from './roster-standing.js';
|
|
69
|
-
import { SeatContainerStatus, isContainerLoginCli, isContainerSeatFloor, isHostSeatFloor,
|
|
72
|
+
import { SeatContainerStatus, isContainerLoginCli, isContainerSeatFloor, isHostSeatFloor, registerSeatContainerLoginRoutes, seatLoginDepsFor, } from './seat-container-login.js';
|
|
70
73
|
import { ChatTurnIndex } from './chat-turns.js';
|
|
71
74
|
import { CHAT_ID, chatJobTurnLines, chatMakeDigest, ChatScopeIndex, chatScopeDeps, chatScopeStatement, prepareChatScratch, removeChatScratch, namedKindRefusal, resolveChatScope, } from './chat-scope.js';
|
|
72
75
|
import { buildRequirementsMaps, publishRequirementsMaps, REQUIREMENTS_MAP_DIR } from './chat-requirements.js';
|
|
@@ -117,8 +120,10 @@ import { withPhaseSkillGaps } from '../skills/phase-skill-gaps.js';
|
|
|
117
120
|
import { STATE_HOME_BLOCKER_CODE, STATE_HOME_REMEDY, isEngineStateHomeRefusal, stateHomeBlockerBody, } from '../projects/state-home-preflight.js';
|
|
118
121
|
import { BASE_SKILL_POLICIES, BASE_SKILL_REF_SHAPE, baseSkillRemedy } from '../skills/base-skill.js';
|
|
119
122
|
import { REQUIRED_GARDEN_VERSION } from '../skills/plugin-source.js';
|
|
123
|
+
import { isSeatKeyList } from '../core/job-seats.js';
|
|
120
124
|
import { engineRosterJson, noEligibleSeatBody, parseNoEligibleSeat, toEngineSeat } from '../core/engine-roster.js';
|
|
121
125
|
import { launchAssuranceNotice } from '../core/assurance.js';
|
|
126
|
+
import { launchPosture } from '../core/launch-posture.js';
|
|
122
127
|
import { launchRequiresQe, mayRequireQe, qeAcceptanceMode, qeSettingSkipReason } from '../core/qe-acceptance-setting.js';
|
|
123
128
|
import { aggregateReceipt, postHocDeliveryAssurance, qeAcceptanceFromView, qeAcceptanceRefusal, QE_ACCEPTANCE_REQUIRED_CODE, receiptOf, qeAcceptanceNotRequired, qeDecisionBypasses, qeDecisionOf, qeAcceptanceSkippedAtGate, unreadableQeAcceptance, } from './delivery-assurance.js';
|
|
124
129
|
import { ProjectSettingsStore } from '../projects/settings.js';
|
|
@@ -144,7 +149,7 @@ const BRIEF_COPY_MAX = 512 * 1024;
|
|
|
144
149
|
import { registerInteractiveDocDelete } from '../interactive/doc-delete-routes.js';
|
|
145
150
|
import { registerInteractiveDocChecks } from '../interactive/doc-checks-routes.js';
|
|
146
151
|
import { crewStateHome, stateHomeOfDb } from '../projects/state-home.js';
|
|
147
|
-
import { demoShowOf, factsOf, inputLines, jobInputsOfProposal, jobLaunchCommon, personPid, requestDigest, SELF_SEATED } from './chat-jobs.js';
|
|
152
|
+
import { demoShowOf, factsOf, inputLines, jobInputsOfProposal, jobLaunchCommon, jobLaunchRoster, personPid, requestDigest, SELF_SEATED } from './chat-jobs.js';
|
|
148
153
|
import { DocumentsRefused, documentsClause, RUN_DOCS_TOKENS_MAX, stagedDocumentsOf, stageRunDocuments } from './run-documents.js';
|
|
149
154
|
import { checkSourcePick, projectSources, RUN_SOURCES_MAX, runSourcesDeps, webScopeReason } from './run-sources.js';
|
|
150
155
|
import { CATALOG_V2_CARDS } from '../workflow-catalog/catalog-data-v2.js';
|
|
@@ -167,7 +172,8 @@ import { ATTACHMENT_LIMITS, ATTACHMENT_MAX_MESSAGE_BYTES, AttachmentError, ChatA
|
|
|
167
172
|
import { CHAT_HISTORY_MAX_LIMIT, ChatHistoryStore, decodeCursor } from './chat-history.js';
|
|
168
173
|
import { PROBE_TIMEOUT_MS, SYSTEM_BUDGET_MS, SYSTEM_STATS_DAYS, SYSTEM_STATS_TTL_MS, WeekFoldCache, assembleSnapshot, buildNeeds, buildClis, buildGovernance, diskRow, estateReadonlyCall, infraRow, judgeGaps, livenessThresholds, loadRow, probeBroker, probeBus, probeEstate, probeInteractive, probeVault, readBridgeLockAsync, readWeek, runLiveness, settleWithin, skillsRow, sortRuns, stateHomeRow, reposRow, unfinished, } from './system-snapshot.js';
|
|
169
174
|
import { CLUSTER_TIMEOUT_MS, ClusterStatusReader, clusterDiagnostics, clusterRows } from './cluster-status.js';
|
|
170
|
-
import {
|
|
175
|
+
import { deliveryRow, readDeliveryReadiness } from '../setup/delivery-readiness.js';
|
|
176
|
+
import { idleClis, probeSeatImages, SeatImageRebuilder, seatImageStatusVia } from './seat-images.js';
|
|
171
177
|
import { RunCostCache } from './needs.js';
|
|
172
178
|
import { governanceStoreFix, legacyHomeOutboxPath } from '../core/governance-store.js';
|
|
173
179
|
import { UsageError, replayOutboxInto } from '../cli/governance.js';
|
|
@@ -475,25 +481,24 @@ const ExcludeLinkedIssuesSchema = z
|
|
|
475
481
|
.optional();
|
|
476
482
|
/**
|
|
477
483
|
* F43: the seats a chat job (or a chat document's helpers) may name, and the ones its Start re-checks, in roster order:
|
|
478
|
-
* the seats that can work now (enabled for council, work-eligible, not signed out)
|
|
479
|
-
* ({@link defaultLaunchRoster}: no opt-in seat unless it
|
|
480
|
-
*
|
|
481
|
-
* opt-in rule reads the key.
|
|
484
|
+
* the seats that can work now (enabled for council, work-eligible, not signed out), opt-in seats INCLUDED (crew#1590):
|
|
485
|
+
* naming or picking one is the opt-in. The default launch rule ({@link defaultLaunchRoster}: no opt-in seat unless it
|
|
486
|
+
* is the only one left) applies where nobody chose, the pool work is drawn from (`jobSeatPool`).
|
|
482
487
|
*/
|
|
483
488
|
export function proposalRoster(standing) {
|
|
484
489
|
const canWork = standing.filter((s) => s.enabled_for_council && s.seat_eligible_for_work !== false && s.auth !== 'signed_out');
|
|
485
|
-
return
|
|
490
|
+
return canWork.map((s) => ({ key: String(s.key), name: s.display_name || String(s.key) }));
|
|
486
491
|
}
|
|
487
492
|
/**
|
|
488
493
|
* The default launch roster ({@link defaultLaunchRoster}: no opt-in seats) — plus the opt-in seat a
|
|
489
|
-
* launch NAMES as its lead (`primary`)
|
|
494
|
+
* launch NAMES as its lead (`primary`), and (crew#1590) any other seat it names (`named`: a chat job's card seats):
|
|
495
|
+
* naming it is the opt-in.
|
|
490
496
|
*/
|
|
491
|
-
export function launchRosterNaming(roster, primary) {
|
|
497
|
+
export function launchRosterNaming(roster, primary, named = []) {
|
|
492
498
|
const base = defaultLaunchRoster(roster);
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
return named === undefined ? base : [...base, named];
|
|
499
|
+
const wanted = [primary, ...named].filter((k) => k !== undefined && !base.some((s) => s.key === k));
|
|
500
|
+
const extra = wanted.map((k) => roster.find((s) => s.key === k)).filter((s) => s !== undefined);
|
|
501
|
+
return extra.length === 0 ? base : [...base, ...new Set(extra)];
|
|
497
502
|
}
|
|
498
503
|
/**
|
|
499
504
|
* Why `primary` cannot lead a launch on `clisJson`'s roster, or `null` when it can (DES-TEAMING-002
|
|
@@ -1351,7 +1356,7 @@ runtime = {}) {
|
|
|
1351
1356
|
engine: adapter,
|
|
1352
1357
|
roster: async () => {
|
|
1353
1358
|
await rosterWithStanding.ready?.();
|
|
1354
|
-
return JSON.stringify(launchRosterNaming(rosterWithStanding(), undefined));
|
|
1359
|
+
return JSON.stringify(launchRosterNaming(rosterWithStanding({ launch: true }), undefined));
|
|
1355
1360
|
},
|
|
1356
1361
|
registry: runtime.mcp ?? null,
|
|
1357
1362
|
grantOf: (slug, action) => appsWritePath?.getGrant(slug, action) ?? null,
|
|
@@ -1643,6 +1648,10 @@ runtime = {}) {
|
|
|
1643
1648
|
// driving this function directly (tests) has no hooks, so downstream code
|
|
1644
1649
|
// still gets the ONE actor shape via this accessor.
|
|
1645
1650
|
const actorOf = (req) => req.actor ?? LOCAL_ACTOR;
|
|
1651
|
+
function clientDetail(req) {
|
|
1652
|
+
const userAgent = req.headers['user-agent'];
|
|
1653
|
+
return typeof userAgent === 'string' ? { client: { userAgent: userAgent.slice(0, 200) } } : {};
|
|
1654
|
+
}
|
|
1646
1655
|
// crew#753: the blocking `skills.garden` finding (an installed garden older than the minimum), or
|
|
1647
1656
|
// `null`. Read from the skills runtime's cached health; no seam ⇒ nothing to judge.
|
|
1648
1657
|
const gardenBlocker = () => {
|
|
@@ -2777,7 +2786,7 @@ runtime = {}) {
|
|
|
2777
2786
|
// (`core/engine-roster.ts`), so a signed-out seat is never convened, never a judge.
|
|
2778
2787
|
// (operator ruling 2026-10-11) …minus the opt-in seats (opencode): a launch gets one only
|
|
2779
2788
|
// when it names it.
|
|
2780
|
-
clisJson: b.clisJson ?? JSON.stringify(launchRosterNaming(rosterWithStanding(), b.primary)),
|
|
2789
|
+
clisJson: b.clisJson ?? JSON.stringify(launchRosterNaming(rosterWithStanding({ launch: true }), b.primary)),
|
|
2781
2790
|
};
|
|
2782
2791
|
// A capture launch (api/capture.ts) reads its materials from a per-run inbox outside every
|
|
2783
2792
|
// sandbox: the capture route registered it under the run id it minted.
|
|
@@ -2804,8 +2813,6 @@ runtime = {}) {
|
|
|
2804
2813
|
}
|
|
2805
2814
|
if (b.entityMode !== undefined)
|
|
2806
2815
|
input.entityMode = b.entityMode;
|
|
2807
|
-
if (b.humanConfirm !== undefined)
|
|
2808
|
-
input.humanConfirm = b.humanConfirm;
|
|
2809
2816
|
// F-E2E-030: only the explicit `'auto'` opts out of the engine's deliver gate. `'human'` and
|
|
2810
2817
|
// an omitted field both leave `autoDeliver` off the input — the gate is the engine's default,
|
|
2811
2818
|
// so the wire never has to say "gate me" to be gated.
|
|
@@ -2835,7 +2842,6 @@ runtime = {}) {
|
|
|
2835
2842
|
'(unless the launch explicitly skips QE acceptance with a reason: skipQeAcceptance)',
|
|
2836
2843
|
});
|
|
2837
2844
|
}
|
|
2838
|
-
input.autoDeliver = true;
|
|
2839
2845
|
}
|
|
2840
2846
|
if (b.repoRef !== undefined)
|
|
2841
2847
|
input.repoRef = b.repoRef;
|
|
@@ -2860,95 +2866,35 @@ runtime = {}) {
|
|
|
2860
2866
|
input.projectGraph = decision.binding;
|
|
2861
2867
|
req.log.info({ runId: input.sessionId, projectId: b.projectId, repoRef: b.repoRef ?? null }, `run ${input.sessionId}: ${decision.reason}`);
|
|
2862
2868
|
}
|
|
2863
|
-
// The
|
|
2864
|
-
//
|
|
2865
|
-
//
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
// phase that writes, not chat/onboarding/recon, and not domain-extraction, whose only
|
|
2870
|
-
// code phase is the `coverage` EVALUATOR, which executes code solely to write its own
|
|
2871
|
-
// report into the tree for its validator — nothing to deliver) ⇒ the
|
|
2872
|
-
// daemon's `deliverDefault` setting ('pr' unless the operator flipped it) — the default
|
|
2873
|
-
// that keeps run 83052f0b's work from stranding invisibly again. The code-work guard is
|
|
2874
|
-
// the issue's own scope ("default deliver:'pr' for CODE-WORK launches"): a read-only
|
|
2875
|
-
// workflow leaves a clean worktree, and the deliver script FAILS a clean worktree loudly
|
|
2876
|
-
// ("nothing to deliver", crew#317) — defaulting it on would flip every repo-scoped chat
|
|
2877
|
-
// from completed to failed;
|
|
2878
|
-
// - omitted otherwise ⇒ 'none': a repo-less run has no worktree to lift, and a free-text
|
|
2879
|
-
// run has no def to append the deliver phase to (the adapter REFUSES deliver:'pr'
|
|
2880
|
-
// without a workflow rather than silently dropping it, so defaulting it on would turn
|
|
2881
|
-
// a legal launch into a 400).
|
|
2882
|
-
// The adapter input spells 'none' as an omitted field; the audit entry below records the
|
|
2883
|
-
// RESOLVED value either way, plus whether it was defaulted.
|
|
2884
|
-
let deliver;
|
|
2885
|
-
let deliverDefaulted = false;
|
|
2886
|
-
if (b.deliver !== undefined) {
|
|
2887
|
-
deliver = b.deliver;
|
|
2888
|
-
}
|
|
2889
|
-
else if (b.repoRef !== undefined && b.workflow !== undefined) {
|
|
2890
|
-
// Unknown def ⇒ no default (the launch fails at workflow resolution with its own error —
|
|
2891
|
-
// defaulting 'pr' onto it would swap that for a misleading deliver-flavored one).
|
|
2892
|
-
const def = adapter.getWorkflow(b.workflow);
|
|
2893
|
-
const codeWork = def !== null &&
|
|
2894
|
-
def.phases.some((p) => p.executes_code === true && p.role !== 'evaluator');
|
|
2895
|
-
deliver =
|
|
2896
|
-
codeWork && (await adapter.getSettings()).deliverDefault !== 'none' ? 'pr' : 'none';
|
|
2897
|
-
deliverDefaulted = true;
|
|
2898
|
-
}
|
|
2899
|
-
else {
|
|
2900
|
-
deliver = 'none';
|
|
2901
|
-
deliverDefaulted = true;
|
|
2902
|
-
}
|
|
2869
|
+
// (studio#1150) The launch's human gates — power, the posture the engine keeps, delivery and its gate — are ONE
|
|
2870
|
+
// decision (`core/launch-posture.ts`), the same one `POST /runs/preview` answers for this body, so a launch form
|
|
2871
|
+
// shows what the run keeps. The rules (crew#393 delivery, DES-POWER-MODE, F-E2E-030) are documented there.
|
|
2872
|
+
const posture = await launchPosture(b, postureFacts, { powerRequired: ctx.powerRequired });
|
|
2873
|
+
let deliver = posture.resolvedDeliver;
|
|
2874
|
+
const deliverDefaulted = posture.deliverDefaulted;
|
|
2903
2875
|
if (deliver === 'pr')
|
|
2904
2876
|
input.deliver = 'pr';
|
|
2877
|
+
if (posture.autoDeliver)
|
|
2878
|
+
input.autoDeliver = true;
|
|
2905
2879
|
// wicked-core#850 EX-01/EX-02: forwarded only when the caller sent it — crew never waives
|
|
2906
2880
|
// assurance on anyone's behalf (a one-CLI launch that did not is TOLD so in its answer, below).
|
|
2907
2881
|
if (b.reducedAssurance === true)
|
|
2908
2882
|
input.reducedAssurance = true;
|
|
2909
|
-
|
|
2910
|
-
//
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
if (b.repoRef === undefined || !isPreset) {
|
|
2925
|
-
powerNotice = 'power mode runs a repo-scoped plan or preset launch; this launch runs phased';
|
|
2926
|
-
}
|
|
2927
|
-
else if (!powerSupported()) {
|
|
2928
|
-
powerNotice = 'this engine has no power mode; the launch runs phased';
|
|
2929
|
-
}
|
|
2930
|
-
else if (ctx.powerRequired === true && ((await adapter.getSettings()).powerModeDefault ?? true) === false) {
|
|
2931
|
-
// A chat job's power Start follows the setting up to the engine call (it may have been turned off meanwhile).
|
|
2932
|
-
powerNotice = 'Power mode for new jobs is off on this daemon; the launch runs phased';
|
|
2933
|
-
}
|
|
2934
|
-
// A chat job's power Start is never run phased in its place (the person chose no plan review for a power run).
|
|
2935
|
-
if (powerNotice !== null && ctx.powerRequired === true) {
|
|
2936
|
-
return reply.code(409).send({ code: 'power_unavailable', error: `${powerNotice.replace(/; this launch runs phased|; the launch runs phased/u, '')}; press Start with Review plan on` });
|
|
2937
|
-
}
|
|
2938
|
-
if (powerNotice === null) {
|
|
2939
|
-
input.power = true;
|
|
2940
|
-
// (studio#1150) A power run asks once, at hand-off: a posture the launch named is not kept — and the answer says so.
|
|
2941
|
-
if (input.humanConfirm !== undefined && input.humanConfirm !== 'none') {
|
|
2942
|
-
humanConfirmNotice = `power mode asks once, at hand-off: humanConfirm ${input.humanConfirm} is not kept (launch with power: false to keep it)`;
|
|
2943
|
-
}
|
|
2944
|
-
input.humanConfirm = 'none';
|
|
2945
|
-
// DES-LEARN §3.3 / wicked-core#1216: the orchestrator talks to the person in their personality
|
|
2946
|
-
// for this project (the project's override, else theirs). The engine hands it to the
|
|
2947
|
-
// orchestrator only; reviewers, judges and QE never hear it.
|
|
2948
|
-
const { voice } = voiceFor(b.projectId);
|
|
2949
|
-
if (voice !== undefined)
|
|
2950
|
-
input.voice = voice;
|
|
2951
|
-
}
|
|
2883
|
+
const { powerNotice, humanConfirmNotice } = posture;
|
|
2884
|
+
// A chat job's power Start is never run phased in its place (the person chose no plan review for a power run).
|
|
2885
|
+
if (posture.powerRefusal !== null) {
|
|
2886
|
+
return reply.code(409).send({ code: 'power_unavailable', error: posture.powerRefusal });
|
|
2887
|
+
}
|
|
2888
|
+
if (posture.humanConfirm !== undefined)
|
|
2889
|
+
input.humanConfirm = posture.humanConfirm;
|
|
2890
|
+
if (posture.power) {
|
|
2891
|
+
input.power = true;
|
|
2892
|
+
// DES-LEARN §3.3 / wicked-core#1216: the orchestrator talks to the person in their personality
|
|
2893
|
+
// for this project (the project's override, else theirs). The engine hands it to the
|
|
2894
|
+
// orchestrator only; reviewers, judges and QE never hear it.
|
|
2895
|
+
const { voice } = voiceFor(b.projectId);
|
|
2896
|
+
if (voice !== undefined)
|
|
2897
|
+
input.voice = voice;
|
|
2952
2898
|
}
|
|
2953
2899
|
// QE-IN-APP-WORKFLOWS: the operator's explicit skip (with its reason) or force — forwarded only
|
|
2954
2900
|
// when sent, never inferred.
|
|
@@ -3194,7 +3140,7 @@ runtime = {}) {
|
|
|
3194
3140
|
}
|
|
3195
3141
|
deliver = 'none';
|
|
3196
3142
|
}
|
|
3197
|
-
const isReview = b.workflow
|
|
3143
|
+
const isReview = b.workflow !== undefined && reviewPrepared(b.workflow);
|
|
3198
3144
|
if (isReview) {
|
|
3199
3145
|
try {
|
|
3200
3146
|
await runtime.reviewLaunch(input);
|
|
@@ -3535,6 +3481,40 @@ runtime = {}) {
|
|
|
3535
3481
|
const out = await launchRun(req.body, { actor: actorOf(req), log: req.log });
|
|
3536
3482
|
return reply.code(out.statusCode).send(out.payload);
|
|
3537
3483
|
});
|
|
3484
|
+
// (studio#1150) What a launch of this body would keep of its human gates — the SAME `launchPosture` decision
|
|
3485
|
+
// `POST /runs` hands the engine — with nothing launched, recorded or read beyond what that decision reads. A launch
|
|
3486
|
+
// form renders it (and sends the `power` it shows) instead of modelling crew's rules.
|
|
3487
|
+
const LaunchPreviewSchema = z.strictObject({
|
|
3488
|
+
power: z.boolean().optional(),
|
|
3489
|
+
repoRef: z.string().min(1).optional(),
|
|
3490
|
+
workflow: z.string().min(1).optional(),
|
|
3491
|
+
plan: PlanSchema.optional(),
|
|
3492
|
+
projectId: z.string().min(1).optional(),
|
|
3493
|
+
humanConfirm: z.string().min(1).optional(),
|
|
3494
|
+
deliver: z.enum(['pr', 'none']).optional(),
|
|
3495
|
+
deliverGate: z.enum(['human', 'auto']).optional(),
|
|
3496
|
+
}).refine((b) => b.plan === undefined || b.workflow === undefined, {
|
|
3497
|
+
path: ['plan'],
|
|
3498
|
+
error: 'plan and workflow are mutually exclusive',
|
|
3499
|
+
}).refine((b) => b.deliverGate === undefined || b.deliver !== 'none', {
|
|
3500
|
+
path: ['deliverGate'],
|
|
3501
|
+
error: 'deliverGate has no meaning with deliver: "none" — there is no deliver phase to gate',
|
|
3502
|
+
});
|
|
3503
|
+
app.post(`${V}/runs/preview`, { config: { manifest: { requestType: 'LaunchPreviewBody', responseType: 'LaunchPreviewResponse', statusCodes: [200, 400] } } }, async (req, reply) => {
|
|
3504
|
+
const parsed = LaunchPreviewSchema.safeParse(req.body ?? {});
|
|
3505
|
+
if (!parsed.success)
|
|
3506
|
+
return reply.code(400).send(invalidBody(parsed.error, 'Invalid request body'));
|
|
3507
|
+
const p = await launchPosture(parsed.data, postureFacts);
|
|
3508
|
+
const posture = {
|
|
3509
|
+
power: p.power,
|
|
3510
|
+
...(p.humanConfirm !== undefined ? { humanConfirm: p.humanConfirm } : {}),
|
|
3511
|
+
deliver: p.deliver,
|
|
3512
|
+
autoDeliver: p.autoDeliver,
|
|
3513
|
+
...(p.powerNotice !== null ? { powerNotice: p.powerNotice } : {}),
|
|
3514
|
+
...(p.humanConfirmNotice !== null ? { humanConfirmNotice: p.humanConfirmNotice } : {}),
|
|
3515
|
+
};
|
|
3516
|
+
return { posture };
|
|
3517
|
+
});
|
|
3538
3518
|
/**
|
|
3539
3519
|
* (DES-CATALOG-002 §4.6) The `job` launcher: a chat job proposal's Go, one launcher per launch kind, each with the
|
|
3540
3520
|
* identity derived from the proposal (`sessionId` = its run id, so a retry finds and adopts it), the chat filing, the
|
|
@@ -3602,30 +3582,16 @@ runtime = {}) {
|
|
|
3602
3582
|
if (resolved === null)
|
|
3603
3583
|
throw new Error(`${p.what.label} is no longer in the catalog`);
|
|
3604
3584
|
const selfSeated = resolved.workflow !== null && SELF_SEATED.has(resolved.workflow);
|
|
3605
|
-
// The seats the person saw: the lead, and the roster narrowed to the proposal's keys.
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
//
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
if (Array.isArray(parsedRoster))
|
|
3614
|
-
inherited = parsedRoster;
|
|
3615
|
-
}
|
|
3616
|
-
catch {
|
|
3617
|
-
inherited = null;
|
|
3618
|
-
}
|
|
3619
|
-
}
|
|
3620
|
-
const current = launchRosterNaming(rosterWithStanding(), lead);
|
|
3621
|
-
// Inherited configuration for the seats it names; the current roster's entry for a seat added since (codex r3).
|
|
3622
|
-
const roster = inherited === null ? current : [...inherited, ...current.filter((s) => !inherited.some((i) => i.key === s.key))];
|
|
3623
|
-
const narrowed = keys.length > 0 ? roster.filter((s) => keys.includes(String(s.key))) : roster;
|
|
3624
|
-
const missingSeat = keys.find((k) => !roster.some((s) => String(s.key) === k));
|
|
3625
|
-
if (missingSeat !== undefined)
|
|
3626
|
-
throw new Error(`${missingSeat} is not on this daemon's roster; change who works on it`);
|
|
3585
|
+
// The seats the person saw: the lead, and the roster narrowed to the proposal's keys (`jobLaunchRoster`).
|
|
3586
|
+
// crew#645 / crew#1593 (coord merge check): the card says WHICH seats, never that they are usable now. The same
|
|
3587
|
+
// bounded readiness wait a launch with no roster gets runs FIRST, so the standing serialized here (and the lead's
|
|
3588
|
+
// eligibility `launchRun` checks against it) is the seats' own fresh answer: a lead whose login expired is refused
|
|
3589
|
+
// by name, never launched on a stale snapshot. A seat added meanwhile still doesn't join (narrowed to the card).
|
|
3590
|
+
await rosterWithStanding.ready?.();
|
|
3591
|
+
// crew#1590: every seat on the card is named, so an opt-in seat the person picked is on the roster too.
|
|
3592
|
+
const { clisJson } = jobLaunchRoster(launchRosterNaming(rosterWithStanding({ launch: true }), p.seats?.lead ?? undefined, p.seats?.keys ?? []), p);
|
|
3627
3593
|
const common = jobLaunchCommon(p, { runId: d.identity.runId, chatId: d.chatId }, {
|
|
3628
|
-
...(
|
|
3594
|
+
...(clisJson !== undefined ? { clisJson } : {}),
|
|
3629
3595
|
selfSeated,
|
|
3630
3596
|
});
|
|
3631
3597
|
// A power Start was checked before accepting; checked again here, so it never runs phased behind the person's back.
|
|
@@ -4036,6 +4002,11 @@ runtime = {}) {
|
|
|
4036
4002
|
repoDeliverChain.delete(repoRef);
|
|
4037
4003
|
}
|
|
4038
4004
|
};
|
|
4005
|
+
registerRedeliverRoutes(app, {
|
|
4006
|
+
adapter, index: deliveryIndex, audit, freeze: deliveryFreeze, actorOf, repoRootOf, withRepoDeliverLock,
|
|
4007
|
+
ghExec: runtime.redeliverGhExec, exec: runtime.redeliverExec, checkRunTree: runtime.checkRunTree,
|
|
4008
|
+
identityFor: async (ref) => deliverIdentityFor(await adapter.getSettings(), ref).login || undefined,
|
|
4009
|
+
});
|
|
4039
4010
|
/** The last words of a failed deliver script — enough to name the refusal, bounded so a full
|
|
4040
4011
|
* git transcript never becomes an error body. */
|
|
4041
4012
|
const deliverErrorTail = (output) => {
|
|
@@ -4438,7 +4409,8 @@ runtime = {}) {
|
|
|
4438
4409
|
// proposal, completing the proposal while the chat is open; never open the id again (codex r1).
|
|
4439
4410
|
const open = askPaths.get(seedChatId) !== undefined || chatScopes.get(seedChatId) !== undefined;
|
|
4440
4411
|
if (open || chatHistory?.has(seedChatId) === true) {
|
|
4441
|
-
|
|
4412
|
+
const stored = chatProposals.viewOfPid(seedChatId, personPid(seedChatId, seedActor.id, b.requestId));
|
|
4413
|
+
let view = stored === null ? null : await chatProposals.servedView(stored);
|
|
4442
4414
|
// The same request id with another seed is not a retry (codex r2).
|
|
4443
4415
|
if (view !== null && view.proposal.request?.digest !== requestDigest(seedBody(b.seed, b.requestId))) {
|
|
4444
4416
|
return reply.code(409).send({ code: 'request_reused', error: 'this requestId already started a chat with another job', chatId: seedChatId });
|
|
@@ -4691,10 +4663,10 @@ runtime = {}) {
|
|
|
4691
4663
|
'the run cannot bind; scope the ask to one repository, sign a seat in, or open it unscoped'
|
|
4692
4664
|
: refused.some((r) => r.source === 'engine')
|
|
4693
4665
|
? 'no seat picked for this ask can take a turn: every one is signed out, disabled, or benched by the ' +
|
|
4694
|
-
'engine in a recent run (out of quota, say); sign another seat in from the
|
|
4666
|
+
'engine in a recent run (out of quota, say); sign another seat in from the Helpers page, turn one ' +
|
|
4695
4667
|
'back on, or wait for the bench to lift'
|
|
4696
4668
|
: 'no seat in the roster can take a turn (every seat is signed out or disabled); sign a seat ' +
|
|
4697
|
-
'in from the
|
|
4669
|
+
'in from the Helpers page, or name seats with `clis`') + ' — see refused',
|
|
4698
4670
|
refused,
|
|
4699
4671
|
});
|
|
4700
4672
|
}
|
|
@@ -4963,6 +4935,8 @@ runtime = {}) {
|
|
|
4963
4935
|
};
|
|
4964
4936
|
},
|
|
4965
4937
|
rosterEligible: () => proposalRoster(rosterWithStanding()),
|
|
4938
|
+
// (F1/F2) Agents › "Use <seat> for new work": the pool every new chat job and document is drawn from.
|
|
4939
|
+
newWorkSeats: readNewWorkSeats,
|
|
4966
4940
|
runs: async () => (await adapter.sessionsDetail()).map((v) => decorateRun(v)),
|
|
4967
4941
|
chatOfRun: (runId) => runTimingIndex.chatIdFor(runId),
|
|
4968
4942
|
isAskPath: (runId) => runTimingIndex.isAskPath(runId),
|
|
@@ -5820,7 +5794,9 @@ runtime = {}) {
|
|
|
5820
5794
|
// turn. The file goes with the chat on `chatClosed` UNLESS a run promoted from it is still
|
|
5821
5795
|
// live (crew#619 retention — dropped when that run terminals), so a reclaimed id answers
|
|
5822
5796
|
// `[]` only once no promoted run holds the old file.
|
|
5823
|
-
|
|
5797
|
+
// (F1/F2) Served like `GET /chats/:id/messages`: an open job or document reads blocked while `newWorkSeats`
|
|
5798
|
+
// can't be honored.
|
|
5799
|
+
...(chatTranscripts !== undefined ? { messages: await chatProposals.withSeatsSetting(chatTranscripts.read(id)) } : {}),
|
|
5824
5800
|
};
|
|
5825
5801
|
}
|
|
5826
5802
|
catch (err) {
|
|
@@ -5950,7 +5926,8 @@ runtime = {}) {
|
|
|
5950
5926
|
const messages = chat === null ? null : chatHistory.messages(id);
|
|
5951
5927
|
if (chat === null || messages === null)
|
|
5952
5928
|
return reply.code(404).send({ error: `no chat ${id} in this daemon's history` });
|
|
5953
|
-
|
|
5929
|
+
// (F1/F2) An open job or document reads blocked while `newWorkSeats` can't be honored: a live state, read now.
|
|
5930
|
+
return { chat, messages: await chatProposals.withSeatsSetting(messages), attachments: chatAttachments.list(id) };
|
|
5954
5931
|
});
|
|
5955
5932
|
// DES-SYSTEM-CHAT (api-types 0.137.0): upload files to a chat (multipart/form-data). The body is
|
|
5956
5933
|
// buffered by a parser scoped to this route alone, capped a little over the per-message total;
|
|
@@ -6697,6 +6674,7 @@ runtime = {}) {
|
|
|
6697
6674
|
runId: id,
|
|
6698
6675
|
detail: {
|
|
6699
6676
|
approve: parsed.data.approve,
|
|
6677
|
+
choice: parsed.data.action ?? (parsed.data.approve ? 'approve' : 'reject'),
|
|
6700
6678
|
...(parsed.data.amend !== undefined ? { amend: parsed.data.amend } : {}),
|
|
6701
6679
|
...(parsed.data.action !== undefined ? { action: parsed.data.action } : {}),
|
|
6702
6680
|
...(parsed.data.amendScope !== undefined ? { amendScope: parsed.data.amendScope } : {}),
|
|
@@ -6787,7 +6765,7 @@ runtime = {}) {
|
|
|
6787
6765
|
},
|
|
6788
6766
|
}, async (req, reply) => {
|
|
6789
6767
|
const { id } = req.params;
|
|
6790
|
-
const out = await decideGate(id, req.body, actorOf(req));
|
|
6768
|
+
const out = await decideGate(id, req.body, actorOf(req), clientDetail(req));
|
|
6791
6769
|
return reply.code(out.code).send(out.body);
|
|
6792
6770
|
});
|
|
6793
6771
|
/**
|
|
@@ -6983,7 +6961,7 @@ runtime = {}) {
|
|
|
6983
6961
|
// "who approved" trail has no side door (task #88).
|
|
6984
6962
|
audit.record(gated ? 'gate.decided' : 'run.resumed', actorOf(req), {
|
|
6985
6963
|
runId: id,
|
|
6986
|
-
detail: gated ? { approve: true, via: 'resume', status } : { status },
|
|
6964
|
+
detail: gated ? { approve: true, via: 'resume', ...clientDetail(req), status } : { status },
|
|
6987
6965
|
});
|
|
6988
6966
|
const landing = steeringPropose
|
|
6989
6967
|
? await landSteeringProposal({ adapter, audit, actor: actorOf(req) }, run, gatePrompt)
|
|
@@ -7062,6 +7040,47 @@ runtime = {}) {
|
|
|
7062
7040
|
function powerSupported() {
|
|
7063
7041
|
return typeof adapter.supportsPowerMode === 'function' && adapter.supportsPowerMode();
|
|
7064
7042
|
}
|
|
7043
|
+
/** A hand launch of the run review is prepared by the daemon (DES-RUNS-REVIEW-001 §3) when it carries the review service. */
|
|
7044
|
+
function reviewPrepared(workflow) {
|
|
7045
|
+
return workflow === REVIEW_WORKFLOW && runtime.reviewLaunch !== undefined;
|
|
7046
|
+
}
|
|
7047
|
+
/** (studio#1150) What `launchPosture` reads of this daemon, for `POST /runs` and `POST /runs/preview` alike. */
|
|
7048
|
+
const postureFacts = {
|
|
7049
|
+
powerModeDefault: async () => (await adapter.getSettings()).powerModeDefault ?? true,
|
|
7050
|
+
namesPreset,
|
|
7051
|
+
powerSupported,
|
|
7052
|
+
// The delivery contract (crew#393): a completed code run must end with a reviewable
|
|
7053
|
+
// deliverable, or an explicit, recorded decision not to. So the deliver option is resolved
|
|
7054
|
+
// HERE, at the boundary, for every launch:
|
|
7055
|
+
// - explicit 'pr' / 'none' wins (the operator decided);
|
|
7056
|
+
// - omitted + repo-scoped + a CODE-WORK workflow (the def carries at least one
|
|
7057
|
+
// `executes_code` phase that is NOT an evaluator — feature/bug/migration and a Tool
|
|
7058
|
+
// phase that writes, not chat/onboarding/recon, and not domain-extraction, whose only
|
|
7059
|
+
// code phase is the `coverage` EVALUATOR, which executes code solely to write its own
|
|
7060
|
+
// report into the tree for its validator — nothing to deliver) ⇒ the
|
|
7061
|
+
// daemon's `deliverDefault` setting ('pr' unless the operator flipped it) — the default
|
|
7062
|
+
// that keeps run 83052f0b's work from stranding invisibly again. The code-work guard is
|
|
7063
|
+
// the issue's own scope ("default deliver:'pr' for CODE-WORK launches"): a read-only
|
|
7064
|
+
// workflow leaves a clean worktree, and the deliver script FAILS a clean worktree loudly
|
|
7065
|
+
// ("nothing to deliver", crew#317) — defaulting it on would flip every repo-scoped chat
|
|
7066
|
+
// from completed to failed;
|
|
7067
|
+
// - omitted otherwise ⇒ 'none': a repo-less run has no worktree to lift, and a free-text
|
|
7068
|
+
// run has no def to append the deliver phase to (the adapter REFUSES deliver:'pr'
|
|
7069
|
+
// without a workflow rather than silently dropping it, so defaulting it on would turn
|
|
7070
|
+
// a legal launch into a 400).
|
|
7071
|
+
// The adapter input spells 'none' as an omitted field; the audit entry below records the
|
|
7072
|
+
// RESOLVED value either way, plus whether it was defaulted.
|
|
7073
|
+
deliverDefault: async (workflow) => {
|
|
7074
|
+
// Unknown def ⇒ no default (the launch fails at workflow resolution with its own error —
|
|
7075
|
+
// defaulting 'pr' onto it would swap that for a misleading deliver-flavored one).
|
|
7076
|
+
const def = adapter.getWorkflow(workflow);
|
|
7077
|
+
const codeWork = def !== null && def.phases.some((p) => p.executes_code === true && p.role !== 'evaluator');
|
|
7078
|
+
return codeWork && (await adapter.getSettings()).deliverDefault !== 'none' ? 'pr' : 'none';
|
|
7079
|
+
},
|
|
7080
|
+
// The launch route removes a change review's delivery (it posts nothing), and a run review's preparation removes it
|
|
7081
|
+
// (`ReviewService.prepareLaunch`). The default evals' preparation keeps whatever delivery was resolved.
|
|
7082
|
+
preparationDropsDelivery: (workflow) => workflow === REVIEW_CHANGE_WORKFLOW || reviewPrepared(workflow),
|
|
7083
|
+
};
|
|
7065
7084
|
// ── Power mode (program DES-POWER-MODE; api-types 0.149.0) ─────────────────────────────────────
|
|
7066
7085
|
// The engine computes every rigor value; these routes only carry a person's switch, raise or pause
|
|
7067
7086
|
// answer to it (human actors only: a worker or plugin bearer gets 403) and read its record back.
|
|
@@ -7390,7 +7409,7 @@ runtime = {}) {
|
|
|
7390
7409
|
noteRode = note !== undefined;
|
|
7391
7410
|
audit.record('gate.decided', actorOf(req), {
|
|
7392
7411
|
runId: id,
|
|
7393
|
-
detail: { approve: true, via: 'reassign', status },
|
|
7412
|
+
detail: { approve: true, via: 'reassign', ...clientDetail(req), status },
|
|
7394
7413
|
});
|
|
7395
7414
|
};
|
|
7396
7415
|
const reassigned = (approved) => {
|
|
@@ -7465,12 +7484,11 @@ runtime = {}) {
|
|
|
7465
7484
|
// await sees a change the adapter learned of during it (a frame, or a write it made); any other
|
|
7466
7485
|
// change is at most the snapshot's age bound old.
|
|
7467
7486
|
const runOf = () => adapter.runView(id);
|
|
7468
|
-
// wicked-core#850: the gate answer carries the gated unit's receipt — what assured the work it asks about.
|
|
7469
|
-
const unitAt = async (ord) => (await runOf())?.units?.find((u) => u.ord === ord);
|
|
7470
7487
|
// (rejudge, api-types 0.134.0) A gate whose unit no judge could rule on says whether its judge
|
|
7471
7488
|
// can be re-run now, and from which seats — the engine's own selection, read each time (a seat
|
|
7472
7489
|
// signed in since the pause counts). Absent on every other gate and on an addon without the read.
|
|
7473
|
-
const rejudgeAt = async (ord,
|
|
7490
|
+
const rejudgeAt = async (ord, run) => {
|
|
7491
|
+
const gated = run?.units?.find((u) => u.ord === ord);
|
|
7474
7492
|
const denial = gated?.denial;
|
|
7475
7493
|
if (gated?.status !== 'rejected' || denial?.source !== 'judge_unavailable')
|
|
7476
7494
|
return {};
|
|
@@ -7491,10 +7509,10 @@ runtime = {}) {
|
|
|
7491
7509
|
// PLACE: `{approve: true, action: 'skip_qe', amend: <reason>, ord}` on this gate, labelled on
|
|
7492
7510
|
// the run, every later gate and the delivery — never a relaunch. Read each time (a PASS
|
|
7493
7511
|
// recorded since the pause withdraws it). Absent on every other gate.
|
|
7494
|
-
const skipQeAt = async (
|
|
7512
|
+
const skipQeAt = async (ord, run) => {
|
|
7513
|
+
const gated = run?.units?.find((u) => u.ord === ord);
|
|
7495
7514
|
if (gated === undefined || !isDeliverUnit(gated))
|
|
7496
7515
|
return {};
|
|
7497
|
-
const run = await runOf();
|
|
7498
7516
|
if (run === undefined)
|
|
7499
7517
|
return {};
|
|
7500
7518
|
const decision = qeDecisionOf(run);
|
|
@@ -7515,26 +7533,56 @@ runtime = {}) {
|
|
|
7515
7533
|
};
|
|
7516
7534
|
// (crew#1512, studio#1170) EVERY ANSWER THIS GATE TAKES NOW: the engine's own list (each candidate run
|
|
7517
7535
|
// through its decision path's pre-checks), less what crew refuses itself (`crewGateActions`). Read each
|
|
7518
|
-
// time; absent on an addon without the read
|
|
7519
|
-
|
|
7536
|
+
// time; absent only on an addon without the read. A failed or moved read gets one retry, then
|
|
7537
|
+
// a retryable 503 (crew#1579), so a skin cannot mistake an unavailable list for no capability.
|
|
7538
|
+
// crew#1634: a mismatch that cannot heal is not retryable: with no open gate row the ord comes from the
|
|
7539
|
+
// cache or the log while the engine names its cursor's (or 0), and an unknown run has no engine list at
|
|
7540
|
+
// all. Those answer the gate without `actions` (the old fallback); a thrown read stays a 503.
|
|
7541
|
+
const actionsAt = async (ord, run) => {
|
|
7520
7542
|
if (typeof adapter.gateActions !== 'function')
|
|
7521
7543
|
return {};
|
|
7522
|
-
|
|
7523
|
-
|
|
7524
|
-
|
|
7544
|
+
let threw = false;
|
|
7545
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
7546
|
+
let listed;
|
|
7547
|
+
try {
|
|
7548
|
+
listed = await adapter.gateActions(id);
|
|
7549
|
+
}
|
|
7550
|
+
catch {
|
|
7551
|
+
threw = true;
|
|
7552
|
+
continue;
|
|
7553
|
+
}
|
|
7554
|
+
if (listed === null)
|
|
7525
7555
|
return {};
|
|
7526
|
-
|
|
7556
|
+
if (listed.ord !== ord)
|
|
7557
|
+
continue;
|
|
7527
7558
|
if (run === undefined)
|
|
7528
7559
|
return {};
|
|
7560
|
+
const gated = run.units?.find((u) => u.ord === ord);
|
|
7529
7561
|
return {
|
|
7530
7562
|
actions: await crewGateActions(run, gated, listed.gateKind, listed.actions),
|
|
7531
7563
|
...(listed.planRev !== undefined ? { planRev: listed.planRev } : {}),
|
|
7532
7564
|
};
|
|
7533
7565
|
}
|
|
7534
|
-
|
|
7535
|
-
|
|
7536
|
-
|
|
7537
|
-
|
|
7566
|
+
// Persistent only if it still holds NOW: a gate that opened or advanced during the read shows as an open row on
|
|
7567
|
+
// this durable re-read, and that is a race, so 503 whatever the run snapshot says (it may predate the run).
|
|
7568
|
+
if (threw)
|
|
7569
|
+
return null;
|
|
7570
|
+
return (await recordedOpenGate(id))?.state === 'open' ? null : {};
|
|
7571
|
+
};
|
|
7572
|
+
const actionsUnavailable = {
|
|
7573
|
+
error: 'Gate actions unavailable: the engine\'s answers for this gate could not be read consistently — retry.',
|
|
7574
|
+
code: 'gate_actions_unavailable',
|
|
7575
|
+
};
|
|
7576
|
+
const unavailable503 = () => reply.header('Retry-After', '1').code(503).send(actionsUnavailable);
|
|
7577
|
+
// crew#1629: start the engine's action read immediately, alongside the other offers. Every
|
|
7578
|
+
// offer and the receipt use the run already in hand; the record/cache overlap reads stay separate.
|
|
7579
|
+
const offersAt = async (ord, run) => {
|
|
7580
|
+
const gated = run?.units?.find((u) => u.ord === ord);
|
|
7581
|
+
const actions = actionsAt(ord, run);
|
|
7582
|
+
const [rejudge, skipQe, listed] = await Promise.all([rejudgeAt(ord, run), skipQeAt(ord, run), actions]);
|
|
7583
|
+
if (listed === null)
|
|
7584
|
+
return null;
|
|
7585
|
+
return { assurance: receiptOf(gated), ...rejudge, ...skipQe, ...listed };
|
|
7538
7586
|
};
|
|
7539
7587
|
// The record judges the cache (crew#1083 round 7): rows that disagree on the ord are 409
|
|
7540
7588
|
// `gate_unknown` whether or not something is cached, and a cached entry is served — for its
|
|
@@ -7557,9 +7605,10 @@ runtime = {}) {
|
|
|
7557
7605
|
|| (recorded.state === 'open' && cached.ord === recorded.ord)
|
|
7558
7606
|
|| (recorded.state === 'none' && (await runOf())?.session.status === 'awaiting_human');
|
|
7559
7607
|
if (servable) {
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7608
|
+
const offers = await offersAt(cached.ord, await runOf());
|
|
7609
|
+
if (offers === null)
|
|
7610
|
+
return unavailable503();
|
|
7611
|
+
return { runId: id, ...cached, ...offers };
|
|
7563
7612
|
}
|
|
7564
7613
|
gateCache.forget(id);
|
|
7565
7614
|
}
|
|
@@ -7635,8 +7684,10 @@ runtime = {}) {
|
|
|
7635
7684
|
// genuinely lost), as does a gate whose `awaitingHuman` predates the log's retention.
|
|
7636
7685
|
return reply.code(404).send({ error: 'No open gate for this run' });
|
|
7637
7686
|
}
|
|
7638
|
-
const
|
|
7639
|
-
|
|
7687
|
+
const offers = await offersAt(open.ord, run);
|
|
7688
|
+
if (offers === null)
|
|
7689
|
+
return unavailable503();
|
|
7690
|
+
return { runId: id, ...open, ...offers };
|
|
7640
7691
|
});
|
|
7641
7692
|
// ── Elicitation (DES-002) ────────────────────────────────────────────────────
|
|
7642
7693
|
//
|
|
@@ -9099,6 +9150,16 @@ runtime = {}) {
|
|
|
9099
9150
|
return reply.code(403).send({ error: 'Only a person can change the power mode default (powerModeDefault)' });
|
|
9100
9151
|
}
|
|
9101
9152
|
}
|
|
9153
|
+
// newWorkSeats (F1/F2): which seats new chats and jobs are drawn from (`core/job-seats.ts`). A list of seat keys,
|
|
9154
|
+
// or null for the default rule; a person's choice only (a worker's bearer gets 403).
|
|
9155
|
+
if (Object.hasOwn(patch, 'newWorkSeats')) {
|
|
9156
|
+
if (patch.newWorkSeats !== null && !isSeatKeyList(patch.newWorkSeats)) {
|
|
9157
|
+
return reply.code(400).send({ error: 'newWorkSeats must be a list of seat keys (at most 64), or null' });
|
|
9158
|
+
}
|
|
9159
|
+
if (!isHumanOperator(actorOf(req))) {
|
|
9160
|
+
return reply.code(403).send({ error: 'Only a person can change which seats new work uses (newWorkSeats)' });
|
|
9161
|
+
}
|
|
9162
|
+
}
|
|
9102
9163
|
// qeAcceptance (api-types 0.120.0): 'required' | 'off' only. 'off' skips QE acceptance on every
|
|
9103
9164
|
// launch that requires it (labelled with the setting), so a typo must be a 400, never a dropped key.
|
|
9104
9165
|
// Turning it off waives an assurance instrument on every launch after it, so only a PERSON may
|
|
@@ -9181,7 +9242,11 @@ runtime = {}) {
|
|
|
9181
9242
|
const problem = registry.validateSettingsPatch(patch.watch);
|
|
9182
9243
|
if (problem !== null)
|
|
9183
9244
|
return reply.code(400).send({ error: problem });
|
|
9184
|
-
|
|
9245
|
+
// The merge runs INSIDE the settings write (crew#1591), against the stored `watch` it
|
|
9246
|
+
// replaces — merging over an earlier read would let two people's switches revert each other.
|
|
9247
|
+
const watchPatch = patch.watch;
|
|
9248
|
+
const at = Date.now();
|
|
9249
|
+
watchNext = (current) => registry.mergeSettings(current.watch, watchPatch, actor.id, at);
|
|
9185
9250
|
}
|
|
9186
9251
|
// Only known engine keys and validated `studio.*` keys are persisted. A key that is
|
|
9187
9252
|
// NEITHER is dropped, not refused: request bodies are forward-additive too (DES-STUDIO-001
|
|
@@ -9199,6 +9264,7 @@ runtime = {}) {
|
|
|
9199
9264
|
'deliverDefault',
|
|
9200
9265
|
'qeAcceptance',
|
|
9201
9266
|
'powerModeDefault',
|
|
9267
|
+
'newWorkSeats',
|
|
9202
9268
|
'onboardingAutoCapture',
|
|
9203
9269
|
'deliverIdentityLogin',
|
|
9204
9270
|
'deliverIdentityByRepo',
|
|
@@ -9223,13 +9289,16 @@ runtime = {}) {
|
|
|
9223
9289
|
for (const key of studioKeys) {
|
|
9224
9290
|
safe[key] = patch[key];
|
|
9225
9291
|
}
|
|
9226
|
-
if (watchNext !== undefined)
|
|
9227
|
-
safe.watch = watchNext;
|
|
9228
9292
|
// `Object.hasOwn`, NOT `k in safe`: `in` walks the prototype chain, so a dropped key named
|
|
9229
9293
|
// `toString` / `valueOf` / `constructor` would test as "kept" and vanish from `ignored` —
|
|
9230
9294
|
// the exact silent drop this route exists to end.
|
|
9231
|
-
|
|
9232
|
-
const
|
|
9295
|
+
// `watch` is merged inside the write (crew#1591), so it is persisted without sitting in `safe`.
|
|
9296
|
+
const changed = watchNext === undefined ? Object.keys(safe) : [...Object.keys(safe), 'watch'];
|
|
9297
|
+
const ignored = Object.keys(patch).filter((k) => !Object.hasOwn(safe, k) && !(k === 'watch' && watchNext !== undefined));
|
|
9298
|
+
const derive = watchNext;
|
|
9299
|
+
const settings = derive === undefined
|
|
9300
|
+
? await adapter.updateSettings(safe)
|
|
9301
|
+
: await adapter.updateSettings(safe, (current) => ({ watch: derive(current) }));
|
|
9233
9302
|
if (watchNext !== undefined)
|
|
9234
9303
|
runtime.watchRegistry?.()?.applySettings(settings.watch);
|
|
9235
9304
|
// Re-apply the worker-config root to this process's env (seat sign-in). The engine reads
|
|
@@ -9251,7 +9320,7 @@ runtime = {}) {
|
|
|
9251
9320
|
// when there is one) is where a dropped unknown key stops being invisible.
|
|
9252
9321
|
audit.record('settings.updated', actorOf(req), {
|
|
9253
9322
|
detail: {
|
|
9254
|
-
changed
|
|
9323
|
+
changed,
|
|
9255
9324
|
...(ignored.length > 0 ? { ignored } : {}),
|
|
9256
9325
|
// Which watchers were switched or re-thresholded (health reads the stamps; this is the trail).
|
|
9257
9326
|
...(watchNext !== undefined ? { watch: patch.watch } : {}),
|
|
@@ -9450,6 +9519,16 @@ runtime = {}) {
|
|
|
9450
9519
|
catch (err) {
|
|
9451
9520
|
return estateUpstreamError(reply, err);
|
|
9452
9521
|
}
|
|
9522
|
+
// crew#1546: an edited learning's replacement whose learning is gone is stale: refused and rejected, never approved,
|
|
9523
|
+
// so no crash window can bring retired words back (accept-with-edit checks the same in `approveEdited`).
|
|
9524
|
+
try {
|
|
9525
|
+
const stale = row?.kind_type === 'memory' ? await refuseStaleReplacement(estateTool, id, row.payload) : null;
|
|
9526
|
+
if (stale !== null)
|
|
9527
|
+
return reply.code(409).send({ error: stale, code: 'stale_replacement' });
|
|
9528
|
+
}
|
|
9529
|
+
catch (err) {
|
|
9530
|
+
return reply.code(502).send({ error: `checking whether proposal ${id} is a stale replacement failed (${message(err)}); nothing was approved` });
|
|
9531
|
+
}
|
|
9453
9532
|
// DC-S4a: a proposal THIS ledger filed for a decision lands through `remember()` — the one
|
|
9454
9533
|
// landing path, with the human check inside it (§4.5). A payload naming an id the ledger does
|
|
9455
9534
|
// not know is an ordinary policy proposal (no ORIGIN claim) and takes the path below.
|
|
@@ -9854,6 +9933,181 @@ runtime = {}) {
|
|
|
9854
9933
|
return items.map(shapeMemoryItem);
|
|
9855
9934
|
};
|
|
9856
9935
|
const deletedCount = (raw) => (typeof raw === 'object' && raw !== null ? raw['deleted_count'] : undefined);
|
|
9936
|
+
const pendingMemoryProposals = async () => {
|
|
9937
|
+
const raw = await estateTool('proposal.list', { kind_type: 'memory', state: 'pending' });
|
|
9938
|
+
const items = typeof raw === 'object' && raw !== null ? raw['proposals'] : undefined;
|
|
9939
|
+
if (!Array.isArray(items))
|
|
9940
|
+
throw new EstateMcpError('proposal.list returned an unexpected shape');
|
|
9941
|
+
return items.flatMap((i) => {
|
|
9942
|
+
const r = typeof i === 'object' && i !== null ? i : {};
|
|
9943
|
+
const payload = typeof r['payload'] === 'object' && r['payload'] !== null ? r['payload'] : {};
|
|
9944
|
+
const facets = typeof r['facets'] === 'object' && r['facets'] !== null ? r['facets'] : {};
|
|
9945
|
+
return typeof r['id'] === 'string'
|
|
9946
|
+
? [{ id: r['id'], content: typeof payload['content'] === 'string' ? payload['content'] : '', reach: typeof payload['reach'] === 'string' ? payload['reach'] : null, facets, replaces: replacesOf(payload) }]
|
|
9947
|
+
: [];
|
|
9948
|
+
});
|
|
9949
|
+
};
|
|
9950
|
+
/** Reject these proposals; true only when the queue is read back with none of them pending. */
|
|
9951
|
+
const withdraw = async (ids) => {
|
|
9952
|
+
for (const id of ids)
|
|
9953
|
+
await estateTool('proposal.reject', { id }).catch(() => undefined);
|
|
9954
|
+
try {
|
|
9955
|
+
const still = new Set((await pendingMemoryProposals()).map((q) => q.id));
|
|
9956
|
+
return ids.every((id) => !still.has(id));
|
|
9957
|
+
}
|
|
9958
|
+
catch {
|
|
9959
|
+
return false;
|
|
9960
|
+
}
|
|
9961
|
+
};
|
|
9962
|
+
const queued = (ids) => ` A proposal of the new words (${ids.join(', ')}) may still be pending: reject it on the approve page.`;
|
|
9963
|
+
const reapproveMemory = async (old, content, beforeIds) => {
|
|
9964
|
+
const reach = old.scope === '' ? 'project' : old.scope.startsWith('operator:') ? 'operator' : null;
|
|
9965
|
+
if (reach === null) {
|
|
9966
|
+
return { status: 409, error: `${old.id} is an approved learning at scope ${JSON.stringify(old.scope)}, which approval cannot place again; nothing changed` };
|
|
9967
|
+
}
|
|
9968
|
+
// The replacement names what it replaces, so approval can refuse it once that memory is gone.
|
|
9969
|
+
const payload = { content, reach, [REPLACES_KEY]: old.id };
|
|
9970
|
+
if (old.tier !== '')
|
|
9971
|
+
payload['tier'] = old.tier;
|
|
9972
|
+
// What was already queued, so a submit whose answer is lost can find the one it filed.
|
|
9973
|
+
let queuedBefore;
|
|
9974
|
+
try {
|
|
9975
|
+
queuedBefore = new Set((await pendingMemoryProposals()).map((q) => q.id));
|
|
9976
|
+
}
|
|
9977
|
+
catch (err) {
|
|
9978
|
+
return { status: 502, error: `reading the approve queue failed (${message(err)}); nothing changed` };
|
|
9979
|
+
}
|
|
9980
|
+
// The memory's OWN proposal must be settled first (codex r2 on crew#1546): estate writes `proposal:<id>`
|
|
9981
|
+
// before it records the approval, so a write that failed in between leaves it pending, and approving it after
|
|
9982
|
+
// this edit would bring the retired words back. Approving it again writes the same memory (idempotent).
|
|
9983
|
+
const sourcePid = old.id.slice(APPROVED_MEMORY_PREFIX.length);
|
|
9984
|
+
if (queuedBefore.has(sourcePid)) {
|
|
9985
|
+
await estateTool('proposal.approve', { id: sourcePid }).catch(() => undefined);
|
|
9986
|
+
try {
|
|
9987
|
+
queuedBefore = new Set((await pendingMemoryProposals()).map((q) => q.id));
|
|
9988
|
+
}
|
|
9989
|
+
catch (err) {
|
|
9990
|
+
return { status: 502, error: `settling ${old.id}'s own proposal could not be checked (${message(err)}); nothing changed` };
|
|
9991
|
+
}
|
|
9992
|
+
if (queuedBefore.has(sourcePid)) {
|
|
9993
|
+
return { status: 409, error: `${old.id}'s own proposal ${sourcePid} is still pending and could not be settled; approve or reject it on the approve page first. Nothing changed` };
|
|
9994
|
+
}
|
|
9995
|
+
}
|
|
9996
|
+
// Superseded replacements are settled too (coord merge check): one of this memory left pending by an edit that
|
|
9997
|
+
// never finished, or of a memory that is already gone, is rejected before the new one is filed.
|
|
9998
|
+
let superseded;
|
|
9999
|
+
try {
|
|
10000
|
+
superseded = (await pendingMemoryProposals()).filter((q) => q.replaces !== null && (q.replaces === old.id || !beforeIds.has(q.replaces))).map((q) => q.id);
|
|
10001
|
+
}
|
|
10002
|
+
catch (err) {
|
|
10003
|
+
return { status: 502, error: `reading the approve queue failed (${message(err)}); nothing changed` };
|
|
10004
|
+
}
|
|
10005
|
+
if (superseded.length > 0 && !(await withdraw(superseded))) {
|
|
10006
|
+
return { status: 502, error: `an earlier replacement of ${old.id} (${superseded.join(', ')}) is still pending and could not be rejected; reject it on the approve page first. Nothing changed` };
|
|
10007
|
+
}
|
|
10008
|
+
let pid = null;
|
|
10009
|
+
let submitErr = null;
|
|
10010
|
+
try {
|
|
10011
|
+
const raw = await estateTool('proposal.submit', { kind_type: 'memory', payload, facets: old.facets });
|
|
10012
|
+
const id = typeof raw === 'object' && raw !== null ? raw['id'] : undefined;
|
|
10013
|
+
if (typeof id === 'string' && id !== '')
|
|
10014
|
+
pid = id;
|
|
10015
|
+
else
|
|
10016
|
+
submitErr = new EstateMcpError('proposal.submit returned no proposal id');
|
|
10017
|
+
}
|
|
10018
|
+
catch (err) {
|
|
10019
|
+
submitErr = err;
|
|
10020
|
+
}
|
|
10021
|
+
if (pid === null) {
|
|
10022
|
+
// The submit may still have filed (a lost answer): find what it filed and withdraw it.
|
|
10023
|
+
// Ours = new since the snapshot, with these words, this reach and these facets (codex r2: words alone would
|
|
10024
|
+
// reject another caller's filing for another repository).
|
|
10025
|
+
const ours = (q) => !queuedBefore.has(q.id) && q.content === content && (q.reach === null || q.reach === reach) && q.replaces === old.id &&
|
|
10026
|
+
Object.entries(old.facets).every(([k, v]) => q.facets[k] === v) && Object.keys(q.facets).every((k) => k in old.facets);
|
|
10027
|
+
let strays;
|
|
10028
|
+
try {
|
|
10029
|
+
strays = (await pendingMemoryProposals()).filter(ours).map((q) => q.id);
|
|
10030
|
+
}
|
|
10031
|
+
catch (err) {
|
|
10032
|
+
return { status: 502, error: `filing the new words for approval failed (${message(submitErr)}) and the queue could not be re-read (${message(err)}).${queued(['unknown id'])}` };
|
|
10033
|
+
}
|
|
10034
|
+
const gone = strays.length === 0 || (await withdraw(strays));
|
|
10035
|
+
// A filing approved meanwhile is no longer pending: the store, not the queue, says whether it landed.
|
|
10036
|
+
let approvedCopies;
|
|
10037
|
+
try {
|
|
10038
|
+
approvedCopies = (await listAll()).filter((m) => m.id.startsWith(APPROVED_MEMORY_PREFIX) && !beforeIds.has(m.id) && m.content.trim() === content).map((m) => m.id);
|
|
10039
|
+
}
|
|
10040
|
+
catch {
|
|
10041
|
+
approvedCopies = null;
|
|
10042
|
+
}
|
|
10043
|
+
const landedNote = approvedCopies === null
|
|
10044
|
+
? `; the store could not be re-read, so an approved copy of the new words may exist beside ${old.id}`
|
|
10045
|
+
: approvedCopies.length > 0
|
|
10046
|
+
? `; an approved copy of the new words exists beside ${old.id}: ${approvedCopies.join(', ')}`
|
|
10047
|
+
: '';
|
|
10048
|
+
return {
|
|
10049
|
+
status: 502,
|
|
10050
|
+
error: `filing the new words for approval failed (${message(submitErr)})${landedNote === '' ? '; nothing changed' : landedNote}${gone ? '' : `.${queued(strays)}`}`,
|
|
10051
|
+
};
|
|
10052
|
+
}
|
|
10053
|
+
const newId = `${APPROVED_MEMORY_PREFIX}${pid}`;
|
|
10054
|
+
const approve = () => estateTool('proposal.approve', { id: pid }).then(() => null, (err) => err);
|
|
10055
|
+
const approveErr = await approve();
|
|
10056
|
+
let landed;
|
|
10057
|
+
try {
|
|
10058
|
+
landed = (await listAll()).find((m) => m.id === newId);
|
|
10059
|
+
}
|
|
10060
|
+
catch (err) {
|
|
10061
|
+
return { status: 502, error: `approving the new words could not be checked (${message(err)}); ${newId} may exist beside ${old.id}.${queued([pid])}` };
|
|
10062
|
+
}
|
|
10063
|
+
if (landed === undefined) {
|
|
10064
|
+
const gone = await withdraw([pid]);
|
|
10065
|
+
return { status: 502, error: `approving the new words failed (${approveErr === null ? 'no memory was written' : message(approveErr)}); nothing changed${gone ? '' : `.${queued([pid])}`}` };
|
|
10066
|
+
}
|
|
10067
|
+
// Taking a written replacement back out: its memory erased and its proposal never left pending.
|
|
10068
|
+
const undo = async (why) => {
|
|
10069
|
+
await estateTool('memory.erase', { id: newId }).catch(() => undefined);
|
|
10070
|
+
let erased = false;
|
|
10071
|
+
try {
|
|
10072
|
+
erased = !(await listAll()).some((m) => m.id === newId);
|
|
10073
|
+
}
|
|
10074
|
+
catch {
|
|
10075
|
+
// Reported below as not confirmed gone.
|
|
10076
|
+
}
|
|
10077
|
+
let settled = false;
|
|
10078
|
+
try {
|
|
10079
|
+
settled = !(await pendingMemoryProposals()).some((q) => q.id === pid) || (await withdraw([pid]));
|
|
10080
|
+
}
|
|
10081
|
+
catch {
|
|
10082
|
+
settled = await withdraw([pid]);
|
|
10083
|
+
}
|
|
10084
|
+
return {
|
|
10085
|
+
status: 502,
|
|
10086
|
+
error: erased
|
|
10087
|
+
? `${why}; they were taken back out, so nothing changed${settled ? '' : `.${queued([pid])}`}`
|
|
10088
|
+
: `${why}; taking ${newId} back out was not confirmed, so both ${old.id} and ${newId} may remain${settled ? '' : `.${queued([pid])}`}`,
|
|
10089
|
+
};
|
|
10090
|
+
};
|
|
10091
|
+
if (landed.scope !== old.scope) {
|
|
10092
|
+
return undo(`the approved words landed at scope ${JSON.stringify(landed.scope)}, not ${JSON.stringify(old.scope)}`);
|
|
10093
|
+
}
|
|
10094
|
+
// The memory landed; its proposal must read approved. A write that landed before estate recorded the
|
|
10095
|
+
// approval leaves it pending: approve it again (the same memory), and undo the edit if that does not settle it.
|
|
10096
|
+
let pending;
|
|
10097
|
+
try {
|
|
10098
|
+
pending = (await pendingMemoryProposals()).some((q) => q.id === pid);
|
|
10099
|
+
if (pending) {
|
|
10100
|
+
await approve();
|
|
10101
|
+
pending = (await pendingMemoryProposals()).some((q) => q.id === pid);
|
|
10102
|
+
}
|
|
10103
|
+
}
|
|
10104
|
+
catch (err) {
|
|
10105
|
+
return undo(`the approval of the new words could not be confirmed (${message(err)})`);
|
|
10106
|
+
}
|
|
10107
|
+
if (pending)
|
|
10108
|
+
return undo('the approval of the new words stayed pending');
|
|
10109
|
+
return { id: newId };
|
|
10110
|
+
};
|
|
9857
10111
|
try {
|
|
9858
10112
|
// 1. The memory as it is: its tier, scope and facets ride onto the replacement.
|
|
9859
10113
|
let before;
|
|
@@ -9883,48 +10137,59 @@ runtime = {}) {
|
|
|
9883
10137
|
}
|
|
9884
10138
|
return upstream('checking that the store can erase one memory failed; nothing changed', err);
|
|
9885
10139
|
}
|
|
9886
|
-
// 3. The new words, as a new memory in the old one's place.
|
|
9887
|
-
|
|
9888
|
-
|
|
9889
|
-
|
|
9890
|
-
const kind = KIND_FOR_TIER[old.tier];
|
|
9891
|
-
if (kind !== undefined)
|
|
9892
|
-
captureArgs['kind'] = kind;
|
|
9893
|
-
}
|
|
9894
|
-
const beforeIds = new Set(before.map((m) => m.id));
|
|
10140
|
+
// 3. The new words, as a new memory in the old one's place. An approved learning (estate's
|
|
10141
|
+
// `proposal:` id, the only mark run-learnings recall admits: crew#1546) is replaced through
|
|
10142
|
+
// the approval queue, so the replacement carries the mark too; a capture would mint a bare id
|
|
10143
|
+
// and the edited learning would silently stop reaching briefs. Anything else is captured.
|
|
9895
10144
|
let newId = null;
|
|
9896
|
-
|
|
9897
|
-
|
|
9898
|
-
|
|
9899
|
-
|
|
9900
|
-
|
|
9901
|
-
newId = id;
|
|
9902
|
-
else
|
|
9903
|
-
captureErr = new EstateMcpError('memory.capture returned no memory_id');
|
|
10145
|
+
if (memoryId.startsWith(APPROVED_MEMORY_PREFIX)) {
|
|
10146
|
+
const placed = await reapproveMemory(old, content, new Set(before.map((m) => m.id)));
|
|
10147
|
+
if ('error' in placed)
|
|
10148
|
+
return reply.code(placed.status).send({ error: placed.error });
|
|
10149
|
+
newId = placed.id;
|
|
9904
10150
|
}
|
|
9905
|
-
|
|
9906
|
-
|
|
9907
|
-
|
|
9908
|
-
|
|
9909
|
-
|
|
9910
|
-
|
|
10151
|
+
else {
|
|
10152
|
+
const captureArgs = { content, scope: old.scope, facets: old.facets };
|
|
10153
|
+
if (old.tier !== '') {
|
|
10154
|
+
captureArgs['tier'] = old.tier;
|
|
10155
|
+
const kind = KIND_FOR_TIER[old.tier];
|
|
10156
|
+
if (kind !== undefined)
|
|
10157
|
+
captureArgs['kind'] = kind;
|
|
10158
|
+
}
|
|
10159
|
+
const beforeIds = new Set(before.map((m) => m.id));
|
|
10160
|
+
let captureErr = null;
|
|
9911
10161
|
try {
|
|
9912
|
-
|
|
10162
|
+
const captured = await estateTool('memory.capture', captureArgs);
|
|
10163
|
+
const id = typeof captured === 'object' && captured !== null ? captured['memory_id'] : undefined;
|
|
10164
|
+
if (typeof id === 'string' && id !== '')
|
|
10165
|
+
newId = id;
|
|
10166
|
+
else
|
|
10167
|
+
captureErr = new EstateMcpError('memory.capture returned no memory_id');
|
|
9913
10168
|
}
|
|
9914
10169
|
catch (err) {
|
|
9915
|
-
|
|
9916
|
-
error: `writing the new words did not answer as expected (${message(captureErr)}) and the store could not be re-read (${message(err)}); a copy of the new words may exist beside ${memoryId}`,
|
|
9917
|
-
});
|
|
10170
|
+
captureErr = err;
|
|
9918
10171
|
}
|
|
9919
|
-
|
|
9920
|
-
|
|
9921
|
-
|
|
9922
|
-
|
|
9923
|
-
|
|
9924
|
-
|
|
9925
|
-
|
|
10172
|
+
if (newId === null) {
|
|
10173
|
+
// The capture may still have written (a lost answer): look before saying nothing changed.
|
|
10174
|
+
let now;
|
|
10175
|
+
try {
|
|
10176
|
+
now = await listAll();
|
|
10177
|
+
}
|
|
10178
|
+
catch (err) {
|
|
10179
|
+
return reply.code(502).send({
|
|
10180
|
+
error: `writing the new words did not answer as expected (${message(captureErr)}) and the store could not be re-read (${message(err)}); a copy of the new words may exist beside ${memoryId}`,
|
|
10181
|
+
});
|
|
10182
|
+
}
|
|
10183
|
+
const copies = now.filter((m) => !beforeIds.has(m.id) && m.content.trim() === content && m.scope === old.scope);
|
|
10184
|
+
if (copies.length !== 1) {
|
|
10185
|
+
return reply.code(502).send({
|
|
10186
|
+
error: copies.length === 0
|
|
10187
|
+
? `writing the new words failed (${message(captureErr)}); nothing changed`
|
|
10188
|
+
: `writing the new words did not answer as expected (${message(captureErr)}); ${copies.length} copies of them now exist beside ${memoryId}: ${copies.map((m) => m.id).join(', ')}`,
|
|
10189
|
+
});
|
|
10190
|
+
}
|
|
10191
|
+
newId = copies[0].id;
|
|
9926
10192
|
}
|
|
9927
|
-
newId = copies[0].id;
|
|
9928
10193
|
}
|
|
9929
10194
|
// 4. The old memory out.
|
|
9930
10195
|
let eraseErr = null;
|
|
@@ -10206,20 +10471,7 @@ runtime = {}) {
|
|
|
10206
10471
|
// per request, and one background `seat-image build` at a time.
|
|
10207
10472
|
const coreExe = () => process.env['WICKED_CORE_EXE'] || null;
|
|
10208
10473
|
const seatImageRebuilder = runtime.seatImageRebuilder ?? new SeatImageRebuilder(coreExe);
|
|
10209
|
-
const seatImageStatus = runtime.seatImageStatus ??
|
|
10210
|
-
(async () => {
|
|
10211
|
-
const exe = coreExe();
|
|
10212
|
-
if (exe === null)
|
|
10213
|
-
throw new Error('WICKED_CORE_EXE is not set');
|
|
10214
|
-
try {
|
|
10215
|
-
const out = await execCapped(exe, ['seat-image', 'status', '--json'], { timeout: PROBE_TIMEOUT_MS });
|
|
10216
|
-
return parseSeatImageStatus(out.stdout);
|
|
10217
|
-
}
|
|
10218
|
-
catch (err) {
|
|
10219
|
-
const e = err;
|
|
10220
|
-
throw new Error(loginDetail(typeof e.stderr === 'string' && e.stderr !== '' ? e.stderr : (e.message ?? 'failed')));
|
|
10221
|
-
}
|
|
10222
|
-
});
|
|
10474
|
+
const seatImageStatus = runtime.seatImageStatus ?? seatImageStatusVia(coreExe);
|
|
10223
10475
|
// The roster's seats (on the container floor every seat runs in an image); `null` when unreadable.
|
|
10224
10476
|
const rosterSeatsNow = () => {
|
|
10225
10477
|
try {
|
|
@@ -10390,6 +10642,11 @@ runtime = {}) {
|
|
|
10390
10642
|
rebuild: () => seatImageRebuilder.current(),
|
|
10391
10643
|
}),
|
|
10392
10644
|
clusterP.then((rows) => rows.cluster),
|
|
10645
|
+
// crew#1527: whether a pull request can be opened — the setup steps' answer, through the same bounded reader.
|
|
10646
|
+
(async () => {
|
|
10647
|
+
const started = Date.now();
|
|
10648
|
+
return deliveryRow(await readDeliveryReadiness(() => Promise.resolve(adapter.getSettings())), started, infraRow);
|
|
10649
|
+
})(),
|
|
10393
10650
|
]);
|
|
10394
10651
|
const [views, settings, openGates, diag, ping, rules, gatesByYou, infraProbed, reposRead] = await Promise.all([
|
|
10395
10652
|
viewsP, settingsP, gatesP, diagP, pingP, rulesP, gatesByYouP, infraP, reposP,
|
|
@@ -10528,6 +10785,7 @@ runtime = {}) {
|
|
|
10528
10785
|
infraProbed[8],
|
|
10529
10786
|
infraProbed[7],
|
|
10530
10787
|
reposRow(reposRead),
|
|
10788
|
+
infraProbed[9],
|
|
10531
10789
|
infraProbed[6],
|
|
10532
10790
|
loadRow(),
|
|
10533
10791
|
];
|