robisie 0.5.30 → 0.5.32

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/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # Historia zmian klienta / Client changelog
2
2
 
3
+ ## [0.5.32](https://github.com/chuppa12/robisie-app/compare/client-v0.5.31...client-v0.5.32) (2026-11-14)
4
+
5
+
6
+ ### Factory Cards
7
+
8
+ * praca workera task-mwgigrme-4ju20p (auto-commit) ([2897214](https://github.com/chuppa12/robisie-app/commit/289721468bce4be4bfd0db50e8e3c536587f772a))
9
+ * praca workera task-mwgk0605-3z6nbf (auto-commit) ([6982bb7](https://github.com/chuppa12/robisie-app/commit/6982bb770e9a2218773a0fe4dc5d4fa4f6f00131))
10
+
11
+ ## [0.5.31](https://github.com/chuppa12/robisie-app/compare/client-v0.5.30...client-v0.5.31) (2026-11-14)
12
+
13
+
14
+ ### Factory Cards
15
+
16
+ * praca workera task-mwgd2g3h-bcjd3v (auto-commit) ([cbf91cb](https://github.com/chuppa12/robisie-app/commit/cbf91cb2f8405a367e9e98a3d8aa3ac1fc95b42b))
17
+ * praca workera task-mwgf5pck-hcmznd (auto-commit) ([e73e58e](https://github.com/chuppa12/robisie-app/commit/e73e58ef33883164ba96afa2298fc282b6c57468))
18
+ * praca workera task-mwggrm9c-jj1by6 (auto-commit) ([4bdc73f](https://github.com/chuppa12/robisie-app/commit/4bdc73f7a2cfa31898c92b864d5690882722151c))
19
+
3
20
  ## [0.5.30](https://github.com/chuppa12/robisie-app/compare/client-v0.5.29...client-v0.5.30) (2026-11-14)
4
21
 
5
22
 
@@ -1,6 +1,6 @@
1
1
  /** Package identity and the server contract it speaks. */
2
2
  export declare const PACKAGE_NAME = "robisie";
3
- export declare const PACKAGE_VERSION = "0.5.30";
3
+ export declare const PACKAGE_VERSION = "0.5.32";
4
4
  /**
5
5
  * MAJOR of the agent-API contract this package understands.
6
6
  * PARITY: src/lib/mcp/contract-version.ts (AGENT_API_CONTRACT_VERSION) on the server.
package/dist/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /** Package identity and the server contract it speaks. */
2
2
  export const PACKAGE_NAME = "robisie";
3
- export const PACKAGE_VERSION = "0.5.30"; // x-release-please-version
3
+ export const PACKAGE_VERSION = "0.5.32"; // x-release-please-version
4
4
  /**
5
5
  * MAJOR of the agent-API contract this package understands.
6
6
  * PARITY: src/lib/mcp/contract-version.ts (AGENT_API_CONTRACT_VERSION) on the server.
@@ -1 +1 @@
1
- {"schema":1,"sha":"257a7b97ee972c55ba752a7664a04fa7d9db0adf","dirty":false}
1
+ {"schema":1,"sha":"9487748c00050d5e59279091185d1f79ae9ff37d","dirty":false}
@@ -1673,20 +1673,20 @@
1673
1673
  "staticOperations": {
1674
1674
  "beforePreflight": {
1675
1675
  "module": "maszynista/tick.ts",
1676
- "startLine": 9636,
1677
- "endLine": 9749,
1676
+ "startLine": 9781,
1677
+ "endLine": 9894,
1678
1678
  "text": "export async function main(): Promise<number> {\n const start = standaloneStartCheck({ filename: __filename, env: process.env });\n if (start.standalone && !start.ok) {\n console.error(start.message);\n process.exitCode = 78;\n return 78;\n }\n let installation: EngineContext;\n try { installation = createEngineContext(currentEngine(), {\n loadEnvironment: loadEnvFiles, preflight, baseRef: engineBaseRef, refreshBase: fetchMain,\n disk: defaultDiskPressureDependencies, workerContext: loadNorthStar,\n controlEnv: hostEnv, workerEnv: executionEnv, prepareWorktree: prepareHostWorktree, workerArtifacts: createWorkerTmpdir,\n notify: async (card, reason) => { decisionForReksio(card, reason, \"Rozstrzygnij na karcie\", \"\", \"\"); return { outcome: \"recorded\", ref: DECISIONS_REKSIO }; },\n hostOperations: hostOperationsPhase,\n activation: { confirmLoaded, finishHostActivation, readActivationState, recoverTickTimeout, runEnabledAuto },\n }, git, log); }\n catch (error) {\n if (!engineClient()) throw error;\n console.error(`HOLD kontekst klienta: ${clientTickFailure(error)}`);\n process.exitCode = 78;\n return 78;\n }\n const previousInstallation = tickInstallation;\n const hostErrorText = errorText;\n const client = engineClient();\n const result: { outcome: \"ok\" | \"retry\" | \"stop\"; reason: string; cleanup: boolean } = { outcome: \"ok\", reason: \"\", cleanup: false };\n const stopClient = (reason = clientTickFailure()): void => {\n if (client && result.outcome !== \"stop\") { result.outcome = \"stop\"; result.reason = reason; }\n };\n let code = 2;\n try { code = await q.withPlannerQueries(installation.planner, async () => {\n tickInstallation = installation;\n const seedGateSettings = installationSeedGateSettings();\n const errorText = client ? clientTickFailure : hostErrorText;\n const loadEnvFiles = installation.loadEnvironment;\n const preflight = () => {\n const actor = installation.preflight();\n return { uid: actor.kind === \"db\" ? actor.uid : API_ACTOR };\n };\n const { confirmLoaded, finishHostActivation, readActivationState, recoverTickTimeout, runEnabledAuto } = installation.activation;\n const smokeOnly = DRY && process.env.MASZYNISTA_SMOKE === \"1\";\n if (!DRY) {\n const acquire = (): boolean => tryCreateTickLock(LOCK);\n if (!acquire()) {\n const raw = readFileSync(LOCK, \"utf8\"), pid = Number(raw);\n if (!Number.isSafeInteger(pid) || pid <= 0) { console.log(\"tick lock bez poprawnego PID — HOLD\"); return 0; }\n try { process.kill(pid, 0); console.log(`tick już trwa (pid ${pid})`); return 0; }\n catch (error) { if ((error as NodeJS.ErrnoException).code !== \"ESRCH\") throw error; }\n if (readFileSync(LOCK, \"utf8\") === raw) unlinkSync(LOCK);\n if (!acquire()) { console.log(\"tick już trwa\"); return 0; }\n }\n }\n skippedCardEvents.clear();\n let s = parseState(null).state;\n // Internal smoke handoff: the child cannot outlive the parent's reserved budget.\n const smokeLimit = DRY ? Number(process.env.MASZYNISTA_SMOKE_TIMEOUT_MS) : NaN;\n let stateLoaded = false;\n let tickStarted: string | undefined;\n let outcome: \"ok\" | \"failed\" = \"ok\";\n let runtimeFailed = false;\n let observedLoaded = \"UNKNOWN\";\n let tickPhase = \"startup\";\n const deadlineAlarm = armTickDeadline(() => s, Number.isSafeInteger(smokeLimit) && smokeLimit > 0\n ? Math.min(TICK_LIMIT_MS, smokeLimit) : TICK_LIMIT_MS, () => ({ phase: tickPhase, observedLoaded }));\n let hostReady = false;\n let hostBoard: { uid: string; projectId: string } | undefined;\n let activationCards: CardLike[] = [];\n let activationCardsKnown = false;\n let blockedBefore = 0;\n const clientStopped = (): boolean => {\n if (client && (outcome === \"failed\" || (!DRY && s.blocked > blockedBefore))) stopClient();\n if (client && result.outcome === \"stop\") outcome = \"failed\";\n return client && result.outcome === \"stop\";\n };\n let hostPhaseStarted = false;\n const hostPhase = async (): Promise<boolean> => {\n if (smokeOnly || !hostReady || hostPhaseStarted) return false;\n hostPhaseStarted = true;\n tickPhase = \"host\";\n if (hostBoard) {\n const { uid: boardUid, projectId: boardProject } = hostBoard;\n try {\n await runEnabledAuto({ state: s, loadedSha: observedLoaded, repo: REPO, logPath: LOG, tick: s.tick, stateDir: hostStateDir(),\n now: new Date().toISOString(), activation: readActivationState(hostStateDir()), dryRun: DRY }, {\n listCards: async () => scanTasks(boardUid, boardProject, { full: true, statuses: [\"delivered\"],\n detailsKeys: ENABLED_SCAN_DETAILS_KEYS }),\n getTask: id => q.getTask(boardUid, id),\n appendDetail: async (id, patch) => { await appendBoundedDetail(boardUid, id, patch); },\n saveState: writeState,\n alarm: hostActivationAlarm,\n log,\n });\n } catch (error) { runtimeFailed = true; outcome = \"failed\"; log(`FAIL ENABLED auto: ${errorText(error)}`); }\n } else log(\"ENABLED auto: UNKNOWN — brak odczytu projektu; dowód karty czeka na dostęp do tablicy\");\n try {\n const result = await engineRunHostActivation({ repo: REPO, stateDir: hostStateDir(), cards: activationCards, cardsKnown: activationCardsKnown, tick: s.tick, dryRun: DRY }, {\n git, remainingTickMs, alarm: hostActivationAlarm, infrastructureChecks, infrastructurePullRequest, log: line => log(`host-activation: ${line}`),\n });\n log(`host-activation: code=${result.code} target=${result.target ?? \"UNKNOWN\"}${result.detail ? ` reason=${result.detail}` : \"\"}`);\n if (result.code === \"activate\" && result.target) {\n lastTick(s, \"activation\", `aktywacja ${result.target}; ogon odroczony`, outcome === \"ok\");\n return true;\n }\n } catch (error) { runtimeFailed = true; outcome = \"failed\"; log(`FAIL aktywacja: ${errorText(error)}`); }\n return false;\n };\n try {\n observedLoaded = loadedSha = readLoadedSha(REPO);\n s = readState((await engineFjConfig()).enabled);\n stateLoaded = true; blockedBefore = s.blocked;\n s.tick++; tickStarted = new Date().toISOString(); s.lastTickAt = tickStarted;\n log(`tick_started tick=${s.tick} at=${tickStarted} duration=UNKNOWN loaded=${loadedSha}`);\n loadEnvFiles();\n const { uid } = preflight();"
1679
1679
  },
1680
1680
  "finalization": {
1681
1681
  "module": "maszynista/tick.ts",
1682
- "startLine": 10038,
1683
- "endLine": 10090,
1682
+ "startLine": 10185,
1683
+ "endLine": 10237,
1684
1684
  "text": " } finally {\n // A persisted terminal FAIL is a card result; every unexpected exception above\n // remains a runtime failure, including DB errors inside card handling.\n if (!DRY && s.blocked > blockedBefore) {\n outcome = \"failed\";\n try { log(`FAIL: licznik blocked wzrósł ${blockedBefore} → ${s.blocked}; outcome=failed`); }\n catch (error) { console.error(`zapis licznika blocked: ${errorText(error)}`); }\n }\n clientStopped();\n // Early board failure still reaches the same host phase, at most once per tick.\n await hostPhase();\n tickPhase = \"finalizing\";\n try { if (!DRY) await finishHostActivation({ stateDir: hostStateDir(), outcome, tick: s.tick, runtimeFailed, observedLoaded }, { alarm: hostActivationAlarm, log }); }\n catch (error) { runtimeFailed = true; outcome = \"failed\"; log(`FAIL breaker aktywacji: ${errorText(error)}`); }\n clientStopped();\n try { if (stateLoaded) writeState(s); }\n catch (error) { runtimeFailed = true; outcome = \"failed\"; if (!client) throw error; stopClient(); result.cleanup = true; }\n finally {\n if (!DRY) {\n try { if (readFileSync(LOCK, \"utf8\") === String(process.pid)) unlinkSync(LOCK); }\n catch (error) { if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") { if (!client) throw error; stopClient(); result.cleanup = true; } }\n }\n const at = new Date().toISOString();\n const duration = tickStarted ? `${(Date.parse(at) - Date.parse(tickStarted)) / 1000}s` : \"UNKNOWN\";\n try {\n const { total, ops } = drainEgressCounters();\n const sorted = Object.entries(ops).sort(([, a], [, b]) => b.bytes - a.bytes);\n const summary = sorted.filter(([op]) => !op.includes(\":\")).slice(0, 12)\n .map(([op, counter]) => `${op}:${counter.calls}:${counter.bytes}`).join(\",\");\n const variants = sorted.filter(([op]) => op.includes(\":\")).slice(0, 6)\n .map(([op, counter]) => `${op}:${counter.calls}:${counter.bytes}`).join(\",\");\n log(`egress tick=${s.tick} total=${total} ops=${summary} variants=${variants}`);\n } catch { /* Optional metrics must never interrupt tick cleanup. */ }\n try { refreshTickReport(observedLoaded); log(`tick_finished tick=${s.tick} at=${at} outcome=${client && result.outcome === \"retry\" ? \"retry\" : outcome} duration=${duration} loaded=${loadedSha}`); }\n finally { clearTimeout(deadlineAlarm); tickDeadline = Number.POSITIVE_INFINITY; }\n }\n }\n }); } catch (error) {\n if (!client) throw error;\n stopClient(); result.cleanup = true;\n } finally {\n tickInstallation = previousInstallation;\n try { await installation.close(); }\n catch (error) {\n if (client) { stopClient(); result.cleanup = true; }\n else safeLog(`Zamknięcie instalacji nieudane: ${String(error)}`);\n }\n }\n if (client && result.outcome !== \"ok\") console.error(`Fabryka ${result.outcome === \"stop\" ? \"zatrzymana\" : \"retry\"}: ${result.reason}${result.cleanup ? \"; finalizacja niepotwierdzona — sprawdź stan i blokadę\" : \"\"}`);\n return client && result.outcome === \"stop\" ? 2 : code;\n}\n\nif (require.main === module && !([\"--opencode-runner\", \"--grok-runner\"].includes(process.argv[2] ?? \"\"))) {"
1685
1685
  },
1686
1686
  "refreshTickReport": {
1687
1687
  "module": "maszynista/tick.ts",
1688
- "startLine": 849,
1689
- "endLine": 860,
1688
+ "startLine": 876,
1689
+ "endLine": 887,
1690
1690
  "text": "export function refreshTickReport(observedLoaded = readLoadedSha(REPO)): void {\n loadedSha = observedLoaded;\n try { mainSha = git([\"rev-parse\", engineBranchRef()]); }\n catch (error) { mainSha = \"UNKNOWN\"; log(`Nie można odczytać main SHA: ${errorText(error)}`); }\n if (DRY) return;\n try {\n const content = readFileSync(LAST_TICK, \"utf8\");\n writeFileSync(LAST_TICK, `${content.replace(/^- (?:loaded|main):.*\\n?/gm, \"\")}- loaded: ${loadedSha}\\n- main: ${mainSha}\\n`);\n } catch (error) { if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error; }\n}\n\nfunction writeAtomic(file: string, content: string): void {"
1691
1691
  },
1692
1692
  "importTime": {
@@ -1706,6 +1706,6 @@
1706
1706
  "status": 0,
1707
1707
  "signal": null,
1708
1708
  "stdout": "v24.3.0\n",
1709
- "stderr": "(node:18118) ExperimentalWarning: SQLite is an experimental feature and might change at any time\n(Use `node --trace-warnings ...` to show where the warning was created)\n"
1709
+ "stderr": "(node:17972) ExperimentalWarning: SQLite is an experimental feature and might change at any time\n(Use `node --trace-warnings ...` to show where the warning was created)\n"
1710
1710
  }
1711
1711
  }
@@ -37628,7 +37628,7 @@ var init_constants = __esm({
37628
37628
  "packages/client/src/constants.ts"() {
37629
37629
  "use strict";
37630
37630
  PACKAGE_NAME = "robisie";
37631
- PACKAGE_VERSION = "0.5.30";
37631
+ PACKAGE_VERSION = "0.5.32";
37632
37632
  SUPPORTED_CONTRACT_MAJOR = 1;
37633
37633
  DEFAULT_ORIGIN = "https://robisie.app";
37634
37634
  MCP_SERVER_NAME = "robisie";
@@ -52703,6 +52703,8 @@ function runDryObserved(input) {
52703
52703
  "--skip-git-repo-check",
52704
52704
  "--ignore-user-config",
52705
52705
  "--ignore-rules",
52706
+ "-c",
52707
+ "features.apps=false",
52706
52708
  ...input.model ? ["--model", input.model] : [],
52707
52709
  ...input.effort === "high" ? ["-c", 'model_reasoning_effort="high"'] : [],
52708
52710
  "-C",
@@ -92706,7 +92708,7 @@ function runReview(input) {
92706
92708
  if (clientReviewer) {
92707
92709
  effort = clientReviewer.effort;
92708
92710
  if (bin === "claude") args.push("--effort", effort);
92709
- if (bin === "codex") args = ["-c", `review_model=${JSON.stringify(model)}`, "-c", `model_reasoning_effort=${JSON.stringify(effort)}`, "review", "-"];
92711
+ if (bin === "codex") args = ["-c", "features.apps=false", "-c", `review_model=${JSON.stringify(model)}`, "-c", `model_reasoning_effort=${JSON.stringify(effort)}`, "review", "-"];
92710
92712
  }
92711
92713
  if (policy && bin === "claude") {
92712
92714
  effort = "medium";
@@ -92717,7 +92719,7 @@ function runReview(input) {
92717
92719
  effort = solEffort;
92718
92720
  if (unknownEffort) fallbackReason = `${fallbackReason ? `${fallbackReason}; ` : ""}effort UNKNOWN: conservative high`;
92719
92721
  bin = "codex";
92720
- args = ["-c", `review_model="${model}"`, "-c", `model_reasoning_effort="${effort}"`, "review", materialPrompt];
92722
+ args = ["-c", "features.apps=false", "-c", `review_model="${model}"`, "-c", `model_reasoning_effort="${effort}"`, "review", materialPrompt];
92721
92723
  }
92722
92724
  if (bin === "claude") env = { ...env, ...HEADLESS_CLAUDE_ENV };
92723
92725
  if (bin === "opencode") {
@@ -315228,6 +315230,7 @@ __export2(tick_exports, {
315228
315230
  executeDeliveredTest: () => executeDeliveredTest,
315229
315231
  executeTesterJob: () => executeTesterJob,
315230
315232
  findEngineProject: () => findEngineProject,
315233
+ flushReviewGrantDiagnostics: () => flushReviewGrantDiagnostics,
315231
315234
  handleCiNoChecksAlarm: () => handleCiNoChecksAlarm,
315232
315235
  handleDiskPressure: () => handleDiskPressure,
315233
315236
  hostActivationAlarm: () => hostActivationAlarm,
@@ -315442,21 +315445,76 @@ function actionableBlockerHold(card, predecessors) {
315442
315445
  if (actionableBlockerRecovery(card, predecessors)) return null;
315443
315446
  return "ACTIONABLE_BLOCKER: seed_brief_sha256 bez zmian; wymagany nowy brief albo depends_on na nierozwi\u0105zan\u0105 kart\u0119-przeszkod\u0119";
315444
315447
  }
315445
- async function recoverBlockedWorkers(s, uid, projectId2, dry = DRY2) {
315448
+ async function recoverBlockedWorkers(s, uid, projectId2, dry = DRY2, pending) {
315446
315449
  if (dry) return;
315450
+ const diagnostics = pending ?? /* @__PURE__ */ new Map();
315451
+ let failure3;
315447
315452
  const rows = await scanTasks(uid, projectId2, { full: true, statuses: ["blocked"], detailsKeys: BLOCKED_WORKER_DETAILS_KEYS });
315448
315453
  for (const row of rows) {
315449
- if (!["ACTIONABLE_BLOCKER", "WORKER_FINISHED"].includes(String(asRecord3(row.details?.maszynista).outcome)) || s.actives.some((a) => a.taskId === row.id)) continue;
315450
- if (row.assignee !== null || landedSha(row) || row.details?.reksio_withheld === true) continue;
315451
- const card = await getTask2(uid, row.id);
315452
- if (!card || card.status !== "blocked" || card.assignee !== null || landedSha(card) || draftHeld(card.details ?? {})) continue;
315453
- const predecessors = await factoryPredecessors(uid, [card]);
315454
- if (!factoryDependenciesReady(card, predecessors)) continue;
315454
+ let diagnostic;
315455
+ const candidate = grantCandidates(row).length > 0;
315455
315456
  try {
315457
+ const hydrated = candidate ? await getTask2(uid, row.id) : null;
315458
+ if (candidate && !hydrated) continue;
315459
+ if (hydrated) {
315460
+ rememberGrantDiagnostics(diagnostics, hydrated);
315461
+ diagnostic = diagnostics.get(row.id);
315462
+ if (row.status !== hydrated.status || row.assignee !== hydrated.assignee || !(0, import_node_util13.isDeepStrictEqual)(row.dependsOn, hydrated.dependsOn) || Object.entries(row.details ?? {}).some(([key, value]) => !(0, import_node_util13.isDeepStrictEqual)(value, hydrated.details?.[key]))) rejectGrant(diagnostic, "snapshot_changed");
315463
+ }
315464
+ if (!["ACTIONABLE_BLOCKER", "WORKER_FINISHED"].includes(String(asRecord3(row.details?.maszynista).outcome))) {
315465
+ rejectGrant(diagnostic, "outcome");
315466
+ continue;
315467
+ }
315468
+ if (s.actives.some((a) => a.taskId === row.id)) {
315469
+ rejectGrant(diagnostic, "active");
315470
+ continue;
315471
+ }
315472
+ if (row.assignee !== null) {
315473
+ rejectGrant(diagnostic, "assignee");
315474
+ continue;
315475
+ }
315476
+ if (landedSha(row)) {
315477
+ rejectGrant(diagnostic, "land");
315478
+ continue;
315479
+ }
315480
+ if (row.details?.reksio_withheld === true) {
315481
+ rejectGrant(diagnostic, "veto");
315482
+ continue;
315483
+ }
315484
+ const card = hydrated ?? await getTask2(uid, row.id);
315485
+ if (!card) continue;
315486
+ if (card.status !== "blocked") {
315487
+ rejectGrant(diagnostic, "status");
315488
+ continue;
315489
+ }
315490
+ if (card.assignee !== null) {
315491
+ rejectGrant(diagnostic, "assignee");
315492
+ continue;
315493
+ }
315494
+ if (landedSha(card)) {
315495
+ rejectGrant(diagnostic, "land");
315496
+ continue;
315497
+ }
315498
+ if (draftHeld(card.details ?? {})) {
315499
+ rejectGrant(diagnostic, card.details?.reksio_withheld === true ? "veto" : "hold");
315500
+ continue;
315501
+ }
315502
+ const predecessors = await factoryPredecessors(uid, [card]);
315503
+ if (!factoryDependenciesReady(card, predecessors)) {
315504
+ rejectGrant(diagnostic, "dependencies");
315505
+ continue;
315506
+ }
315456
315507
  const worker = asRecord3(card.details?.maszynista);
315457
315508
  if (worker.outcome === "WORKER_FINISHED") {
315458
- if (worker.phase === "blocked" && worker.move === "blocked" && !await consumeR3Grant(s, uid, card))
315459
- await consumeR4Grant(s, uid, card);
315509
+ if (worker.phase !== "blocked") {
315510
+ rejectGrant(diagnostic, "phase");
315511
+ continue;
315512
+ }
315513
+ if (worker.move !== "blocked") {
315514
+ rejectGrant(diagnostic, "move");
315515
+ continue;
315516
+ }
315517
+ if (!await consumeR3Grant(s, uid, card, diagnostic)) await consumeR4Grant(s, uid, card, diagnostic);
315460
315518
  continue;
315461
315519
  }
315462
315520
  if (!actionableBlockerRecovery(card, predecessors)) continue;
@@ -315468,9 +315526,15 @@ async function recoverBlockedWorkers(s, uid, projectId2, dry = DRY2) {
315468
315526
  });
315469
315527
  log2(`karta ${card.id}: naprawiona powi\u0105zana przeszkoda \u2192 ready`);
315470
315528
  } catch (error48) {
315471
- if (!(error48 instanceof PlannerDomainError) || error48.plannerCode !== "TASK_UPDATE_CONFLICT") throw error48;
315529
+ if (candidate) {
315530
+ if (diagnostic) diagnostic.uncertain = true;
315531
+ if (!(error48 instanceof PlannerDomainError) || error48.plannerCode !== "TASK_UPDATE_CONFLICT") failure3 ??= error48;
315532
+ safeLog(`grant recovery ${row.id}: ${errorText5(error48)}`);
315533
+ } else if (!(error48 instanceof PlannerDomainError) || error48.plannerCode !== "TASK_UPDATE_CONFLICT") throw error48;
315472
315534
  }
315473
315535
  }
315536
+ if (!pending) await flushReviewGrantDiagnostics(uid, diagnostics);
315537
+ if (failure3) throw failure3;
315474
315538
  }
315475
315539
  function ringDraftChanges(cards, dry = DRY2) {
315476
315540
  if (dry) return;
@@ -318086,39 +318150,126 @@ async function deliver3(s, uid, card, sha5) {
318086
318150
  function readyTaskPatch() {
318087
318151
  return { status: "ready", assignee: null, detailsPatch: { readyAt: new Date(Date.now()).toISOString() } };
318088
318152
  }
318089
- function r3Grant(card) {
318153
+ function rejectGrant(diagnostic, reason, round) {
318154
+ if (diagnostic && round) (diagnostic.refusals ??= {})[round] = reason;
318155
+ else if (diagnostic && diagnostic.reason !== "snapshot_changed") diagnostic.reason = reason;
318156
+ return null;
318157
+ }
318158
+ function grantReceiptError(error48) {
318159
+ return error48 instanceof SyntaxError ? "receipt_json" : /SHA-256/.test(errorText5(error48)) ? "receipt_integrity" : "receipt_read";
318160
+ }
318161
+ function grantCandidates(card) {
318162
+ const rulings = card.details?.rozstrzygniecia_reksia;
318163
+ if (!Array.isArray(rulings)) return [];
318164
+ const tokens = /* @__PURE__ */ new Map();
318165
+ for (const value of rulings) {
318166
+ const ruling = asRecord3(value), token = ruling.znalezisko;
318167
+ if (ruling.by !== "control-room" || typeof token !== "string") continue;
318168
+ const match = /^LIMIT_RUND ([a-fA-F0-9]{8}-(?:[a-fA-F0-9]{4}-){3}[a-fA-F0-9]{12}) ([a-fA-F0-9]{40}) R([34])$/.exec(token);
318169
+ if (match && match[0] === token && match[1] === card.id) tokens.set(token, { sha: match[2], round: match[3] === "3" ? 3 : 4 });
318170
+ }
318171
+ return [...tokens].map(([token, identity]) => ({ token, ...identity, rulings: rulings.map(asRecord3).filter((ruling) => ruling.znalezisko === token) }));
318172
+ }
318173
+ function grantConsumed(card, candidate) {
318174
+ const review = asRecord3(card.details?.review), used = asRecord3(candidate.round === 3 ? review.extraRoundGrant : review.extraRound4Grant);
318175
+ if (typeof used.rulingSha256 === "string") return candidate.rulings.every((ruling) => rulingSha(ruling) === used.rulingSha256);
318176
+ return used.token === candidate.token || used.sha === candidate.sha && (used.fromRound === candidate.round - 1 || Number(review.round) >= candidate.round);
318177
+ }
318178
+ function rememberGrantDiagnostics(pending, card, reason) {
318179
+ if (!grantCandidates(card).length) return;
318180
+ if (!pending.has(card.id)) pending.set(card.id, { card: structuredClone(card), reason });
318181
+ }
318182
+ function grantSnapshotMatch(fresh, snapshot2) {
318183
+ return fresh.status === snapshot2.status && fresh.assignee === snapshot2.assignee && (0, import_node_util13.isDeepStrictEqual)(fresh.dependsOn, snapshot2.dependsOn) && recoveryDetailsMatch(fresh, snapshot2) && ["review", "landed", "hold", "unblock", "scope_blocked_at", "seed_brief", "seed_brief_sha256"].every((key) => (0, import_node_util13.isDeepStrictEqual)(fresh.details?.[key], snapshot2.details?.[key]));
318184
+ }
318185
+ async function flushReviewGrantDiagnostics(uid, pending) {
318186
+ if (DRY2) return;
318187
+ for (const [id2, diagnostic] of pending) {
318188
+ try {
318189
+ const fresh = await getTask2(uid, id2);
318190
+ if (!fresh) continue;
318191
+ for (const candidate of grantCandidates(fresh)) {
318192
+ if (grantConsumed(fresh, candidate)) continue;
318193
+ const changed = !grantSnapshotMatch(fresh, diagnostic.card);
318194
+ if (diagnostic.uncertain && !changed) continue;
318195
+ const current = { card: fresh };
318196
+ if (changed) current.reason = "snapshot_changed";
318197
+ else if (candidate.rulings.length > 1) current.reason = "ambiguous_rulings";
318198
+ else if (asRecord3(fresh.details?.review).sha !== candidate.sha) current.reason = "sha_mismatch";
318199
+ else if (diagnostic.reason) current.reason = diagnostic.reason;
318200
+ else if (diagnostic.refusals?.[candidate.round]) current.reason = diagnostic.refusals[candidate.round];
318201
+ else if (candidate.round === 3 ? r3Grant(fresh, current) : r4Grant(fresh, current)) {
318202
+ if (landedSha(fresh)) current.reason = "land";
318203
+ else if (draftHeld(fresh.details ?? {})) current.reason = fresh.details?.reksio_withheld === true ? "veto" : "hold";
318204
+ else continue;
318205
+ }
318206
+ current.reason ??= current.refusals?.[candidate.round];
318207
+ if (!current.reason) continue;
318208
+ const canonical4 = (value) => JSON.stringify(value, (_key, item) => item && typeof item === "object" && !Array.isArray(item) ? Object.fromEntries(Object.entries(item).sort(([a], [b]) => a.localeCompare(b))) : item);
318209
+ const content = candidate.rulings.map(canonical4).sort();
318210
+ const reason = current.reason;
318211
+ const message3 = `grant-odrzucony karta=${id2} R${candidate.round} reason=${reason} ruling=[${content.join(",")}]${reason === "time" ? ` ruling.at=${String(candidate.rulings[0].at)} review.at=${String(asRecord3(fresh.details?.review).at)}` : ""}`;
318212
+ const fingerprint = (0, import_node_crypto32.createHash)("sha256").update(JSON.stringify([id2, candidate.round, content, reason])).digest("hex");
318213
+ const marker = import_node_path52.default.join(DIR, "review-jobs", `grant-rejected-${fingerprint}.log-state`);
318214
+ if ((0, import_node_fs47.existsSync)(marker)) continue;
318215
+ (0, import_node_fs47.mkdirSync)(import_node_path52.default.dirname(marker), { recursive: true });
318216
+ (0, import_node_fs47.writeFileSync)(marker, fingerprint);
318217
+ log2(message3);
318218
+ try {
318219
+ const result = await wakeRole(message3, "control-room", `grant-rejected:${fingerprint}`);
318220
+ if (result.rc !== 0) safeLog(`grant diagnostyka ${id2}: wake CR nieudany ${result.stderr.slice(0, 200)}`);
318221
+ } catch (error48) {
318222
+ safeLog(`grant diagnostyka ${id2}: wake CR nieudany ${errorText5(error48)}`);
318223
+ }
318224
+ }
318225
+ } catch (error48) {
318226
+ safeLog(`grant diagnostyka ${id2}: ${errorText5(error48)}`);
318227
+ }
318228
+ }
318229
+ pending.clear();
318230
+ }
318231
+ function r3Grant(card, diagnostic) {
318090
318232
  const review = asRecord3(card.details?.review), sha5 = review.sha;
318091
- if (!/^[a-f0-9]{8}-(?:[a-f0-9]{4}-){3}[a-f0-9]{12}$/i.test(card.id) || card.details?.card_owner !== "control-room" || card.details?.reksio_withheld === true || review.verdict !== "FAIL" || review.round !== 2 || review.extraRoundGrant != null || typeof sha5 !== "string" || !/^[a-f0-9]{40}$/.test(sha5)) return null;
318233
+ if (!/^[a-f0-9]{8}-(?:[a-f0-9]{4}-){3}[a-f0-9]{12}$/i.test(card.id)) return rejectGrant(diagnostic, "card_id", 3);
318234
+ if (card.details?.card_owner !== "control-room") return rejectGrant(diagnostic, "card_owner", 3);
318235
+ if (card.details?.reksio_withheld === true) return rejectGrant(diagnostic, "veto", 3);
318236
+ if (review.verdict !== "FAIL") return rejectGrant(diagnostic, "review_verdict", 3);
318237
+ if (review.round !== 2) return rejectGrant(diagnostic, "review_round", 3);
318238
+ if (review.extraRoundGrant != null) return rejectGrant(diagnostic, "r3_used", 3);
318239
+ if (typeof sha5 !== "string" || !/^[a-f0-9]{40}$/.test(sha5)) return rejectGrant(diagnostic, "sha_mismatch", 3);
318092
318240
  const token = `LIMIT_RUND ${card.id} ${sha5} R3`;
318093
318241
  const rulings = card.details?.rozstrzygniecia_reksia;
318094
318242
  const matching = Array.isArray(rulings) ? rulings.map(asRecord3).filter((ruling) => ruling.znalezisko === token) : [];
318095
- if (matching.length > 1) return null;
318243
+ if (matching.length > 1) return rejectGrant(diagnostic, "ambiguous_rulings", 3);
318096
318244
  const grant = matching[0] ?? asRecord3(asRecord3(card.details?.unblock).verdict), at3 = grant.at;
318097
- if (typeof at3 !== "string" || !/^\d{4}-\d\d-\d\dT.*Z$/.test(at3) || !Number.isFinite(Date.parse(at3)) || !Number.isFinite(Date.parse(String(review.at))) || Date.parse(at3) < Date.parse(String(review.at)) || Date.parse(at3) > Date.now()) return null;
318245
+ if (typeof at3 !== "string" || !/^\d{4}-\d\d-\d\dT.*Z$/.test(at3) || !Number.isFinite(Date.parse(at3)) || !Number.isFinite(Date.parse(String(review.at))) || Date.parse(at3) < Date.parse(String(review.at)) || Date.parse(at3) > Date.now()) return rejectGrant(diagnostic, "time", 3);
318098
318246
  if (matching.length === 1) {
318099
- if (grant.werdykt !== "UCHYLONE" || grant.by !== "control-room" || typeof grant.powod !== "string" || !grant.powod.trim()) return null;
318247
+ if (grant.werdykt !== "UCHYLONE" || grant.by !== "control-room" || typeof grant.powod !== "string" || !grant.powod.trim()) return rejectGrant(diagnostic, "ruling", 3);
318100
318248
  } else {
318101
318249
  const worker = asRecord3(card.details?.maszynista), blockedAt = card.details?.scope_blocked_at;
318102
- if (!hasDutyNote(card.details) || card.status !== "blocked" || worker.outcome !== "WORKER_FINISHED" || worker.phase !== "blocked" || worker.move !== "blocked" || typeof blockedAt !== "string" || !Number.isFinite(Date.parse(blockedAt)) || Date.parse(at3) <= Date.parse(blockedAt) || Date.parse(at3) <= Date.parse(String(review.at))) return null;
318250
+ if (!hasDutyNote(card.details) || card.status !== "blocked" || worker.outcome !== "WORKER_FINISHED" || worker.phase !== "blocked" || worker.move !== "blocked" || typeof blockedAt !== "string" || !Number.isFinite(Date.parse(blockedAt)) || Date.parse(at3) <= Date.parse(blockedAt) || Date.parse(at3) <= Date.parse(String(review.at))) return rejectGrant(diagnostic, "legacy_note", 3);
318103
318251
  }
318104
318252
  try {
318105
318253
  const full = asRecord3(JSON.parse((0, import_node_fs47.readFileSync)(checkedReceipt(review.receipt).path, "utf8")));
318106
318254
  const ciResult = asRecord3(asRecord3(card.details?.maszynista).ciResult);
318107
- if (full.sha !== sha5 || full.round !== 2 || !(full.verdict === "FAIL" || full.verdict === "PASS" && ciResult.sha === sha5 && Array.isArray(ciResult.runs) && ciResult.runs.some((value) => {
318255
+ if (full.sha !== sha5) return rejectGrant(diagnostic, "receipt_sha", 3);
318256
+ if (full.round !== 2) return rejectGrant(diagnostic, "receipt_round", 3);
318257
+ if (!(full.verdict === "FAIL" || full.verdict === "PASS" && ciResult.sha === sha5 && Array.isArray(ciResult.runs) && ciResult.runs.some((value) => {
318108
318258
  const { name: name3, status: status2, conclusion } = asRecord3(value);
318109
318259
  return status2 === "completed" && conclusion !== "success" && typeof name3 === "string" && REQUIRED_CHECKS2.some((required3) => name3.startsWith(required3));
318110
- }) || full.verdict === "PASS" && typeof review.notes === "string" && /^Konflikt rebase:/.test(review.notes)) || full.jobKey !== review.jobKey) return null;
318260
+ }) || full.verdict === "PASS" && typeof review.notes === "string" && /^Konflikt rebase:/.test(review.notes))) return rejectGrant(diagnostic, "receipt_verdict", 3);
318261
+ if (full.jobKey !== review.jobKey) return rejectGrant(diagnostic, "receipt_job", 3);
318111
318262
  } catch (error48) {
318112
- log2(`R4 ${card.id}: brak dowodu zako\u0144czonej R3: ${errorText5(error48)}`);
318113
- return null;
318263
+ if (!diagnostic && !grantCandidates(card).length) log2(`R4 ${card.id}: brak dowodu zako\u0144czonej R3: ${errorText5(error48)}`);
318264
+ return rejectGrant(diagnostic, grantReceiptError(error48), 3);
318114
318265
  }
318115
318266
  return { token, at: at3, sha: sha5, fromRound: 2, rulingSha256: (0, import_node_crypto32.createHash)("sha256").update(JSON.stringify(grant)).digest("hex") };
318116
318267
  }
318117
- async function consumeR3Grant(s, uid, card) {
318118
- const grant = r3Grant(card);
318268
+ async function consumeR3Grant(s, uid, card, diagnostic) {
318269
+ const grant = r3Grant(card, diagnostic);
318119
318270
  if (!grant || decideReviewMove("FAIL", 2, 0, true) !== "repair") return false;
318120
318271
  const fresh = await getTask2(uid, card.id);
318121
- if (!fresh || fresh.status !== card.status || fresh.assignee !== card.assignee || !(0, import_node_util13.isDeepStrictEqual)(fresh.dependsOn, card.dependsOn) || landedSha(fresh) || draftHeld(fresh.details ?? {}) || !r3Grant(fresh) || ["maszynista", "review", "rozstrzygniecia_reksia", "card_owner", "reksio_withheld", "unblock", "scope_blocked_at"].some((key) => !(0, import_node_util13.isDeepStrictEqual)(fresh.details?.[key], card.details?.[key]))) return false;
318272
+ if (!fresh || fresh.status !== card.status || fresh.assignee !== card.assignee || !(0, import_node_util13.isDeepStrictEqual)(fresh.dependsOn, card.dependsOn) || landedSha(fresh) || draftHeld(fresh.details ?? {}) || !r3Grant(fresh, diagnostic) || ["maszynista", "review", "rozstrzygniecia_reksia", "card_owner", "reksio_withheld", "unblock", "scope_blocked_at"].some((key) => !(0, import_node_util13.isDeepStrictEqual)(fresh.details?.[key], card.details?.[key]))) return false;
318122
318273
  const review = { ...asRecord3(fresh.details?.review), round: 3, extraRoundGrant: { ...grant, briefSha256: contractSha(fresh) } };
318123
318274
  const maszynista = { ...asRecord3(fresh.details?.maszynista), phase: "repair", move: "repair" };
318124
318275
  await updateTask2(uid, card.id, {
@@ -318143,50 +318294,59 @@ function contractSha(card) {
318143
318294
  if (typeof declared === "string" && /^[a-f0-9]{64}$/i.test(declared) && declared.toLowerCase() !== computed.toLowerCase()) return null;
318144
318295
  return computed.toLowerCase();
318145
318296
  }
318146
- function r4Grant(card) {
318297
+ function r4Grant(card, diagnostic) {
318147
318298
  const review = asRecord3(card.details?.review), sha5 = review.sha, r3 = review.extraRoundGrant;
318148
- if (!/^[a-f0-9]{8}-(?:[a-f0-9]{4}-){3}[a-f0-9]{12}$/i.test(card.id) || card.details?.card_owner !== "control-room" || card.details?.reksio_withheld === true || review.verdict !== "FAIL" || review.round !== 3 || r3 == null || typeof sha5 !== "string" || !/^[a-f0-9]{40}$/.test(sha5)) return null;
318299
+ if (!/^[a-f0-9]{8}-(?:[a-f0-9]{4}-){3}[a-f0-9]{12}$/i.test(card.id)) return rejectGrant(diagnostic, "card_id", 4);
318300
+ if (card.details?.card_owner !== "control-room") return rejectGrant(diagnostic, "card_owner", 4);
318301
+ if (card.details?.reksio_withheld === true) return rejectGrant(diagnostic, "veto", 4);
318302
+ if (review.verdict !== "FAIL") return rejectGrant(diagnostic, "review_verdict", 4);
318303
+ if (review.round !== 3) return rejectGrant(diagnostic, "review_round", 4);
318304
+ if (r3 == null) return rejectGrant(diagnostic, "r3_missing", 4);
318305
+ if (typeof sha5 !== "string" || !/^[a-f0-9]{40}$/.test(sha5)) return rejectGrant(diagnostic, "sha_mismatch", 4);
318149
318306
  const current = contractSha(card);
318150
- if (!current) return null;
318307
+ if (!current) return rejectGrant(diagnostic, "contract", 4);
318151
318308
  const token = `LIMIT_RUND ${card.id} ${sha5} R4`;
318152
318309
  const rulings = card.details?.rozstrzygniecia_reksia;
318153
318310
  const matching = Array.isArray(rulings) ? rulings.map(asRecord3).filter((ruling2) => ruling2.znalezisko === token) : [];
318154
- if (matching.length !== 1) return null;
318311
+ if (matching.length !== 1) return rejectGrant(diagnostic, "ambiguous_rulings", 4);
318155
318312
  const ruling = matching[0], at3 = ruling.at, declared = ruling.nowy_brief_sha256;
318156
- if (ruling.werdykt !== "UCHYLONE" || ruling.by !== "control-room" || typeof ruling.powod !== "string" || !ruling.powod.trim() || typeof at3 !== "string" || !/^\d{4}-\d\d-\d\dT.*Z$/.test(at3) || !Number.isFinite(Date.parse(at3)) || !Number.isFinite(Date.parse(String(review.at))) || Date.parse(at3) < Date.parse(String(review.at)) || Date.parse(at3) > Date.now()) return null;
318313
+ if (ruling.werdykt !== "UCHYLONE" || ruling.by !== "control-room" || typeof ruling.powod !== "string" || !ruling.powod.trim()) return rejectGrant(diagnostic, "ruling", 4);
318314
+ if (typeof at3 !== "string" || !/^\d{4}-\d\d-\d\dT.*Z$/.test(at3) || !Number.isFinite(Date.parse(at3)) || !Number.isFinite(Date.parse(String(review.at))) || Date.parse(at3) < Date.parse(String(review.at)) || Date.parse(at3) > Date.now()) return rejectGrant(diagnostic, "time", 4);
318157
318315
  const used = asRecord3(review.extraRound4Grant);
318158
- if (used.sha === sha5 || typeof used.briefSha256 === "string" && used.briefSha256.toLowerCase() === current) return null;
318316
+ if (used.sha === sha5 || typeof used.briefSha256 === "string" && used.briefSha256.toLowerCase() === current) return rejectGrant(diagnostic, "brief_used", 4);
318159
318317
  try {
318160
318318
  const full = asRecord3(JSON.parse((0, import_node_fs47.readFileSync)(checkedReceipt(review.receipt).path, "utf8")));
318161
- if (full.sha !== sha5 || full.round !== 3 || full.jobKey !== review.jobKey) return null;
318319
+ if (full.sha !== sha5) return rejectGrant(diagnostic, "receipt_sha", 4);
318320
+ if (full.round !== 3) return rejectGrant(diagnostic, "receipt_round", 4);
318321
+ if (full.jobKey !== review.jobKey) return rejectGrant(diagnostic, "receipt_job", 4);
318162
318322
  if (full.verdict === "FAIL") {
318163
- if (typeof declared !== "string" || !/^[a-f0-9]{64}$/i.test(declared) || declared.toLowerCase() !== current) return null;
318323
+ if (typeof declared !== "string" || !/^[a-f0-9]{64}$/i.test(declared) || declared.toLowerCase() !== current) return rejectGrant(diagnostic, "brief_mismatch", 4);
318164
318324
  const previous = asRecord3(r3).briefSha256;
318165
318325
  if (typeof previous === "string") {
318166
- if (previous.toLowerCase() === current) return null;
318326
+ if (previous.toLowerCase() === current) return rejectGrant(diagnostic, "brief_used", 4);
318167
318327
  } else {
318168
318328
  const r3Ruling = [...Array.isArray(rulings) ? rulings : [], asRecord3(card.details?.unblock).verdict].find((candidate) => candidate != null && rulingSha(candidate) === asRecord3(r3).rulingSha256);
318169
318329
  const r3Brief = asRecord3(r3Ruling).nowy_brief_sha256;
318170
- if (typeof r3Brief === "string" && r3Brief.toLowerCase() === current) return null;
318330
+ if (typeof r3Brief === "string" && r3Brief.toLowerCase() === current) return rejectGrant(diagnostic, "brief_used", 4);
318171
318331
  }
318172
318332
  } else if (full.verdict === "PASS") {
318173
318333
  const ciResult = asRecord3(asRecord3(card.details?.maszynista).ciResult), previousSha = asRecord3(r3).sha;
318174
318334
  if (typeof previousSha !== "string" || !/^[a-f0-9]{40}$/.test(previousSha) || previousSha === sha5 || ciResult.sha !== sha5 || !Array.isArray(ciResult.runs) || !ciResult.runs.some((value) => {
318175
318335
  const { name: name3, status: status2, conclusion } = asRecord3(value);
318176
318336
  return status2 === "completed" && conclusion !== "success" && typeof name3 === "string" && REQUIRED_CHECKS2.some((required3) => name3.startsWith(required3));
318177
- })) return null;
318178
- } else return null;
318337
+ })) return rejectGrant(diagnostic, "ci", 4);
318338
+ } else return rejectGrant(diagnostic, "receipt_verdict", 4);
318179
318339
  } catch (error48) {
318180
- log2(`runda 3\u21924 ${card.id}: brak dowodu zako\u0144czonej rundy 3: ${errorText5(error48)}`);
318181
- return null;
318340
+ if (!diagnostic && !grantCandidates(card).length) log2(`runda 3\u21924 ${card.id}: brak dowodu zako\u0144czonej rundy 3: ${errorText5(error48)}`);
318341
+ return rejectGrant(diagnostic, grantReceiptError(error48), 4);
318182
318342
  }
318183
318343
  return { token, at: at3, sha: sha5, fromRound: 3, briefSha256: current, rulingSha256: rulingSha(ruling) };
318184
318344
  }
318185
- async function consumeR4Grant(s, uid, card) {
318186
- const grant = r4Grant(card);
318345
+ async function consumeR4Grant(s, uid, card, diagnostic) {
318346
+ const grant = r4Grant(card, diagnostic);
318187
318347
  if (!grant) return false;
318188
318348
  const fresh = await getTask2(uid, card.id);
318189
- if (!fresh || fresh.status !== card.status || fresh.assignee !== card.assignee || !(0, import_node_util13.isDeepStrictEqual)(fresh.dependsOn, card.dependsOn) || landedSha(fresh) || draftHeld(fresh.details ?? {}) || !r4Grant(fresh) || ["maszynista", "review", "rozstrzygniecia_reksia", "card_owner", "reksio_withheld", "unblock", "scope_blocked_at", "seed_brief", "seed_brief_sha256"].some((key) => !(0, import_node_util13.isDeepStrictEqual)(fresh.details?.[key], card.details?.[key]))) return false;
318349
+ if (!fresh || fresh.status !== card.status || fresh.assignee !== card.assignee || !(0, import_node_util13.isDeepStrictEqual)(fresh.dependsOn, card.dependsOn) || landedSha(fresh) || draftHeld(fresh.details ?? {}) || !r4Grant(fresh, diagnostic) || ["maszynista", "review", "rozstrzygniecia_reksia", "card_owner", "reksio_withheld", "unblock", "scope_blocked_at", "seed_brief", "seed_brief_sha256"].some((key) => !(0, import_node_util13.isDeepStrictEqual)(fresh.details?.[key], card.details?.[key]))) return false;
318190
318350
  const review = { ...asRecord3(fresh.details?.review), round: 4, extraRound4Grant: grant };
318191
318351
  const maszynista = { ...asRecord3(fresh.details?.maszynista), phase: "repair", move: "repair" };
318192
318352
  await updateTask2(uid, card.id, {
@@ -318205,19 +318365,41 @@ async function consumeR4Grant(s, uid, card) {
318205
318365
  lastTick(s, "repair", `CR: jednorazowa runda 3\u21924 dla ${grant.sha}`, true, card.id);
318206
318366
  return true;
318207
318367
  }
318208
- async function recoverReviewRoundGrants(s, uid, cards) {
318368
+ async function recoverReviewRoundGrants(s, uid, cards, pending) {
318209
318369
  if (DRY2) return;
318370
+ const diagnostics = pending ?? /* @__PURE__ */ new Map();
318371
+ let failure3;
318210
318372
  for (const snapshot2 of cards) {
318211
- const details2 = snapshot2.details ?? {};
318212
- const rulings = details2.rozstrzygniecia_reksia;
318213
- const review = asRecord3(details2.review);
318214
- const tokens = [`LIMIT_RUND ${snapshot2.id} ${review.sha} R3`, `LIMIT_RUND ${snapshot2.id} ${review.sha} R4`];
318215
- if (snapshot2.status !== "blocked" || review.verdict !== "FAIL" || typeof review.sha !== "string" || details2.card_owner !== "control-room" || !Array.isArray(rulings) || !rulings.some((ruling) => tokens.includes(String(asRecord3(ruling).znalezisko)))) continue;
318216
- const fresh = await getTask2(uid, snapshot2.id);
318217
- if (fresh?.status !== "blocked" || !recoveryDetailsMatch(fresh, snapshot2)) continue;
318218
- if (r3Grant(fresh)) await consumeR3Grant(s, uid, fresh);
318219
- else if (r4Grant(fresh)) await consumeR4Grant(s, uid, fresh);
318373
+ if (!grantCandidates(snapshot2).length) continue;
318374
+ try {
318375
+ const fresh = await getTask2(uid, snapshot2.id);
318376
+ if (!fresh) continue;
318377
+ rememberGrantDiagnostics(diagnostics, fresh);
318378
+ const diagnostic = diagnostics.get(fresh.id);
318379
+ const details2 = snapshot2.details ?? {};
318380
+ const review = asRecord3(details2.review);
318381
+ const tokens = [`LIMIT_RUND ${snapshot2.id} ${review.sha} R3`, `LIMIT_RUND ${snapshot2.id} ${review.sha} R4`];
318382
+ const rulings = details2.rozstrzygniecia_reksia;
318383
+ if (!recoveryDetailsMatch(fresh, snapshot2) || fresh.status !== snapshot2.status) {
318384
+ rejectGrant(diagnostic, "snapshot_changed");
318385
+ continue;
318386
+ }
318387
+ if (snapshot2.status !== "blocked") {
318388
+ rejectGrant(diagnostic, "status");
318389
+ continue;
318390
+ }
318391
+ if (review.verdict !== "FAIL" || typeof review.sha !== "string" || details2.card_owner !== "control-room" || !Array.isArray(rulings) || !rulings.some((ruling) => tokens.includes(String(asRecord3(ruling).znalezisko)))) continue;
318392
+ if (r3Grant(fresh, diagnostic)) await consumeR3Grant(s, uid, fresh, diagnostic);
318393
+ else if (r4Grant(fresh, diagnostic)) await consumeR4Grant(s, uid, fresh, diagnostic);
318394
+ } catch (error48) {
318395
+ const diagnostic = diagnostics.get(snapshot2.id);
318396
+ if (diagnostic) diagnostic.uncertain = true;
318397
+ failure3 ??= error48;
318398
+ safeLog(`grant recovery ${snapshot2.id}: ${errorText5(error48)}`);
318399
+ }
318220
318400
  }
318401
+ if (!pending) await flushReviewGrantDiagnostics(uid, diagnostics);
318402
+ if (failure3) throw failure3;
318221
318403
  }
318222
318404
  async function applyReview(s, uid, card, verdict, notes) {
318223
318405
  const previous = asRecord3(card.details?.review);
@@ -325477,8 +325659,9 @@ async function main2() {
325477
325659
  outcome = "failed";
325478
325660
  log2(`FAIL powr\xF3t pakowania: ${errorText6(error48)}`);
325479
325661
  }
325662
+ const grantDiagnostics = /* @__PURE__ */ new Map();
325480
325663
  try {
325481
- await recoverReviewRoundGrants(s, uid, activationCards);
325664
+ await recoverReviewRoundGrants(s, uid, activationCards, grantDiagnostics);
325482
325665
  } catch (error48) {
325483
325666
  runtimeFailed = true;
325484
325667
  outcome = "failed";
@@ -325550,12 +325733,13 @@ async function main2() {
325550
325733
  };
325551
325734
  await leadPhase();
325552
325735
  try {
325553
- await recoverBlockedWorkers(s, uid, projectId2);
325736
+ await recoverBlockedWorkers(s, uid, projectId2, DRY2, grantDiagnostics);
325554
325737
  } catch (error48) {
325555
325738
  runtimeFailed = true;
325556
325739
  outcome = "failed";
325557
325740
  log2(`FAIL powr\xF3t po blokerze: ${errorText6(error48)}`);
325558
325741
  }
325742
+ await flushReviewGrantDiagnostics(uid, grantDiagnostics);
325559
325743
  await leadPhase();
325560
325744
  let dispatchableReadyCount = "UNKNOWN";
325561
325745
  let dispatchError;
@@ -325946,7 +326130,7 @@ var init_tick = __esm({
325946
326130
  REVIEW_SCAN_FIELDS = [...REVIEW_RECOVERY_FIELDS];
325947
326131
  DECISION_QUEUE_SCAN_FIELDS = ["id", "cardId", "reason", "openedAt", "wakes", "attempt", "escalatedAt", "lastMachineWriteAt", "closedAt", "kind", "event_id", "rodzaj", "card_id", "event_type", "occurrence_id", "recipient", "pointer", "readiness", "proof", "lead_class", "consumed"];
325948
326132
  DECISION_REFRESH_DETAILS_KEYS = [...DECISION_DETAILS_KEYS];
325949
- BLOCKED_WORKER_DETAILS_KEYS = ["maszynista", "landed", "reksio_withheld"];
326133
+ BLOCKED_WORKER_DETAILS_KEYS = ["maszynista", "landed", "reksio_withheld", "rozstrzygniecia_reksia"];
325950
326134
  ENABLED_SCAN_DETAILS_KEYS = ["card_class", "landed", "enabled_check", "enabled_evidence", "enabled_auto"];
325951
326135
  RESERVATION_DETAILS_KEYS = [...SCOPE_RESERVATION_DETAILS_KEYS, "origin"];
325952
326136
  RESERVATION_SCAN_DETAILS_KEYS = [...RESERVATION_DETAILS_KEYS, "test", "landed", "retest"];
@@ -326139,6 +326323,7 @@ init_tick();
326139
326323
  executeDeliveredTest,
326140
326324
  executeTesterJob,
326141
326325
  findEngineProject,
326326
+ flushReviewGrantDiagnostics,
326142
326327
  handleCiNoChecksAlarm,
326143
326328
  handleDiskPressure,
326144
326329
  hostActivationAlarm,
@@ -61,7 +61,7 @@ export function runK3CodexRole(bundle, options, spawn = spawnSync) {
61
61
  env[key] = value ? `${value},127.0.0.1,localhost` : "127.0.0.1,localhost";
62
62
  }
63
63
  }
64
- const argv = ["exec", "--json", "--ephemeral", "--skip-git-repo-check", "--ignore-user-config", "--ignore-rules",
64
+ const argv = ["exec", "--json", "--ephemeral", "--skip-git-repo-check", "--ignore-user-config", "--ignore-rules", "-c", "features.apps=false",
65
65
  "--model", bundle.execution.model, "-c", `model_reasoning_effort=${JSON.stringify(bundle.execution.effort)}`,
66
66
  "-C", options.cwd,
67
67
  "-s", options.sandbox,
package/dist/roles.d.ts CHANGED
@@ -17,7 +17,7 @@ export interface Role {
17
17
  export declare function rolesDir(): string;
18
18
  export declare function parseRole(file: Role["file"], text: string): Role;
19
19
  export declare function loadRoles(dir?: string): Role[];
20
- export declare const MANAGED_LINE = "<!-- robisie:managed 0.5.30 \u2014 plik zarz\u0105dzany przez `npx robisie`; `npx robisie uninstall` go usunie -->";
20
+ export declare const MANAGED_LINE = "<!-- robisie:managed 0.5.32 \u2014 plik zarz\u0105dzany przez `npx robisie`; `npx robisie uninstall` go usunie -->";
21
21
  export type AgentFlavor = "claude" | "codex" | "opencode";
22
22
  /** How the operator starts the Builder for one card in its own session (the card id is not a secret). */
23
23
  export declare function builderStartCommand(flavor: AgentFlavor, codexRolePath?: string): string;
package/dist/roles.js CHANGED
@@ -62,7 +62,7 @@ export function builderStartCommand(flavor, codexRolePath = "<Builder role file>
62
62
  return `ROBISIE_CARD_REF=<card id> claude --agent manager-builder-client ${shellQuote(prompt)}`;
63
63
  if (flavor === "opencode")
64
64
  return `ROBISIE_CARD_REF=<card id> opencode run --agent manager-builder-client ${shellQuote(prompt)}`;
65
- return `ROBISIE_CARD_REF=<card id> codex ${shellQuote(`Act as the robisie Builder: read ${codexRolePath} in full and follow it. ${prompt}`)}`;
65
+ return `ROBISIE_CARD_REF=<card id> codex -c features.apps=false ${shellQuote(`Act as the robisie Builder: read ${codexRolePath} in full and follow it. ${prompt}`)}`;
66
66
  }
67
67
  /** The one section robisie adds: how the unchanged contract maps onto this agent. */
68
68
  export function adapterSection(flavor, codexRolePath) {
package/docs/README.en.md CHANGED
@@ -1,4 +1,4 @@
1
- # robisie — from account to accepted card (package 0.5.30) <!-- x-release-please-version -->
1
+ # robisie — from account to accepted card (package 0.5.32) <!-- x-release-please-version -->
2
2
 
3
3
  In the project directory with its engine configuration, run `npx robisie init`, then `npx robisie doctor`: init prepares the project goal and tester protection list, and doctor checks both inputs.
4
4
 
@@ -383,7 +383,7 @@ The ID comes from the created or freshly read card, not the project or session.
383
383
 
384
384
  ```sh
385
385
  ROBISIE_CARD_REF=12345678-1234-1234-1234-123456789abc claude --agent manager-builder-client 'Start the assigned client task now. Read launch context first and follow the role contract through review handoff.'
386
- ROBISIE_CARD_REF=12345678-1234-1234-1234-123456789abc codex 'Act as the robisie Builder: read /home/tester/Robisie config/robisie/roles/codex/manager-builder-client.md in full and follow it. Start the assigned client task now. Read launch context first and follow the role contract through review handoff.'
386
+ ROBISIE_CARD_REF=12345678-1234-1234-1234-123456789abc codex -c features.apps=false 'Act as the robisie Builder: read /home/tester/Robisie config/robisie/roles/codex/manager-builder-client.md in full and follow it. Start the assigned client task now. Read launch context first and follow the role contract through review handoff.'
387
387
  ROBISIE_CARD_REF=12345678-1234-1234-1234-123456789abc opencode run --agent manager-builder-client 'Start the assigned client task now. Read launch context first and follow the role contract through review handoff.'
388
388
  ```
389
389
 
package/docs/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # robisie — od konta do odebranej karty (paczka 0.5.30) <!-- x-release-please-version -->
1
+ # robisie — od konta do odebranej karty (paczka 0.5.32) <!-- x-release-please-version -->
2
2
 
3
3
  W katalogu projektu z konfiguracją silnika uruchom `npx robisie init`, potem `npx robisie doctor`: init przygotuje cel projektu i listę ochrony testera, a doctor sprawdzi oba wejścia.
4
4
 
@@ -430,7 +430,7 @@ ID pochodzi z utworzonej lub odczytanej karty, nie z projektu ani sesji. Poniże
430
430
 
431
431
  ```sh
432
432
  ROBISIE_CARD_REF=12345678-1234-1234-1234-123456789abc claude --agent manager-builder-client 'Start the assigned client task now. Read launch context first and follow the role contract through review handoff.'
433
- ROBISIE_CARD_REF=12345678-1234-1234-1234-123456789abc codex 'Act as the robisie Builder: read /home/tester/Robisie config/robisie/roles/codex/manager-builder-client.md in full and follow it. Start the assigned client task now. Read launch context first and follow the role contract through review handoff.'
433
+ ROBISIE_CARD_REF=12345678-1234-1234-1234-123456789abc codex -c features.apps=false 'Act as the robisie Builder: read /home/tester/Robisie config/robisie/roles/codex/manager-builder-client.md in full and follow it. Start the assigned client task now. Read launch context first and follow the role contract through review handoff.'
434
434
  ROBISIE_CARD_REF=12345678-1234-1234-1234-123456789abc opencode run --agent manager-builder-client 'Start the assigned client task now. Read launch context first and follow the role contract through review handoff.'
435
435
  ```
436
436
 
@@ -128,7 +128,7 @@ function builderCommand(environment) {
128
128
  if (provider === "opencode") return `opencode run --agent manager-builder-client '${BUILDER_PROMPT}'`;
129
129
  const rolePath = join(configDir, "roles", "codex", "manager-builder-client.md");
130
130
  const prompt = `Act as the robisie Builder: read ${rolePath} in full and follow it. ${BUILDER_PROMPT}`;
131
- return `codex exec '${prompt.replace(/'/g, "'\\''")}'`;
131
+ return `codex exec -c features.apps=false '${prompt.replace(/'/g, "'\\''")}'`;
132
132
  }
133
133
 
134
134
  export function buildLaunchContract(cardRef, projectContext, sourceEnvironment) {
@@ -574,7 +574,7 @@ async function spawnQuality(cardRef, dependencies) {
574
574
  const prompt = `${role}\n\nReview only cardRef: ${cardRef}. Bind get_project_context first; require configured MCP. Follow prepare_review, independent checks, create_review_receipt, append/readback and verify_stored_review. Return only the complete direct JSON receipt.\n`;
575
575
  const stdout = await new Promise((resolveOutput, rejectOutput) => {
576
576
  const child = (dependencies.execQuality ?? execFile)("codex", [
577
- "exec", "--ephemeral", "-s", "read-only", "-c", 'model_reasoning_effort="high"', "-",
577
+ "exec", "--ephemeral", "-s", "read-only", "-c", "features.apps=false", "-c", 'model_reasoning_effort="high"', "-",
578
578
  ], {
579
579
  cwd: projectContext,
580
580
  env: { ...copyLaunchEnvironment(environment), ROBISIE_KEY: credential, ROBISIE_PROJECT_CONTEXT: projectContext },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "robisie",
3
- "version": "0.5.30",
3
+ "version": "0.5.32",
4
4
  "description": "Instalator klienta robisie: łączy agenta (Claude Code, Codex CLI, OpenCode) z tablicą robisie i instaluje role klienta.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",