wicked-crew 0.18.16 → 0.18.18
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/README.md +11 -5
- 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 +28 -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 +39 -3
- package/dist/api/chat-proposals.d.ts.map +1 -1
- package/dist/api/chat-proposals.js +122 -17
- package/dist/api/chat-proposals.js.map +1 -1
- package/dist/api/chat-scope.d.ts.map +1 -1
- package/dist/api/chat-scope.js +2 -0
- package/dist/api/chat-scope.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/roster-standing.d.ts +7 -0
- package/dist/api/roster-standing.d.ts.map +1 -1
- package/dist/api/roster-standing.js +32 -2
- package/dist/api/roster-standing.js.map +1 -1
- package/dist/api/routes.d.ts +6 -6
- package/dist/api/routes.d.ts.map +1 -1
- package/dist/api/routes.js +526 -182
- package/dist/api/routes.js.map +1 -1
- 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-standing.d.ts +3 -0
- package/dist/api/seat-standing.d.ts.map +1 -1
- package/dist/api/seat-standing.js +5 -0
- package/dist/api/seat-standing.js.map +1 -1
- package/dist/api/server.d.ts.map +1 -1
- package/dist/api/server.js +3 -1
- package/dist/api/server.js.map +1 -1
- package/dist/api/system-snapshot.d.ts.map +1 -1
- package/dist/api/system-snapshot.js +1 -0
- 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 +123 -0
- package/dist/core/adapter.d.ts +38 -2
- package/dist/core/adapter.d.ts.map +1 -1
- package/dist/core/adapter.js +102 -7
- package/dist/core/adapter.js.map +1 -1
- package/dist/core/deliver-exclusions.d.ts +29 -0
- package/dist/core/deliver-exclusions.d.ts.map +1 -1
- package/dist/core/deliver-exclusions.js +44 -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 +30 -1
- package/dist/core/deliver.d.ts.map +1 -1
- package/dist/core/deliver.js +167 -17
- 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/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/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/qe/acceptance.d.ts +5 -1
- package/dist/qe/acceptance.d.ts.map +1 -1
- package/dist/qe/acceptance.js +13 -1
- package/dist/qe/acceptance.js.map +1 -1
- package/dist/qe/ledger.d.ts +34 -0
- package/dist/qe/ledger.d.ts.map +1 -1
- package/dist/qe/ledger.js +107 -1
- package/dist/qe/ledger.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/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/studio/apps-standalone/fixture.js +3 -3
- package/dist/studio/assets/{KnowledgeGraph-Bgo9MFqp.js → KnowledgeGraph-JfsMExo3.js} +1 -1
- package/dist/studio/assets/{index-DNAGbMFA.js → index-pq0QeOmo.js} +301 -301
- package/dist/studio/editors/wicked-apps/editor.json +1 -1
- package/dist/studio/editors/wicked-apps/index.html +1 -1
- package/dist/studio/editors/wicked-deck/editor.json +1 -1
- package/dist/studio/editors/wicked-deck/index.html +1 -1
- package/dist/studio/editors/wicked-doc/editor.json +1 -1
- package/dist/studio/editors/wicked-doc/index.html +1 -1
- package/dist/studio/editors/wicked-insights/editor.json +1 -1
- package/dist/studio/editors/wicked-insights/index.html +1 -1
- package/dist/studio/editors/wicked-page/editor.json +1 -1
- package/dist/studio/editors/wicked-page/index.html +1 -1
- package/dist/studio/editors/wicked-video/editor.json +1 -1
- package/dist/studio/editors/wicked-video/index.html +1 -1
- package/dist/studio/index.html +1 -1
- package/dist/studio/testid-inventory.json +52 -4
- package/endpoint-manifest.json +11 -1
- package/package.json +5 -5
package/dist/api/routes.js
CHANGED
|
@@ -13,7 +13,7 @@ import { promises as fsp } from 'node:fs';
|
|
|
13
13
|
import { basename, isAbsolute, join, relative, resolve } from 'node:path';
|
|
14
14
|
import { fileURLToPath } from 'node:url';
|
|
15
15
|
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';
|
|
16
|
+
import { CampaignsUnsupportedError, ChatUnsupportedError, CoreAdapter, ElicitationUnsupportedError, GovernanceReplayUnsupportedError, PlanGateNoteUnsupportedError, PlanLaunchUnsupportedError, SteeringUnsupportedError, addonSupportsQeOverride, addonSupportsReducedAssurance, humanGatePhaseIds, readNewWorkSeats, settingsFilePath, wickedDir } from '../core/adapter.js';
|
|
17
17
|
import { codeGraphDb, codeGraphErrorStatus, repoFolderMissing, repoFolderMissingBody } from '../core/repoPaths.js';
|
|
18
18
|
import { resolveCursorUnit } from '../core/cursor.js';
|
|
19
19
|
/** Create `dir` (private) when missing and answer it — a read root must exist when a run launches. */
|
|
@@ -56,6 +56,8 @@ import { attemptUnavailableReason, capturedAttempts, outputUnavailableReason, re
|
|
|
56
56
|
import { execCapped, ExecOutputTooLarge } from '../core/exec.js';
|
|
57
57
|
import { callEstateTool, EstateMcpError, ESTATE_INSTALL_HINT, memoryStoreInfo } from '../core/estate-mcp-client.js';
|
|
58
58
|
import { NO_LEARNINGS_WORKFLOWS } from '../learnings/service.js';
|
|
59
|
+
import { APPROVED_MEMORY_PREFIX } from '../learnings/recall.js';
|
|
60
|
+
import { REPLACES_KEY, refuseStaleReplacement, replacesOf } from '../learnings/replacement-lineage.js';
|
|
59
61
|
import { matchRulesForJob, stripRulesBrief, withRulesBrief } from '../decisions/rules-brief.js';
|
|
60
62
|
import { SeatHealthTracker } from './seat-health.js';
|
|
61
63
|
import { applyWorkerConfigRoot, signedInHeuristic } from './seat-signin.js';
|
|
@@ -66,7 +68,7 @@ import { chatSeatAdmission, homeless } from './seat-standing.js';
|
|
|
66
68
|
import { seatGovernanceDiagnostics, seatGovernanceWarnings, } from './seat-governance.js';
|
|
67
69
|
import { seatWorkDefaultNow } from './seat-work-default.js';
|
|
68
70
|
import { ROSTER_REFRESH_WAIT_MS, rosterWithStandingFactory } from './roster-standing.js';
|
|
69
|
-
import { SeatContainerStatus, isContainerLoginCli, isContainerSeatFloor, isHostSeatFloor,
|
|
71
|
+
import { SeatContainerStatus, isContainerLoginCli, isContainerSeatFloor, isHostSeatFloor, registerSeatContainerLoginRoutes, seatLoginDepsFor, } from './seat-container-login.js';
|
|
70
72
|
import { ChatTurnIndex } from './chat-turns.js';
|
|
71
73
|
import { CHAT_ID, chatJobTurnLines, chatMakeDigest, ChatScopeIndex, chatScopeDeps, chatScopeStatement, prepareChatScratch, removeChatScratch, namedKindRefusal, resolveChatScope, } from './chat-scope.js';
|
|
72
74
|
import { buildRequirementsMaps, publishRequirementsMaps, REQUIREMENTS_MAP_DIR } from './chat-requirements.js';
|
|
@@ -117,8 +119,10 @@ import { withPhaseSkillGaps } from '../skills/phase-skill-gaps.js';
|
|
|
117
119
|
import { STATE_HOME_BLOCKER_CODE, STATE_HOME_REMEDY, isEngineStateHomeRefusal, stateHomeBlockerBody, } from '../projects/state-home-preflight.js';
|
|
118
120
|
import { BASE_SKILL_POLICIES, BASE_SKILL_REF_SHAPE, baseSkillRemedy } from '../skills/base-skill.js';
|
|
119
121
|
import { REQUIRED_GARDEN_VERSION } from '../skills/plugin-source.js';
|
|
122
|
+
import { isSeatKeyList } from '../core/job-seats.js';
|
|
120
123
|
import { engineRosterJson, noEligibleSeatBody, parseNoEligibleSeat, toEngineSeat } from '../core/engine-roster.js';
|
|
121
124
|
import { launchAssuranceNotice } from '../core/assurance.js';
|
|
125
|
+
import { launchPosture } from '../core/launch-posture.js';
|
|
122
126
|
import { launchRequiresQe, mayRequireQe, qeAcceptanceMode, qeSettingSkipReason } from '../core/qe-acceptance-setting.js';
|
|
123
127
|
import { aggregateReceipt, postHocDeliveryAssurance, qeAcceptanceFromView, qeAcceptanceRefusal, QE_ACCEPTANCE_REQUIRED_CODE, receiptOf, qeAcceptanceNotRequired, qeDecisionBypasses, qeDecisionOf, qeAcceptanceSkippedAtGate, unreadableQeAcceptance, } from './delivery-assurance.js';
|
|
124
128
|
import { ProjectSettingsStore } from '../projects/settings.js';
|
|
@@ -144,7 +148,7 @@ const BRIEF_COPY_MAX = 512 * 1024;
|
|
|
144
148
|
import { registerInteractiveDocDelete } from '../interactive/doc-delete-routes.js';
|
|
145
149
|
import { registerInteractiveDocChecks } from '../interactive/doc-checks-routes.js';
|
|
146
150
|
import { crewStateHome, stateHomeOfDb } from '../projects/state-home.js';
|
|
147
|
-
import { demoShowOf, factsOf, inputLines, jobInputsOfProposal, jobLaunchCommon, personPid, requestDigest, SELF_SEATED } from './chat-jobs.js';
|
|
151
|
+
import { demoShowOf, factsOf, inputLines, jobInputsOfProposal, jobLaunchCommon, jobLaunchRoster, personPid, requestDigest, SELF_SEATED } from './chat-jobs.js';
|
|
148
152
|
import { DocumentsRefused, documentsClause, RUN_DOCS_TOKENS_MAX, stagedDocumentsOf, stageRunDocuments } from './run-documents.js';
|
|
149
153
|
import { checkSourcePick, projectSources, RUN_SOURCES_MAX, runSourcesDeps, webScopeReason } from './run-sources.js';
|
|
150
154
|
import { CATALOG_V2_CARDS } from '../workflow-catalog/catalog-data-v2.js';
|
|
@@ -167,7 +171,8 @@ import { ATTACHMENT_LIMITS, ATTACHMENT_MAX_MESSAGE_BYTES, AttachmentError, ChatA
|
|
|
167
171
|
import { CHAT_HISTORY_MAX_LIMIT, ChatHistoryStore, decodeCursor } from './chat-history.js';
|
|
168
172
|
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
173
|
import { CLUSTER_TIMEOUT_MS, ClusterStatusReader, clusterDiagnostics, clusterRows } from './cluster-status.js';
|
|
170
|
-
import {
|
|
174
|
+
import { deliveryRow, readDeliveryReadiness } from '../setup/delivery-readiness.js';
|
|
175
|
+
import { idleClis, probeSeatImages, SeatImageRebuilder, seatImageStatusVia } from './seat-images.js';
|
|
171
176
|
import { RunCostCache } from './needs.js';
|
|
172
177
|
import { governanceStoreFix, legacyHomeOutboxPath } from '../core/governance-store.js';
|
|
173
178
|
import { UsageError, replayOutboxInto } from '../cli/governance.js';
|
|
@@ -475,25 +480,24 @@ const ExcludeLinkedIssuesSchema = z
|
|
|
475
480
|
.optional();
|
|
476
481
|
/**
|
|
477
482
|
* 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.
|
|
483
|
+
* the seats that can work now (enabled for council, work-eligible, not signed out), opt-in seats INCLUDED (crew#1590):
|
|
484
|
+
* naming or picking one is the opt-in. The default launch rule ({@link defaultLaunchRoster}: no opt-in seat unless it
|
|
485
|
+
* is the only one left) applies where nobody chose, the pool work is drawn from (`jobSeatPool`).
|
|
482
486
|
*/
|
|
483
487
|
export function proposalRoster(standing) {
|
|
484
488
|
const canWork = standing.filter((s) => s.enabled_for_council && s.seat_eligible_for_work !== false && s.auth !== 'signed_out');
|
|
485
|
-
return
|
|
489
|
+
return canWork.map((s) => ({ key: String(s.key), name: s.display_name || String(s.key) }));
|
|
486
490
|
}
|
|
487
491
|
/**
|
|
488
492
|
* The default launch roster ({@link defaultLaunchRoster}: no opt-in seats) — plus the opt-in seat a
|
|
489
|
-
* launch NAMES as its lead (`primary`)
|
|
493
|
+
* launch NAMES as its lead (`primary`), and (crew#1590) any other seat it names (`named`: a chat job's card seats):
|
|
494
|
+
* naming it is the opt-in.
|
|
490
495
|
*/
|
|
491
|
-
export function launchRosterNaming(roster, primary) {
|
|
496
|
+
export function launchRosterNaming(roster, primary, named = []) {
|
|
492
497
|
const base = defaultLaunchRoster(roster);
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
return named === undefined ? base : [...base, named];
|
|
498
|
+
const wanted = [primary, ...named].filter((k) => k !== undefined && !base.some((s) => s.key === k));
|
|
499
|
+
const extra = wanted.map((k) => roster.find((s) => s.key === k)).filter((s) => s !== undefined);
|
|
500
|
+
return extra.length === 0 ? base : [...base, ...new Set(extra)];
|
|
497
501
|
}
|
|
498
502
|
/**
|
|
499
503
|
* Why `primary` cannot lead a launch on `clisJson`'s roster, or `null` when it can (DES-TEAMING-002
|
|
@@ -1785,6 +1789,8 @@ runtime = {}) {
|
|
|
1785
1789
|
workingDoc: app.hasRoute({ method: 'GET', url: `${V}/runs/:id/working-doc` }),
|
|
1786
1790
|
// (api-types 0.149.0) Power mode: the routes are served AND the engine runs it.
|
|
1787
1791
|
powerMode: powerSupported(),
|
|
1792
|
+
// (api-types 0.211.0, crew#1512) `GET /runs/:id/gate` carries `actions`: the engine has the read.
|
|
1793
|
+
gateActions: typeof adapter.gateActions === 'function' && (adapter.supportsGateActions?.() ?? true),
|
|
1788
1794
|
// (api-types 0.188.0, crew#1139) A plan approval carries the operator's note (`GateDecision.amend` at a
|
|
1789
1795
|
// plan_approval gate, with or without `plan`): the engine lands it on the plan's first creator step.
|
|
1790
1796
|
planGateNote: typeof adapter.supportsPlanGateNote === 'function' && adapter.supportsPlanGateNote(),
|
|
@@ -2802,8 +2808,6 @@ runtime = {}) {
|
|
|
2802
2808
|
}
|
|
2803
2809
|
if (b.entityMode !== undefined)
|
|
2804
2810
|
input.entityMode = b.entityMode;
|
|
2805
|
-
if (b.humanConfirm !== undefined)
|
|
2806
|
-
input.humanConfirm = b.humanConfirm;
|
|
2807
2811
|
// F-E2E-030: only the explicit `'auto'` opts out of the engine's deliver gate. `'human'` and
|
|
2808
2812
|
// an omitted field both leave `autoDeliver` off the input — the gate is the engine's default,
|
|
2809
2813
|
// so the wire never has to say "gate me" to be gated.
|
|
@@ -2833,7 +2837,6 @@ runtime = {}) {
|
|
|
2833
2837
|
'(unless the launch explicitly skips QE acceptance with a reason: skipQeAcceptance)',
|
|
2834
2838
|
});
|
|
2835
2839
|
}
|
|
2836
|
-
input.autoDeliver = true;
|
|
2837
2840
|
}
|
|
2838
2841
|
if (b.repoRef !== undefined)
|
|
2839
2842
|
input.repoRef = b.repoRef;
|
|
@@ -2858,90 +2861,35 @@ runtime = {}) {
|
|
|
2858
2861
|
input.projectGraph = decision.binding;
|
|
2859
2862
|
req.log.info({ runId: input.sessionId, projectId: b.projectId, repoRef: b.repoRef ?? null }, `run ${input.sessionId}: ${decision.reason}`);
|
|
2860
2863
|
}
|
|
2861
|
-
// The
|
|
2862
|
-
//
|
|
2863
|
-
//
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
// phase that writes, not chat/onboarding/recon, and not domain-extraction, whose only
|
|
2868
|
-
// code phase is the `coverage` EVALUATOR, which executes code solely to write its own
|
|
2869
|
-
// report into the tree for its validator — nothing to deliver) ⇒ the
|
|
2870
|
-
// daemon's `deliverDefault` setting ('pr' unless the operator flipped it) — the default
|
|
2871
|
-
// that keeps run 83052f0b's work from stranding invisibly again. The code-work guard is
|
|
2872
|
-
// the issue's own scope ("default deliver:'pr' for CODE-WORK launches"): a read-only
|
|
2873
|
-
// workflow leaves a clean worktree, and the deliver script FAILS a clean worktree loudly
|
|
2874
|
-
// ("nothing to deliver", crew#317) — defaulting it on would flip every repo-scoped chat
|
|
2875
|
-
// from completed to failed;
|
|
2876
|
-
// - omitted otherwise ⇒ 'none': a repo-less run has no worktree to lift, and a free-text
|
|
2877
|
-
// run has no def to append the deliver phase to (the adapter REFUSES deliver:'pr'
|
|
2878
|
-
// without a workflow rather than silently dropping it, so defaulting it on would turn
|
|
2879
|
-
// a legal launch into a 400).
|
|
2880
|
-
// The adapter input spells 'none' as an omitted field; the audit entry below records the
|
|
2881
|
-
// RESOLVED value either way, plus whether it was defaulted.
|
|
2882
|
-
let deliver;
|
|
2883
|
-
let deliverDefaulted = false;
|
|
2884
|
-
if (b.deliver !== undefined) {
|
|
2885
|
-
deliver = b.deliver;
|
|
2886
|
-
}
|
|
2887
|
-
else if (b.repoRef !== undefined && b.workflow !== undefined) {
|
|
2888
|
-
// Unknown def ⇒ no default (the launch fails at workflow resolution with its own error —
|
|
2889
|
-
// defaulting 'pr' onto it would swap that for a misleading deliver-flavored one).
|
|
2890
|
-
const def = adapter.getWorkflow(b.workflow);
|
|
2891
|
-
const codeWork = def !== null &&
|
|
2892
|
-
def.phases.some((p) => p.executes_code === true && p.role !== 'evaluator');
|
|
2893
|
-
deliver =
|
|
2894
|
-
codeWork && (await adapter.getSettings()).deliverDefault !== 'none' ? 'pr' : 'none';
|
|
2895
|
-
deliverDefaulted = true;
|
|
2896
|
-
}
|
|
2897
|
-
else {
|
|
2898
|
-
deliver = 'none';
|
|
2899
|
-
deliverDefaulted = true;
|
|
2900
|
-
}
|
|
2864
|
+
// (studio#1150) The launch's human gates — power, the posture the engine keeps, delivery and its gate — are ONE
|
|
2865
|
+
// decision (`core/launch-posture.ts`), the same one `POST /runs/preview` answers for this body, so a launch form
|
|
2866
|
+
// shows what the run keeps. The rules (crew#393 delivery, DES-POWER-MODE, F-E2E-030) are documented there.
|
|
2867
|
+
const posture = await launchPosture(b, postureFacts, { powerRequired: ctx.powerRequired });
|
|
2868
|
+
let deliver = posture.resolvedDeliver;
|
|
2869
|
+
const deliverDefaulted = posture.deliverDefaulted;
|
|
2901
2870
|
if (deliver === 'pr')
|
|
2902
2871
|
input.deliver = 'pr';
|
|
2872
|
+
if (posture.autoDeliver)
|
|
2873
|
+
input.autoDeliver = true;
|
|
2903
2874
|
// wicked-core#850 EX-01/EX-02: forwarded only when the caller sent it — crew never waives
|
|
2904
2875
|
// assurance on anyone's behalf (a one-CLI launch that did not is TOLD so in its answer, below).
|
|
2905
2876
|
if (b.reducedAssurance === true)
|
|
2906
2877
|
input.reducedAssurance = true;
|
|
2907
|
-
|
|
2908
|
-
//
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
:
|
|
2917
|
-
|
|
2918
|
-
//
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
powerNotice = 'power mode runs a repo-scoped plan or preset launch; this launch runs phased';
|
|
2923
|
-
}
|
|
2924
|
-
else if (!powerSupported()) {
|
|
2925
|
-
powerNotice = 'this engine has no power mode; the launch runs phased';
|
|
2926
|
-
}
|
|
2927
|
-
else if (ctx.powerRequired === true && ((await adapter.getSettings()).powerModeDefault ?? true) === false) {
|
|
2928
|
-
// A chat job's power Start follows the setting up to the engine call (it may have been turned off meanwhile).
|
|
2929
|
-
powerNotice = 'Power mode for new jobs is off on this daemon; the launch runs phased';
|
|
2930
|
-
}
|
|
2931
|
-
// A chat job's power Start is never run phased in its place (the person chose no plan review for a power run).
|
|
2932
|
-
if (powerNotice !== null && ctx.powerRequired === true) {
|
|
2933
|
-
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` });
|
|
2934
|
-
}
|
|
2935
|
-
if (powerNotice === null) {
|
|
2936
|
-
input.power = true;
|
|
2937
|
-
input.humanConfirm = 'none';
|
|
2938
|
-
// DES-LEARN §3.3 / wicked-core#1216: the orchestrator talks to the person in their personality
|
|
2939
|
-
// for this project (the project's override, else theirs). The engine hands it to the
|
|
2940
|
-
// orchestrator only; reviewers, judges and QE never hear it.
|
|
2941
|
-
const { voice } = voiceFor(b.projectId);
|
|
2942
|
-
if (voice !== undefined)
|
|
2943
|
-
input.voice = voice;
|
|
2944
|
-
}
|
|
2878
|
+
const { powerNotice, humanConfirmNotice } = posture;
|
|
2879
|
+
// A chat job's power Start is never run phased in its place (the person chose no plan review for a power run).
|
|
2880
|
+
if (posture.powerRefusal !== null) {
|
|
2881
|
+
return reply.code(409).send({ code: 'power_unavailable', error: posture.powerRefusal });
|
|
2882
|
+
}
|
|
2883
|
+
if (posture.humanConfirm !== undefined)
|
|
2884
|
+
input.humanConfirm = posture.humanConfirm;
|
|
2885
|
+
if (posture.power) {
|
|
2886
|
+
input.power = true;
|
|
2887
|
+
// DES-LEARN §3.3 / wicked-core#1216: the orchestrator talks to the person in their personality
|
|
2888
|
+
// for this project (the project's override, else theirs). The engine hands it to the
|
|
2889
|
+
// orchestrator only; reviewers, judges and QE never hear it.
|
|
2890
|
+
const { voice } = voiceFor(b.projectId);
|
|
2891
|
+
if (voice !== undefined)
|
|
2892
|
+
input.voice = voice;
|
|
2945
2893
|
}
|
|
2946
2894
|
// QE-IN-APP-WORKFLOWS: the operator's explicit skip (with its reason) or force — forwarded only
|
|
2947
2895
|
// when sent, never inferred.
|
|
@@ -3187,7 +3135,7 @@ runtime = {}) {
|
|
|
3187
3135
|
}
|
|
3188
3136
|
deliver = 'none';
|
|
3189
3137
|
}
|
|
3190
|
-
const isReview = b.workflow
|
|
3138
|
+
const isReview = b.workflow !== undefined && reviewPrepared(b.workflow);
|
|
3191
3139
|
if (isReview) {
|
|
3192
3140
|
try {
|
|
3193
3141
|
await runtime.reviewLaunch(input);
|
|
@@ -3445,7 +3393,7 @@ runtime = {}) {
|
|
|
3445
3393
|
const notice = launchAssuranceNotice({ runId, reducedAssurance: b.reducedAssurance, engineClisJson: engineRosterJson(input.clisJson) });
|
|
3446
3394
|
const assuranceNotice = notice === null ? {} : { assuranceNotice: notice };
|
|
3447
3395
|
// (program DES-POWER-MODE) Whether the run is in power mode, and why not when it was wanted.
|
|
3448
|
-
const power = { ...(input.power === true ? { power: true } : {}), ...(powerNotice !== null ? { powerNotice } : {}) };
|
|
3396
|
+
const power = { ...(input.power === true ? { power: true } : {}), ...(powerNotice !== null ? { powerNotice } : {}), ...(humanConfirmNotice !== null ? { humanConfirmNotice } : {}) };
|
|
3449
3397
|
return reply.code(201).send({ runId, ...(linkedIssues !== undefined ? { linkedIssues } : {}), ...freeText, ...skillsWarning, ...assuranceNotice, ...power });
|
|
3450
3398
|
}
|
|
3451
3399
|
catch (err) {
|
|
@@ -3528,6 +3476,40 @@ runtime = {}) {
|
|
|
3528
3476
|
const out = await launchRun(req.body, { actor: actorOf(req), log: req.log });
|
|
3529
3477
|
return reply.code(out.statusCode).send(out.payload);
|
|
3530
3478
|
});
|
|
3479
|
+
// (studio#1150) What a launch of this body would keep of its human gates — the SAME `launchPosture` decision
|
|
3480
|
+
// `POST /runs` hands the engine — with nothing launched, recorded or read beyond what that decision reads. A launch
|
|
3481
|
+
// form renders it (and sends the `power` it shows) instead of modelling crew's rules.
|
|
3482
|
+
const LaunchPreviewSchema = z.strictObject({
|
|
3483
|
+
power: z.boolean().optional(),
|
|
3484
|
+
repoRef: z.string().min(1).optional(),
|
|
3485
|
+
workflow: z.string().min(1).optional(),
|
|
3486
|
+
plan: PlanSchema.optional(),
|
|
3487
|
+
projectId: z.string().min(1).optional(),
|
|
3488
|
+
humanConfirm: z.string().min(1).optional(),
|
|
3489
|
+
deliver: z.enum(['pr', 'none']).optional(),
|
|
3490
|
+
deliverGate: z.enum(['human', 'auto']).optional(),
|
|
3491
|
+
}).refine((b) => b.plan === undefined || b.workflow === undefined, {
|
|
3492
|
+
path: ['plan'],
|
|
3493
|
+
error: 'plan and workflow are mutually exclusive',
|
|
3494
|
+
}).refine((b) => b.deliverGate === undefined || b.deliver !== 'none', {
|
|
3495
|
+
path: ['deliverGate'],
|
|
3496
|
+
error: 'deliverGate has no meaning with deliver: "none" — there is no deliver phase to gate',
|
|
3497
|
+
});
|
|
3498
|
+
app.post(`${V}/runs/preview`, { config: { manifest: { requestType: 'LaunchPreviewBody', responseType: 'LaunchPreviewResponse', statusCodes: [200, 400] } } }, async (req, reply) => {
|
|
3499
|
+
const parsed = LaunchPreviewSchema.safeParse(req.body ?? {});
|
|
3500
|
+
if (!parsed.success)
|
|
3501
|
+
return reply.code(400).send(invalidBody(parsed.error, 'Invalid request body'));
|
|
3502
|
+
const p = await launchPosture(parsed.data, postureFacts);
|
|
3503
|
+
const posture = {
|
|
3504
|
+
power: p.power,
|
|
3505
|
+
...(p.humanConfirm !== undefined ? { humanConfirm: p.humanConfirm } : {}),
|
|
3506
|
+
deliver: p.deliver,
|
|
3507
|
+
autoDeliver: p.autoDeliver,
|
|
3508
|
+
...(p.powerNotice !== null ? { powerNotice: p.powerNotice } : {}),
|
|
3509
|
+
...(p.humanConfirmNotice !== null ? { humanConfirmNotice: p.humanConfirmNotice } : {}),
|
|
3510
|
+
};
|
|
3511
|
+
return { posture };
|
|
3512
|
+
});
|
|
3531
3513
|
/**
|
|
3532
3514
|
* (DES-CATALOG-002 §4.6) The `job` launcher: a chat job proposal's Go, one launcher per launch kind, each with the
|
|
3533
3515
|
* identity derived from the proposal (`sessionId` = its run id, so a retry finds and adopts it), the chat filing, the
|
|
@@ -3595,30 +3577,16 @@ runtime = {}) {
|
|
|
3595
3577
|
if (resolved === null)
|
|
3596
3578
|
throw new Error(`${p.what.label} is no longer in the catalog`);
|
|
3597
3579
|
const selfSeated = resolved.workflow !== null && SELF_SEATED.has(resolved.workflow);
|
|
3598
|
-
// The seats the person saw: the lead, and the roster narrowed to the proposal's keys.
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
//
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
if (Array.isArray(parsedRoster))
|
|
3607
|
-
inherited = parsedRoster;
|
|
3608
|
-
}
|
|
3609
|
-
catch {
|
|
3610
|
-
inherited = null;
|
|
3611
|
-
}
|
|
3612
|
-
}
|
|
3613
|
-
const current = launchRosterNaming(rosterWithStanding(), lead);
|
|
3614
|
-
// Inherited configuration for the seats it names; the current roster's entry for a seat added since (codex r3).
|
|
3615
|
-
const roster = inherited === null ? current : [...inherited, ...current.filter((s) => !inherited.some((i) => i.key === s.key))];
|
|
3616
|
-
const narrowed = keys.length > 0 ? roster.filter((s) => keys.includes(String(s.key))) : roster;
|
|
3617
|
-
const missingSeat = keys.find((k) => !roster.some((s) => String(s.key) === k));
|
|
3618
|
-
if (missingSeat !== undefined)
|
|
3619
|
-
throw new Error(`${missingSeat} is not on this daemon's roster; change who works on it`);
|
|
3580
|
+
// The seats the person saw: the lead, and the roster narrowed to the proposal's keys (`jobLaunchRoster`).
|
|
3581
|
+
// crew#645 / crew#1593 (coord merge check): the card says WHICH seats, never that they are usable now. The same
|
|
3582
|
+
// bounded readiness wait a launch with no roster gets runs FIRST, so the standing serialized here (and the lead's
|
|
3583
|
+
// eligibility `launchRun` checks against it) is the seats' own fresh answer: a lead whose login expired is refused
|
|
3584
|
+
// by name, never launched on a stale snapshot. A seat added meanwhile still doesn't join (narrowed to the card).
|
|
3585
|
+
await rosterWithStanding.ready?.();
|
|
3586
|
+
// crew#1590: every seat on the card is named, so an opt-in seat the person picked is on the roster too.
|
|
3587
|
+
const { clisJson } = jobLaunchRoster(launchRosterNaming(rosterWithStanding(), p.seats?.lead ?? undefined, p.seats?.keys ?? []), p);
|
|
3620
3588
|
const common = jobLaunchCommon(p, { runId: d.identity.runId, chatId: d.chatId }, {
|
|
3621
|
-
...(
|
|
3589
|
+
...(clisJson !== undefined ? { clisJson } : {}),
|
|
3622
3590
|
selfSeated,
|
|
3623
3591
|
});
|
|
3624
3592
|
// A power Start was checked before accepting; checked again here, so it never runs phased behind the person's back.
|
|
@@ -4431,7 +4399,8 @@ runtime = {}) {
|
|
|
4431
4399
|
// proposal, completing the proposal while the chat is open; never open the id again (codex r1).
|
|
4432
4400
|
const open = askPaths.get(seedChatId) !== undefined || chatScopes.get(seedChatId) !== undefined;
|
|
4433
4401
|
if (open || chatHistory?.has(seedChatId) === true) {
|
|
4434
|
-
|
|
4402
|
+
const stored = chatProposals.viewOfPid(seedChatId, personPid(seedChatId, seedActor.id, b.requestId));
|
|
4403
|
+
let view = stored === null ? null : await chatProposals.servedView(stored);
|
|
4435
4404
|
// The same request id with another seed is not a retry (codex r2).
|
|
4436
4405
|
if (view !== null && view.proposal.request?.digest !== requestDigest(seedBody(b.seed, b.requestId))) {
|
|
4437
4406
|
return reply.code(409).send({ code: 'request_reused', error: 'this requestId already started a chat with another job', chatId: seedChatId });
|
|
@@ -4956,6 +4925,8 @@ runtime = {}) {
|
|
|
4956
4925
|
};
|
|
4957
4926
|
},
|
|
4958
4927
|
rosterEligible: () => proposalRoster(rosterWithStanding()),
|
|
4928
|
+
// (F1/F2) Agents › "Use <seat> for new work": the pool every new chat job and document is drawn from.
|
|
4929
|
+
newWorkSeats: readNewWorkSeats,
|
|
4959
4930
|
runs: async () => (await adapter.sessionsDetail()).map((v) => decorateRun(v)),
|
|
4960
4931
|
chatOfRun: (runId) => runTimingIndex.chatIdFor(runId),
|
|
4961
4932
|
isAskPath: (runId) => runTimingIndex.isAskPath(runId),
|
|
@@ -5813,7 +5784,9 @@ runtime = {}) {
|
|
|
5813
5784
|
// turn. The file goes with the chat on `chatClosed` UNLESS a run promoted from it is still
|
|
5814
5785
|
// live (crew#619 retention — dropped when that run terminals), so a reclaimed id answers
|
|
5815
5786
|
// `[]` only once no promoted run holds the old file.
|
|
5816
|
-
|
|
5787
|
+
// (F1/F2) Served like `GET /chats/:id/messages`: an open job or document reads blocked while `newWorkSeats`
|
|
5788
|
+
// can't be honored.
|
|
5789
|
+
...(chatTranscripts !== undefined ? { messages: await chatProposals.withSeatsSetting(chatTranscripts.read(id)) } : {}),
|
|
5817
5790
|
};
|
|
5818
5791
|
}
|
|
5819
5792
|
catch (err) {
|
|
@@ -5943,7 +5916,8 @@ runtime = {}) {
|
|
|
5943
5916
|
const messages = chat === null ? null : chatHistory.messages(id);
|
|
5944
5917
|
if (chat === null || messages === null)
|
|
5945
5918
|
return reply.code(404).send({ error: `no chat ${id} in this daemon's history` });
|
|
5946
|
-
|
|
5919
|
+
// (F1/F2) An open job or document reads blocked while `newWorkSeats` can't be honored: a live state, read now.
|
|
5920
|
+
return { chat, messages: await chatProposals.withSeatsSetting(messages), attachments: chatAttachments.list(id) };
|
|
5947
5921
|
});
|
|
5948
5922
|
// DES-SYSTEM-CHAT (api-types 0.137.0): upload files to a chat (multipart/form-data). The body is
|
|
5949
5923
|
// buffered by a parser scoped to this route alone, capped a little over the per-message total;
|
|
@@ -6175,6 +6149,14 @@ runtime = {}) {
|
|
|
6175
6149
|
qeUnitOrds: (run.units ?? [])
|
|
6176
6150
|
.filter((u) => u.qe_acceptance != null)
|
|
6177
6151
|
.map((u) => u.ord),
|
|
6152
|
+
// crew#1560: the verdicts the engine bound on its latest QE attempt decide what counts.
|
|
6153
|
+
...(() => {
|
|
6154
|
+
if (opts.treeScoped === false)
|
|
6155
|
+
return {};
|
|
6156
|
+
const t = run.session.verified_tree;
|
|
6157
|
+
const bound = engineBoundOf(run, typeof t === 'string' && t !== '' ? t : null);
|
|
6158
|
+
return bound === null ? {} : { engineBound: bound, engineRetiredQeRuns: engineRetiredQeRunsOf(run) };
|
|
6159
|
+
})(),
|
|
6178
6160
|
requirement,
|
|
6179
6161
|
...(opts.qeRunId !== undefined ? { qeRunId: opts.qeRunId } : {}),
|
|
6180
6162
|
// AW-14 (arch-R13a + R16): the conformance section reads the same wires the standalone
|
|
@@ -6237,6 +6219,48 @@ runtime = {}) {
|
|
|
6237
6219
|
}
|
|
6238
6220
|
return check;
|
|
6239
6221
|
}
|
|
6222
|
+
/** (crew#1560) The verdict the engine bound on the latest attempt of EVERY unit it runs its isolated
|
|
6223
|
+
* QE reviewer for (the units carrying a QE ledger root): the bound QE run and the session nonce of
|
|
6224
|
+
* the reviewer turn whose verdict it bound — or `null` (no cut, today's reading) when any such unit
|
|
6225
|
+
* has no bound record, its record judged a tree other than the deliverable tree, or no unit runs a
|
|
6226
|
+
* reviewer at all. */
|
|
6227
|
+
function engineBoundOf(run, deliverableTree) {
|
|
6228
|
+
const out = [];
|
|
6229
|
+
for (const u of [...(run.units ?? [])].sort((a, b) => a.ord - b.ord)) {
|
|
6230
|
+
const unit = u;
|
|
6231
|
+
if (typeof unit.qe_ledger_root !== 'string' || unit.qe_ledger_root === '')
|
|
6232
|
+
continue;
|
|
6233
|
+
const r = unit.qe_review;
|
|
6234
|
+
if (r === undefined || r === null)
|
|
6235
|
+
return null;
|
|
6236
|
+
if (typeof r.qe_run_id !== 'string' || r.qe_run_id === '')
|
|
6237
|
+
return null;
|
|
6238
|
+
if (deliverableTree !== null && r.tree !== deliverableTree)
|
|
6239
|
+
return null;
|
|
6240
|
+
const attempts = Array.isArray(r.attempts) ? r.attempts : [];
|
|
6241
|
+
const turn = [...attempts].reverse().find((a) => a.status === 'verdict');
|
|
6242
|
+
if (turn === undefined || typeof turn.session !== 'string' || turn.session === '')
|
|
6243
|
+
return null;
|
|
6244
|
+
out.push({ qeRunId: r.qe_run_id, session: turn.session });
|
|
6245
|
+
}
|
|
6246
|
+
return out.length > 0 ? out : null;
|
|
6247
|
+
}
|
|
6248
|
+
/** (crew#1560) The QE runs a "redo the QE check" retired on the run's reviewer units, and when
|
|
6249
|
+
* (`units[].qe_redos[]` `qe_run_id`, `at`): verdicts recorded on them before the redo are superseded. */
|
|
6250
|
+
function engineRetiredQeRunsOf(run) {
|
|
6251
|
+
const out = [];
|
|
6252
|
+
for (const u of run.units ?? []) {
|
|
6253
|
+
const unit = u;
|
|
6254
|
+
if (typeof unit.qe_ledger_root !== 'string' || unit.qe_ledger_root === '')
|
|
6255
|
+
continue;
|
|
6256
|
+
for (const r of Array.isArray(unit.qe_redos) ? unit.qe_redos : []) {
|
|
6257
|
+
if (typeof r.qe_run_id === 'string' && r.qe_run_id !== '' && typeof r.at === 'number' && Number.isFinite(r.at)) {
|
|
6258
|
+
out.push({ qeRunId: r.qe_run_id, at: r.at });
|
|
6259
|
+
}
|
|
6260
|
+
}
|
|
6261
|
+
}
|
|
6262
|
+
return out;
|
|
6263
|
+
}
|
|
6240
6264
|
/** The engine's isolated QE review record on the run's latest QE unit (`units[].qe_review`, the
|
|
6241
6265
|
* unit's last attempt), or `null` when the engine kept none. */
|
|
6242
6266
|
function engineQeReviewOf(run) {
|
|
@@ -7005,6 +7029,47 @@ runtime = {}) {
|
|
|
7005
7029
|
function powerSupported() {
|
|
7006
7030
|
return typeof adapter.supportsPowerMode === 'function' && adapter.supportsPowerMode();
|
|
7007
7031
|
}
|
|
7032
|
+
/** A hand launch of the run review is prepared by the daemon (DES-RUNS-REVIEW-001 §3) when it carries the review service. */
|
|
7033
|
+
function reviewPrepared(workflow) {
|
|
7034
|
+
return workflow === REVIEW_WORKFLOW && runtime.reviewLaunch !== undefined;
|
|
7035
|
+
}
|
|
7036
|
+
/** (studio#1150) What `launchPosture` reads of this daemon, for `POST /runs` and `POST /runs/preview` alike. */
|
|
7037
|
+
const postureFacts = {
|
|
7038
|
+
powerModeDefault: async () => (await adapter.getSettings()).powerModeDefault ?? true,
|
|
7039
|
+
namesPreset,
|
|
7040
|
+
powerSupported,
|
|
7041
|
+
// The delivery contract (crew#393): a completed code run must end with a reviewable
|
|
7042
|
+
// deliverable, or an explicit, recorded decision not to. So the deliver option is resolved
|
|
7043
|
+
// HERE, at the boundary, for every launch:
|
|
7044
|
+
// - explicit 'pr' / 'none' wins (the operator decided);
|
|
7045
|
+
// - omitted + repo-scoped + a CODE-WORK workflow (the def carries at least one
|
|
7046
|
+
// `executes_code` phase that is NOT an evaluator — feature/bug/migration and a Tool
|
|
7047
|
+
// phase that writes, not chat/onboarding/recon, and not domain-extraction, whose only
|
|
7048
|
+
// code phase is the `coverage` EVALUATOR, which executes code solely to write its own
|
|
7049
|
+
// report into the tree for its validator — nothing to deliver) ⇒ the
|
|
7050
|
+
// daemon's `deliverDefault` setting ('pr' unless the operator flipped it) — the default
|
|
7051
|
+
// that keeps run 83052f0b's work from stranding invisibly again. The code-work guard is
|
|
7052
|
+
// the issue's own scope ("default deliver:'pr' for CODE-WORK launches"): a read-only
|
|
7053
|
+
// workflow leaves a clean worktree, and the deliver script FAILS a clean worktree loudly
|
|
7054
|
+
// ("nothing to deliver", crew#317) — defaulting it on would flip every repo-scoped chat
|
|
7055
|
+
// from completed to failed;
|
|
7056
|
+
// - omitted otherwise ⇒ 'none': a repo-less run has no worktree to lift, and a free-text
|
|
7057
|
+
// run has no def to append the deliver phase to (the adapter REFUSES deliver:'pr'
|
|
7058
|
+
// without a workflow rather than silently dropping it, so defaulting it on would turn
|
|
7059
|
+
// a legal launch into a 400).
|
|
7060
|
+
// The adapter input spells 'none' as an omitted field; the audit entry below records the
|
|
7061
|
+
// RESOLVED value either way, plus whether it was defaulted.
|
|
7062
|
+
deliverDefault: async (workflow) => {
|
|
7063
|
+
// Unknown def ⇒ no default (the launch fails at workflow resolution with its own error —
|
|
7064
|
+
// defaulting 'pr' onto it would swap that for a misleading deliver-flavored one).
|
|
7065
|
+
const def = adapter.getWorkflow(workflow);
|
|
7066
|
+
const codeWork = def !== null && def.phases.some((p) => p.executes_code === true && p.role !== 'evaluator');
|
|
7067
|
+
return codeWork && (await adapter.getSettings()).deliverDefault !== 'none' ? 'pr' : 'none';
|
|
7068
|
+
},
|
|
7069
|
+
// The launch route removes a change review's delivery (it posts nothing), and a run review's preparation removes it
|
|
7070
|
+
// (`ReviewService.prepareLaunch`). The default evals' preparation keeps whatever delivery was resolved.
|
|
7071
|
+
preparationDropsDelivery: (workflow) => workflow === REVIEW_CHANGE_WORKFLOW || reviewPrepared(workflow),
|
|
7072
|
+
};
|
|
7008
7073
|
// ── Power mode (program DES-POWER-MODE; api-types 0.149.0) ─────────────────────────────────────
|
|
7009
7074
|
// The engine computes every rigor value; these routes only carry a person's switch, raise or pause
|
|
7010
7075
|
// answer to it (human actors only: a worker or plugin bearer gets 403) and read its record back.
|
|
@@ -7163,6 +7228,29 @@ runtime = {}) {
|
|
|
7163
7228
|
* left (re-seat a worker the first just started, or approve twice).
|
|
7164
7229
|
*/
|
|
7165
7230
|
const reassignsInFlight = new Set();
|
|
7231
|
+
/**
|
|
7232
|
+
* (crew#1512, studio#1170) The engine's list of a gate's answers ({@link GateAction}) less what CREW refuses on
|
|
7233
|
+
* the same gate, by the same checks its POST routes run: every `approve: true` answer at a deliver unit that
|
|
7234
|
+
* the delivery checks refuse (the freeze; QE acceptance with no attributed PASS) — the in-place `skip_qe` kept
|
|
7235
|
+
* when the checks take it — every one on an analysis run's held plan change (crew#1157), and a reassign on a
|
|
7236
|
+
* steering-author run (its approve lands the proposal). Marks
|
|
7237
|
+
* `humanOnly` where crew answers a non-human actor 403 `human_operator_only`.
|
|
7238
|
+
*/
|
|
7239
|
+
async function crewGateActions(run, gated, gateKind, actions) {
|
|
7240
|
+
const declines = (a) => a.action === 'reject' || a.action === 'request_changes';
|
|
7241
|
+
// crew#1157: an analysis run's held plan change is never approved (`gateForDecision`): only the declines stay.
|
|
7242
|
+
let approveRefused = analysisPlanRefusal(run.session.id, { gateKind }) !== null;
|
|
7243
|
+
let skipRefused = approveRefused;
|
|
7244
|
+
if (!approveRefused && gated !== undefined && isDeliverUnit(gated)) {
|
|
7245
|
+
approveRefused = 'refusal' in (await deliverApprovalRefusal(run, gated));
|
|
7246
|
+
skipRefused = 'refusal' in (await deliverApprovalRefusal(run, gated, 'skip'));
|
|
7247
|
+
}
|
|
7248
|
+
const steering = isSteeringAuthorRun(run);
|
|
7249
|
+
return actions
|
|
7250
|
+
.filter((a) => declines(a) || !(a.action === SKIP_QE_ACTION ? skipRefused : approveRefused))
|
|
7251
|
+
.filter((a) => !(steering && a.action === 'reassign'))
|
|
7252
|
+
.map((a) => (a.action === SKIP_QE_ACTION || a.action === SKIP_RULES_ACTION ? { ...a, humanOnly: true } : a));
|
|
7253
|
+
}
|
|
7166
7254
|
/**
|
|
7167
7255
|
* codex r1 on #1060: whether approving the run's open gate ACCEPTS the parked unit's work rather
|
|
7168
7256
|
* than re-running it (wicked-core `confirm_gate`: a `judge_unavailable` / `qe_reviewer_unavailable`
|
|
@@ -7274,6 +7362,32 @@ runtime = {}) {
|
|
|
7274
7362
|
}
|
|
7275
7363
|
const cursor = resolveCursorUnit(run);
|
|
7276
7364
|
const ord = cursor?.ord ?? run.session.unit_ix;
|
|
7365
|
+
// (crew#1512) A parked run's reassign APPROVES its gate, so it is the engine's list that says whether this gate
|
|
7366
|
+
// takes one and on which seats — checked before anything is re-seated or approved. An addon without the read keeps
|
|
7367
|
+
// the older rule (`approveAcceptsWork`, below); with the read, a failed or stale one changes nothing.
|
|
7368
|
+
// The adapter always has the method; whether the ADDON carries the read is `supportsGateActions` (a partial adapter
|
|
7369
|
+
// that defines `gateActions` itself carries it).
|
|
7370
|
+
const listsActions = gated && typeof adapter.gateActions === 'function' && (adapter.supportsGateActions?.() ?? true);
|
|
7371
|
+
if (listsActions) {
|
|
7372
|
+
const listed = await adapter.gateActions(id).catch(() => undefined);
|
|
7373
|
+
if (listed === undefined || listed === null || listed.ord !== ord) {
|
|
7374
|
+
return reply.code(409).send({ error: `run ${id}'s open gate could not be read for its answers — read the gate again. Nothing was changed.`, code: 'gate_unknown' });
|
|
7375
|
+
}
|
|
7376
|
+
const offer = listed.actions.find((a) => a.action === 'reassign');
|
|
7377
|
+
if (offer === undefined) {
|
|
7378
|
+
const approve = listed.actions.find((a) => a.action === 'approve');
|
|
7379
|
+
return reply.code(409).send({
|
|
7380
|
+
error: `run ${id}'s gate takes no reassign${approve !== undefined ? ` (its approve is ${approve.intent.replace(/_/g, ' ')})` : ''} — answer it via POST /runs/${id}/gate. Nothing was changed.`,
|
|
7381
|
+
code: 'action_not_offered',
|
|
7382
|
+
});
|
|
7383
|
+
}
|
|
7384
|
+
if (requestedCli === undefined || !(offer.seats ?? []).includes(requestedCli)) {
|
|
7385
|
+
return reply.code(409).send({
|
|
7386
|
+
error: `run ${id}'s gate re-seats unit ${ord} only on ${(offer.seats ?? []).join(', ') || 'no seat'}${requestedCli === undefined ? ': name one' : `, not '${requestedCli}'`}. Nothing was changed.`,
|
|
7387
|
+
code: 'seat_not_offered',
|
|
7388
|
+
});
|
|
7389
|
+
}
|
|
7390
|
+
}
|
|
7277
7391
|
let noteRode = false;
|
|
7278
7392
|
const approve = async () => {
|
|
7279
7393
|
if (typeof adapter.confirmGate !== 'function')
|
|
@@ -7298,7 +7412,7 @@ runtime = {}) {
|
|
|
7298
7412
|
// a `judge_unavailable` / `qe_reviewer_unavailable` denial (the operator judges, the unit
|
|
7299
7413
|
// counts) or a `review_adjudication` gate (lands with carried items) — must not follow a
|
|
7300
7414
|
// re-seat: the new seat would be recorded on work it never did, and never run.
|
|
7301
|
-
const accepts = await approveAcceptsWork(run, ord, decided?.gateKind);
|
|
7415
|
+
const accepts = listsActions ? null : await approveAcceptsWork(run, ord, decided?.gateKind);
|
|
7302
7416
|
if (accepts !== null) {
|
|
7303
7417
|
return reply.code(409).send({
|
|
7304
7418
|
error: `run ${id} is parked at a gate whose approve ${accepts}, so a reassign would not run unit ${ord} on '${requestedCli}' — approve, send back or stop it via POST /runs/${id}/gate. Nothing was changed.`,
|
|
@@ -7407,6 +7521,29 @@ runtime = {}) {
|
|
|
7407
7521
|
},
|
|
7408
7522
|
};
|
|
7409
7523
|
};
|
|
7524
|
+
// (crew#1512, studio#1170) EVERY ANSWER THIS GATE TAKES NOW: the engine's own list (each candidate run
|
|
7525
|
+
// through its decision path's pre-checks), less what crew refuses itself (`crewGateActions`). Read each
|
|
7526
|
+
// time; absent on an addon without the read, or when the engine's open gate is not this one.
|
|
7527
|
+
const actionsAt = async (ord, gated) => {
|
|
7528
|
+
if (typeof adapter.gateActions !== 'function')
|
|
7529
|
+
return {};
|
|
7530
|
+
try {
|
|
7531
|
+
const listed = await adapter.gateActions(id);
|
|
7532
|
+
if (listed === null || listed.ord !== ord)
|
|
7533
|
+
return {};
|
|
7534
|
+
const run = await runOf();
|
|
7535
|
+
if (run === undefined)
|
|
7536
|
+
return {};
|
|
7537
|
+
return {
|
|
7538
|
+
actions: await crewGateActions(run, gated, listed.gateKind, listed.actions),
|
|
7539
|
+
...(listed.planRev !== undefined ? { planRev: listed.planRev } : {}),
|
|
7540
|
+
};
|
|
7541
|
+
}
|
|
7542
|
+
catch {
|
|
7543
|
+
// A failed read lists nothing; the skin falls back to the gate's own offers.
|
|
7544
|
+
return {};
|
|
7545
|
+
}
|
|
7546
|
+
};
|
|
7410
7547
|
// The record judges the cache (crew#1083 round 7): rows that disagree on the ord are 409
|
|
7411
7548
|
// `gate_unknown` whether or not something is cached, and a cached entry is served — for its
|
|
7412
7549
|
// presentation fields (prompt, choices, recommended) — only when its ord is the record's open
|
|
@@ -7430,7 +7567,7 @@ runtime = {}) {
|
|
|
7430
7567
|
if (servable) {
|
|
7431
7568
|
// One read of the gated unit serves both its receipt and its re-judge offer.
|
|
7432
7569
|
const gated = await unitAt(cached.ord);
|
|
7433
|
-
return { runId: id, ...cached, assurance: receiptOf(gated), ...(await rejudgeAt(cached.ord, gated)), ...(await skipQeAt(gated)) };
|
|
7570
|
+
return { runId: id, ...cached, assurance: receiptOf(gated), ...(await rejudgeAt(cached.ord, gated)), ...(await skipQeAt(gated)), ...(await actionsAt(cached.ord, gated)) };
|
|
7434
7571
|
}
|
|
7435
7572
|
gateCache.forget(id);
|
|
7436
7573
|
}
|
|
@@ -7507,7 +7644,7 @@ runtime = {}) {
|
|
|
7507
7644
|
return reply.code(404).send({ error: 'No open gate for this run' });
|
|
7508
7645
|
}
|
|
7509
7646
|
const gatedUnit = run.units?.find((u) => u.ord === open.ord);
|
|
7510
|
-
return { runId: id, ...open, assurance: receiptOf(gatedUnit), ...(await rejudgeAt(open.ord, gatedUnit)), ...(await skipQeAt(gatedUnit)) };
|
|
7647
|
+
return { runId: id, ...open, assurance: receiptOf(gatedUnit), ...(await rejudgeAt(open.ord, gatedUnit)), ...(await skipQeAt(gatedUnit)), ...(await actionsAt(open.ord, gatedUnit)) };
|
|
7511
7648
|
});
|
|
7512
7649
|
// ── Elicitation (DES-002) ────────────────────────────────────────────────────
|
|
7513
7650
|
//
|
|
@@ -8970,6 +9107,16 @@ runtime = {}) {
|
|
|
8970
9107
|
return reply.code(403).send({ error: 'Only a person can change the power mode default (powerModeDefault)' });
|
|
8971
9108
|
}
|
|
8972
9109
|
}
|
|
9110
|
+
// newWorkSeats (F1/F2): which seats new chats and jobs are drawn from (`core/job-seats.ts`). A list of seat keys,
|
|
9111
|
+
// or null for the default rule; a person's choice only (a worker's bearer gets 403).
|
|
9112
|
+
if (Object.hasOwn(patch, 'newWorkSeats')) {
|
|
9113
|
+
if (patch.newWorkSeats !== null && !isSeatKeyList(patch.newWorkSeats)) {
|
|
9114
|
+
return reply.code(400).send({ error: 'newWorkSeats must be a list of seat keys (at most 64), or null' });
|
|
9115
|
+
}
|
|
9116
|
+
if (!isHumanOperator(actorOf(req))) {
|
|
9117
|
+
return reply.code(403).send({ error: 'Only a person can change which seats new work uses (newWorkSeats)' });
|
|
9118
|
+
}
|
|
9119
|
+
}
|
|
8973
9120
|
// qeAcceptance (api-types 0.120.0): 'required' | 'off' only. 'off' skips QE acceptance on every
|
|
8974
9121
|
// launch that requires it (labelled with the setting), so a typo must be a 400, never a dropped key.
|
|
8975
9122
|
// Turning it off waives an assurance instrument on every launch after it, so only a PERSON may
|
|
@@ -9052,7 +9199,11 @@ runtime = {}) {
|
|
|
9052
9199
|
const problem = registry.validateSettingsPatch(patch.watch);
|
|
9053
9200
|
if (problem !== null)
|
|
9054
9201
|
return reply.code(400).send({ error: problem });
|
|
9055
|
-
|
|
9202
|
+
// The merge runs INSIDE the settings write (crew#1591), against the stored `watch` it
|
|
9203
|
+
// replaces — merging over an earlier read would let two people's switches revert each other.
|
|
9204
|
+
const watchPatch = patch.watch;
|
|
9205
|
+
const at = Date.now();
|
|
9206
|
+
watchNext = (current) => registry.mergeSettings(current.watch, watchPatch, actor.id, at);
|
|
9056
9207
|
}
|
|
9057
9208
|
// Only known engine keys and validated `studio.*` keys are persisted. A key that is
|
|
9058
9209
|
// NEITHER is dropped, not refused: request bodies are forward-additive too (DES-STUDIO-001
|
|
@@ -9070,6 +9221,7 @@ runtime = {}) {
|
|
|
9070
9221
|
'deliverDefault',
|
|
9071
9222
|
'qeAcceptance',
|
|
9072
9223
|
'powerModeDefault',
|
|
9224
|
+
'newWorkSeats',
|
|
9073
9225
|
'onboardingAutoCapture',
|
|
9074
9226
|
'deliverIdentityLogin',
|
|
9075
9227
|
'deliverIdentityByRepo',
|
|
@@ -9094,13 +9246,16 @@ runtime = {}) {
|
|
|
9094
9246
|
for (const key of studioKeys) {
|
|
9095
9247
|
safe[key] = patch[key];
|
|
9096
9248
|
}
|
|
9097
|
-
if (watchNext !== undefined)
|
|
9098
|
-
safe.watch = watchNext;
|
|
9099
9249
|
// `Object.hasOwn`, NOT `k in safe`: `in` walks the prototype chain, so a dropped key named
|
|
9100
9250
|
// `toString` / `valueOf` / `constructor` would test as "kept" and vanish from `ignored` —
|
|
9101
9251
|
// the exact silent drop this route exists to end.
|
|
9102
|
-
|
|
9103
|
-
const
|
|
9252
|
+
// `watch` is merged inside the write (crew#1591), so it is persisted without sitting in `safe`.
|
|
9253
|
+
const changed = watchNext === undefined ? Object.keys(safe) : [...Object.keys(safe), 'watch'];
|
|
9254
|
+
const ignored = Object.keys(patch).filter((k) => !Object.hasOwn(safe, k) && !(k === 'watch' && watchNext !== undefined));
|
|
9255
|
+
const derive = watchNext;
|
|
9256
|
+
const settings = derive === undefined
|
|
9257
|
+
? await adapter.updateSettings(safe)
|
|
9258
|
+
: await adapter.updateSettings(safe, (current) => ({ watch: derive(current) }));
|
|
9104
9259
|
if (watchNext !== undefined)
|
|
9105
9260
|
runtime.watchRegistry?.()?.applySettings(settings.watch);
|
|
9106
9261
|
// Re-apply the worker-config root to this process's env (seat sign-in). The engine reads
|
|
@@ -9122,7 +9277,7 @@ runtime = {}) {
|
|
|
9122
9277
|
// when there is one) is where a dropped unknown key stops being invisible.
|
|
9123
9278
|
audit.record('settings.updated', actorOf(req), {
|
|
9124
9279
|
detail: {
|
|
9125
|
-
changed
|
|
9280
|
+
changed,
|
|
9126
9281
|
...(ignored.length > 0 ? { ignored } : {}),
|
|
9127
9282
|
// Which watchers were switched or re-thresholded (health reads the stamps; this is the trail).
|
|
9128
9283
|
...(watchNext !== undefined ? { watch: patch.watch } : {}),
|
|
@@ -9321,6 +9476,16 @@ runtime = {}) {
|
|
|
9321
9476
|
catch (err) {
|
|
9322
9477
|
return estateUpstreamError(reply, err);
|
|
9323
9478
|
}
|
|
9479
|
+
// crew#1546: an edited learning's replacement whose learning is gone is stale: refused and rejected, never approved,
|
|
9480
|
+
// so no crash window can bring retired words back (accept-with-edit checks the same in `approveEdited`).
|
|
9481
|
+
try {
|
|
9482
|
+
const stale = row?.kind_type === 'memory' ? await refuseStaleReplacement(estateTool, id, row.payload) : null;
|
|
9483
|
+
if (stale !== null)
|
|
9484
|
+
return reply.code(409).send({ error: stale, code: 'stale_replacement' });
|
|
9485
|
+
}
|
|
9486
|
+
catch (err) {
|
|
9487
|
+
return reply.code(502).send({ error: `checking whether proposal ${id} is a stale replacement failed (${message(err)}); nothing was approved` });
|
|
9488
|
+
}
|
|
9324
9489
|
// DC-S4a: a proposal THIS ledger filed for a decision lands through `remember()` — the one
|
|
9325
9490
|
// landing path, with the human check inside it (§4.5). A payload naming an id the ledger does
|
|
9326
9491
|
// not know is an ordinary policy proposal (no ORIGIN claim) and takes the path below.
|
|
@@ -9725,6 +9890,181 @@ runtime = {}) {
|
|
|
9725
9890
|
return items.map(shapeMemoryItem);
|
|
9726
9891
|
};
|
|
9727
9892
|
const deletedCount = (raw) => (typeof raw === 'object' && raw !== null ? raw['deleted_count'] : undefined);
|
|
9893
|
+
const pendingMemoryProposals = async () => {
|
|
9894
|
+
const raw = await estateTool('proposal.list', { kind_type: 'memory', state: 'pending' });
|
|
9895
|
+
const items = typeof raw === 'object' && raw !== null ? raw['proposals'] : undefined;
|
|
9896
|
+
if (!Array.isArray(items))
|
|
9897
|
+
throw new EstateMcpError('proposal.list returned an unexpected shape');
|
|
9898
|
+
return items.flatMap((i) => {
|
|
9899
|
+
const r = typeof i === 'object' && i !== null ? i : {};
|
|
9900
|
+
const payload = typeof r['payload'] === 'object' && r['payload'] !== null ? r['payload'] : {};
|
|
9901
|
+
const facets = typeof r['facets'] === 'object' && r['facets'] !== null ? r['facets'] : {};
|
|
9902
|
+
return typeof r['id'] === 'string'
|
|
9903
|
+
? [{ id: r['id'], content: typeof payload['content'] === 'string' ? payload['content'] : '', reach: typeof payload['reach'] === 'string' ? payload['reach'] : null, facets, replaces: replacesOf(payload) }]
|
|
9904
|
+
: [];
|
|
9905
|
+
});
|
|
9906
|
+
};
|
|
9907
|
+
/** Reject these proposals; true only when the queue is read back with none of them pending. */
|
|
9908
|
+
const withdraw = async (ids) => {
|
|
9909
|
+
for (const id of ids)
|
|
9910
|
+
await estateTool('proposal.reject', { id }).catch(() => undefined);
|
|
9911
|
+
try {
|
|
9912
|
+
const still = new Set((await pendingMemoryProposals()).map((q) => q.id));
|
|
9913
|
+
return ids.every((id) => !still.has(id));
|
|
9914
|
+
}
|
|
9915
|
+
catch {
|
|
9916
|
+
return false;
|
|
9917
|
+
}
|
|
9918
|
+
};
|
|
9919
|
+
const queued = (ids) => ` A proposal of the new words (${ids.join(', ')}) may still be pending: reject it on the approve page.`;
|
|
9920
|
+
const reapproveMemory = async (old, content, beforeIds) => {
|
|
9921
|
+
const reach = old.scope === '' ? 'project' : old.scope.startsWith('operator:') ? 'operator' : null;
|
|
9922
|
+
if (reach === null) {
|
|
9923
|
+
return { status: 409, error: `${old.id} is an approved learning at scope ${JSON.stringify(old.scope)}, which approval cannot place again; nothing changed` };
|
|
9924
|
+
}
|
|
9925
|
+
// The replacement names what it replaces, so approval can refuse it once that memory is gone.
|
|
9926
|
+
const payload = { content, reach, [REPLACES_KEY]: old.id };
|
|
9927
|
+
if (old.tier !== '')
|
|
9928
|
+
payload['tier'] = old.tier;
|
|
9929
|
+
// What was already queued, so a submit whose answer is lost can find the one it filed.
|
|
9930
|
+
let queuedBefore;
|
|
9931
|
+
try {
|
|
9932
|
+
queuedBefore = new Set((await pendingMemoryProposals()).map((q) => q.id));
|
|
9933
|
+
}
|
|
9934
|
+
catch (err) {
|
|
9935
|
+
return { status: 502, error: `reading the approve queue failed (${message(err)}); nothing changed` };
|
|
9936
|
+
}
|
|
9937
|
+
// The memory's OWN proposal must be settled first (codex r2 on crew#1546): estate writes `proposal:<id>`
|
|
9938
|
+
// before it records the approval, so a write that failed in between leaves it pending, and approving it after
|
|
9939
|
+
// this edit would bring the retired words back. Approving it again writes the same memory (idempotent).
|
|
9940
|
+
const sourcePid = old.id.slice(APPROVED_MEMORY_PREFIX.length);
|
|
9941
|
+
if (queuedBefore.has(sourcePid)) {
|
|
9942
|
+
await estateTool('proposal.approve', { id: sourcePid }).catch(() => undefined);
|
|
9943
|
+
try {
|
|
9944
|
+
queuedBefore = new Set((await pendingMemoryProposals()).map((q) => q.id));
|
|
9945
|
+
}
|
|
9946
|
+
catch (err) {
|
|
9947
|
+
return { status: 502, error: `settling ${old.id}'s own proposal could not be checked (${message(err)}); nothing changed` };
|
|
9948
|
+
}
|
|
9949
|
+
if (queuedBefore.has(sourcePid)) {
|
|
9950
|
+
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` };
|
|
9951
|
+
}
|
|
9952
|
+
}
|
|
9953
|
+
// Superseded replacements are settled too (coord merge check): one of this memory left pending by an edit that
|
|
9954
|
+
// never finished, or of a memory that is already gone, is rejected before the new one is filed.
|
|
9955
|
+
let superseded;
|
|
9956
|
+
try {
|
|
9957
|
+
superseded = (await pendingMemoryProposals()).filter((q) => q.replaces !== null && (q.replaces === old.id || !beforeIds.has(q.replaces))).map((q) => q.id);
|
|
9958
|
+
}
|
|
9959
|
+
catch (err) {
|
|
9960
|
+
return { status: 502, error: `reading the approve queue failed (${message(err)}); nothing changed` };
|
|
9961
|
+
}
|
|
9962
|
+
if (superseded.length > 0 && !(await withdraw(superseded))) {
|
|
9963
|
+
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` };
|
|
9964
|
+
}
|
|
9965
|
+
let pid = null;
|
|
9966
|
+
let submitErr = null;
|
|
9967
|
+
try {
|
|
9968
|
+
const raw = await estateTool('proposal.submit', { kind_type: 'memory', payload, facets: old.facets });
|
|
9969
|
+
const id = typeof raw === 'object' && raw !== null ? raw['id'] : undefined;
|
|
9970
|
+
if (typeof id === 'string' && id !== '')
|
|
9971
|
+
pid = id;
|
|
9972
|
+
else
|
|
9973
|
+
submitErr = new EstateMcpError('proposal.submit returned no proposal id');
|
|
9974
|
+
}
|
|
9975
|
+
catch (err) {
|
|
9976
|
+
submitErr = err;
|
|
9977
|
+
}
|
|
9978
|
+
if (pid === null) {
|
|
9979
|
+
// The submit may still have filed (a lost answer): find what it filed and withdraw it.
|
|
9980
|
+
// Ours = new since the snapshot, with these words, this reach and these facets (codex r2: words alone would
|
|
9981
|
+
// reject another caller's filing for another repository).
|
|
9982
|
+
const ours = (q) => !queuedBefore.has(q.id) && q.content === content && (q.reach === null || q.reach === reach) && q.replaces === old.id &&
|
|
9983
|
+
Object.entries(old.facets).every(([k, v]) => q.facets[k] === v) && Object.keys(q.facets).every((k) => k in old.facets);
|
|
9984
|
+
let strays;
|
|
9985
|
+
try {
|
|
9986
|
+
strays = (await pendingMemoryProposals()).filter(ours).map((q) => q.id);
|
|
9987
|
+
}
|
|
9988
|
+
catch (err) {
|
|
9989
|
+
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'])}` };
|
|
9990
|
+
}
|
|
9991
|
+
const gone = strays.length === 0 || (await withdraw(strays));
|
|
9992
|
+
// A filing approved meanwhile is no longer pending: the store, not the queue, says whether it landed.
|
|
9993
|
+
let approvedCopies;
|
|
9994
|
+
try {
|
|
9995
|
+
approvedCopies = (await listAll()).filter((m) => m.id.startsWith(APPROVED_MEMORY_PREFIX) && !beforeIds.has(m.id) && m.content.trim() === content).map((m) => m.id);
|
|
9996
|
+
}
|
|
9997
|
+
catch {
|
|
9998
|
+
approvedCopies = null;
|
|
9999
|
+
}
|
|
10000
|
+
const landedNote = approvedCopies === null
|
|
10001
|
+
? `; the store could not be re-read, so an approved copy of the new words may exist beside ${old.id}`
|
|
10002
|
+
: approvedCopies.length > 0
|
|
10003
|
+
? `; an approved copy of the new words exists beside ${old.id}: ${approvedCopies.join(', ')}`
|
|
10004
|
+
: '';
|
|
10005
|
+
return {
|
|
10006
|
+
status: 502,
|
|
10007
|
+
error: `filing the new words for approval failed (${message(submitErr)})${landedNote === '' ? '; nothing changed' : landedNote}${gone ? '' : `.${queued(strays)}`}`,
|
|
10008
|
+
};
|
|
10009
|
+
}
|
|
10010
|
+
const newId = `${APPROVED_MEMORY_PREFIX}${pid}`;
|
|
10011
|
+
const approve = () => estateTool('proposal.approve', { id: pid }).then(() => null, (err) => err);
|
|
10012
|
+
const approveErr = await approve();
|
|
10013
|
+
let landed;
|
|
10014
|
+
try {
|
|
10015
|
+
landed = (await listAll()).find((m) => m.id === newId);
|
|
10016
|
+
}
|
|
10017
|
+
catch (err) {
|
|
10018
|
+
return { status: 502, error: `approving the new words could not be checked (${message(err)}); ${newId} may exist beside ${old.id}.${queued([pid])}` };
|
|
10019
|
+
}
|
|
10020
|
+
if (landed === undefined) {
|
|
10021
|
+
const gone = await withdraw([pid]);
|
|
10022
|
+
return { status: 502, error: `approving the new words failed (${approveErr === null ? 'no memory was written' : message(approveErr)}); nothing changed${gone ? '' : `.${queued([pid])}`}` };
|
|
10023
|
+
}
|
|
10024
|
+
// Taking a written replacement back out: its memory erased and its proposal never left pending.
|
|
10025
|
+
const undo = async (why) => {
|
|
10026
|
+
await estateTool('memory.erase', { id: newId }).catch(() => undefined);
|
|
10027
|
+
let erased = false;
|
|
10028
|
+
try {
|
|
10029
|
+
erased = !(await listAll()).some((m) => m.id === newId);
|
|
10030
|
+
}
|
|
10031
|
+
catch {
|
|
10032
|
+
// Reported below as not confirmed gone.
|
|
10033
|
+
}
|
|
10034
|
+
let settled = false;
|
|
10035
|
+
try {
|
|
10036
|
+
settled = !(await pendingMemoryProposals()).some((q) => q.id === pid) || (await withdraw([pid]));
|
|
10037
|
+
}
|
|
10038
|
+
catch {
|
|
10039
|
+
settled = await withdraw([pid]);
|
|
10040
|
+
}
|
|
10041
|
+
return {
|
|
10042
|
+
status: 502,
|
|
10043
|
+
error: erased
|
|
10044
|
+
? `${why}; they were taken back out, so nothing changed${settled ? '' : `.${queued([pid])}`}`
|
|
10045
|
+
: `${why}; taking ${newId} back out was not confirmed, so both ${old.id} and ${newId} may remain${settled ? '' : `.${queued([pid])}`}`,
|
|
10046
|
+
};
|
|
10047
|
+
};
|
|
10048
|
+
if (landed.scope !== old.scope) {
|
|
10049
|
+
return undo(`the approved words landed at scope ${JSON.stringify(landed.scope)}, not ${JSON.stringify(old.scope)}`);
|
|
10050
|
+
}
|
|
10051
|
+
// The memory landed; its proposal must read approved. A write that landed before estate recorded the
|
|
10052
|
+
// approval leaves it pending: approve it again (the same memory), and undo the edit if that does not settle it.
|
|
10053
|
+
let pending;
|
|
10054
|
+
try {
|
|
10055
|
+
pending = (await pendingMemoryProposals()).some((q) => q.id === pid);
|
|
10056
|
+
if (pending) {
|
|
10057
|
+
await approve();
|
|
10058
|
+
pending = (await pendingMemoryProposals()).some((q) => q.id === pid);
|
|
10059
|
+
}
|
|
10060
|
+
}
|
|
10061
|
+
catch (err) {
|
|
10062
|
+
return undo(`the approval of the new words could not be confirmed (${message(err)})`);
|
|
10063
|
+
}
|
|
10064
|
+
if (pending)
|
|
10065
|
+
return undo('the approval of the new words stayed pending');
|
|
10066
|
+
return { id: newId };
|
|
10067
|
+
};
|
|
9728
10068
|
try {
|
|
9729
10069
|
// 1. The memory as it is: its tier, scope and facets ride onto the replacement.
|
|
9730
10070
|
let before;
|
|
@@ -9754,48 +10094,59 @@ runtime = {}) {
|
|
|
9754
10094
|
}
|
|
9755
10095
|
return upstream('checking that the store can erase one memory failed; nothing changed', err);
|
|
9756
10096
|
}
|
|
9757
|
-
// 3. The new words, as a new memory in the old one's place.
|
|
9758
|
-
|
|
9759
|
-
|
|
9760
|
-
|
|
9761
|
-
const kind = KIND_FOR_TIER[old.tier];
|
|
9762
|
-
if (kind !== undefined)
|
|
9763
|
-
captureArgs['kind'] = kind;
|
|
9764
|
-
}
|
|
9765
|
-
const beforeIds = new Set(before.map((m) => m.id));
|
|
10097
|
+
// 3. The new words, as a new memory in the old one's place. An approved learning (estate's
|
|
10098
|
+
// `proposal:` id, the only mark run-learnings recall admits: crew#1546) is replaced through
|
|
10099
|
+
// the approval queue, so the replacement carries the mark too; a capture would mint a bare id
|
|
10100
|
+
// and the edited learning would silently stop reaching briefs. Anything else is captured.
|
|
9766
10101
|
let newId = null;
|
|
9767
|
-
|
|
9768
|
-
|
|
9769
|
-
|
|
9770
|
-
|
|
9771
|
-
|
|
9772
|
-
newId = id;
|
|
9773
|
-
else
|
|
9774
|
-
captureErr = new EstateMcpError('memory.capture returned no memory_id');
|
|
10102
|
+
if (memoryId.startsWith(APPROVED_MEMORY_PREFIX)) {
|
|
10103
|
+
const placed = await reapproveMemory(old, content, new Set(before.map((m) => m.id)));
|
|
10104
|
+
if ('error' in placed)
|
|
10105
|
+
return reply.code(placed.status).send({ error: placed.error });
|
|
10106
|
+
newId = placed.id;
|
|
9775
10107
|
}
|
|
9776
|
-
|
|
9777
|
-
|
|
9778
|
-
|
|
9779
|
-
|
|
9780
|
-
|
|
9781
|
-
|
|
10108
|
+
else {
|
|
10109
|
+
const captureArgs = { content, scope: old.scope, facets: old.facets };
|
|
10110
|
+
if (old.tier !== '') {
|
|
10111
|
+
captureArgs['tier'] = old.tier;
|
|
10112
|
+
const kind = KIND_FOR_TIER[old.tier];
|
|
10113
|
+
if (kind !== undefined)
|
|
10114
|
+
captureArgs['kind'] = kind;
|
|
10115
|
+
}
|
|
10116
|
+
const beforeIds = new Set(before.map((m) => m.id));
|
|
10117
|
+
let captureErr = null;
|
|
9782
10118
|
try {
|
|
9783
|
-
|
|
10119
|
+
const captured = await estateTool('memory.capture', captureArgs);
|
|
10120
|
+
const id = typeof captured === 'object' && captured !== null ? captured['memory_id'] : undefined;
|
|
10121
|
+
if (typeof id === 'string' && id !== '')
|
|
10122
|
+
newId = id;
|
|
10123
|
+
else
|
|
10124
|
+
captureErr = new EstateMcpError('memory.capture returned no memory_id');
|
|
9784
10125
|
}
|
|
9785
10126
|
catch (err) {
|
|
9786
|
-
|
|
9787
|
-
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}`,
|
|
9788
|
-
});
|
|
10127
|
+
captureErr = err;
|
|
9789
10128
|
}
|
|
9790
|
-
|
|
9791
|
-
|
|
9792
|
-
|
|
9793
|
-
|
|
9794
|
-
|
|
9795
|
-
|
|
9796
|
-
|
|
10129
|
+
if (newId === null) {
|
|
10130
|
+
// The capture may still have written (a lost answer): look before saying nothing changed.
|
|
10131
|
+
let now;
|
|
10132
|
+
try {
|
|
10133
|
+
now = await listAll();
|
|
10134
|
+
}
|
|
10135
|
+
catch (err) {
|
|
10136
|
+
return reply.code(502).send({
|
|
10137
|
+
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}`,
|
|
10138
|
+
});
|
|
10139
|
+
}
|
|
10140
|
+
const copies = now.filter((m) => !beforeIds.has(m.id) && m.content.trim() === content && m.scope === old.scope);
|
|
10141
|
+
if (copies.length !== 1) {
|
|
10142
|
+
return reply.code(502).send({
|
|
10143
|
+
error: copies.length === 0
|
|
10144
|
+
? `writing the new words failed (${message(captureErr)}); nothing changed`
|
|
10145
|
+
: `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(', ')}`,
|
|
10146
|
+
});
|
|
10147
|
+
}
|
|
10148
|
+
newId = copies[0].id;
|
|
9797
10149
|
}
|
|
9798
|
-
newId = copies[0].id;
|
|
9799
10150
|
}
|
|
9800
10151
|
// 4. The old memory out.
|
|
9801
10152
|
let eraseErr = null;
|
|
@@ -10077,20 +10428,7 @@ runtime = {}) {
|
|
|
10077
10428
|
// per request, and one background `seat-image build` at a time.
|
|
10078
10429
|
const coreExe = () => process.env['WICKED_CORE_EXE'] || null;
|
|
10079
10430
|
const seatImageRebuilder = runtime.seatImageRebuilder ?? new SeatImageRebuilder(coreExe);
|
|
10080
|
-
const seatImageStatus = runtime.seatImageStatus ??
|
|
10081
|
-
(async () => {
|
|
10082
|
-
const exe = coreExe();
|
|
10083
|
-
if (exe === null)
|
|
10084
|
-
throw new Error('WICKED_CORE_EXE is not set');
|
|
10085
|
-
try {
|
|
10086
|
-
const out = await execCapped(exe, ['seat-image', 'status', '--json'], { timeout: PROBE_TIMEOUT_MS });
|
|
10087
|
-
return parseSeatImageStatus(out.stdout);
|
|
10088
|
-
}
|
|
10089
|
-
catch (err) {
|
|
10090
|
-
const e = err;
|
|
10091
|
-
throw new Error(loginDetail(typeof e.stderr === 'string' && e.stderr !== '' ? e.stderr : (e.message ?? 'failed')));
|
|
10092
|
-
}
|
|
10093
|
-
});
|
|
10431
|
+
const seatImageStatus = runtime.seatImageStatus ?? seatImageStatusVia(coreExe);
|
|
10094
10432
|
// The roster's seats (on the container floor every seat runs in an image); `null` when unreadable.
|
|
10095
10433
|
const rosterSeatsNow = () => {
|
|
10096
10434
|
try {
|
|
@@ -10261,6 +10599,11 @@ runtime = {}) {
|
|
|
10261
10599
|
rebuild: () => seatImageRebuilder.current(),
|
|
10262
10600
|
}),
|
|
10263
10601
|
clusterP.then((rows) => rows.cluster),
|
|
10602
|
+
// crew#1527: whether a pull request can be opened — the setup steps' answer, through the same bounded reader.
|
|
10603
|
+
(async () => {
|
|
10604
|
+
const started = Date.now();
|
|
10605
|
+
return deliveryRow(await readDeliveryReadiness(() => Promise.resolve(adapter.getSettings())), started, infraRow);
|
|
10606
|
+
})(),
|
|
10264
10607
|
]);
|
|
10265
10608
|
const [views, settings, openGates, diag, ping, rules, gatesByYou, infraProbed, reposRead] = await Promise.all([
|
|
10266
10609
|
viewsP, settingsP, gatesP, diagP, pingP, rulesP, gatesByYouP, infraP, reposP,
|
|
@@ -10399,6 +10742,7 @@ runtime = {}) {
|
|
|
10399
10742
|
infraProbed[8],
|
|
10400
10743
|
infraProbed[7],
|
|
10401
10744
|
reposRow(reposRead),
|
|
10745
|
+
infraProbed[9],
|
|
10402
10746
|
infraProbed[6],
|
|
10403
10747
|
loadRow(),
|
|
10404
10748
|
];
|