robisie 0.5.31 → 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,13 @@
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
+
3
11
  ## [0.5.31](https://github.com/chuppa12/robisie-app/compare/client-v0.5.30...client-v0.5.31) (2026-11-14)
4
12
 
5
13
 
@@ -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.31";
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.31"; // 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":"201d1f0395fd6dc8713936ac21c74934a4fbe88e","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:18049) 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.31";
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";
@@ -315230,6 +315230,7 @@ __export2(tick_exports, {
315230
315230
  executeDeliveredTest: () => executeDeliveredTest,
315231
315231
  executeTesterJob: () => executeTesterJob,
315232
315232
  findEngineProject: () => findEngineProject,
315233
+ flushReviewGrantDiagnostics: () => flushReviewGrantDiagnostics,
315233
315234
  handleCiNoChecksAlarm: () => handleCiNoChecksAlarm,
315234
315235
  handleDiskPressure: () => handleDiskPressure,
315235
315236
  hostActivationAlarm: () => hostActivationAlarm,
@@ -315444,21 +315445,76 @@ function actionableBlockerHold(card, predecessors) {
315444
315445
  if (actionableBlockerRecovery(card, predecessors)) return null;
315445
315446
  return "ACTIONABLE_BLOCKER: seed_brief_sha256 bez zmian; wymagany nowy brief albo depends_on na nierozwi\u0105zan\u0105 kart\u0119-przeszkod\u0119";
315446
315447
  }
315447
- async function recoverBlockedWorkers(s, uid, projectId2, dry = DRY2) {
315448
+ async function recoverBlockedWorkers(s, uid, projectId2, dry = DRY2, pending) {
315448
315449
  if (dry) return;
315450
+ const diagnostics = pending ?? /* @__PURE__ */ new Map();
315451
+ let failure3;
315449
315452
  const rows = await scanTasks(uid, projectId2, { full: true, statuses: ["blocked"], detailsKeys: BLOCKED_WORKER_DETAILS_KEYS });
315450
315453
  for (const row of rows) {
315451
- if (!["ACTIONABLE_BLOCKER", "WORKER_FINISHED"].includes(String(asRecord3(row.details?.maszynista).outcome)) || s.actives.some((a) => a.taskId === row.id)) continue;
315452
- if (row.assignee !== null || landedSha(row) || row.details?.reksio_withheld === true) continue;
315453
- const card = await getTask2(uid, row.id);
315454
- if (!card || card.status !== "blocked" || card.assignee !== null || landedSha(card) || draftHeld(card.details ?? {})) continue;
315455
- const predecessors = await factoryPredecessors(uid, [card]);
315456
- if (!factoryDependenciesReady(card, predecessors)) continue;
315454
+ let diagnostic;
315455
+ const candidate = grantCandidates(row).length > 0;
315457
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
+ }
315458
315507
  const worker = asRecord3(card.details?.maszynista);
315459
315508
  if (worker.outcome === "WORKER_FINISHED") {
315460
- if (worker.phase === "blocked" && worker.move === "blocked" && !await consumeR3Grant(s, uid, card))
315461
- 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);
315462
315518
  continue;
315463
315519
  }
315464
315520
  if (!actionableBlockerRecovery(card, predecessors)) continue;
@@ -315470,9 +315526,15 @@ async function recoverBlockedWorkers(s, uid, projectId2, dry = DRY2) {
315470
315526
  });
315471
315527
  log2(`karta ${card.id}: naprawiona powi\u0105zana przeszkoda \u2192 ready`);
315472
315528
  } catch (error48) {
315473
- 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;
315474
315534
  }
315475
315535
  }
315536
+ if (!pending) await flushReviewGrantDiagnostics(uid, diagnostics);
315537
+ if (failure3) throw failure3;
315476
315538
  }
315477
315539
  function ringDraftChanges(cards, dry = DRY2) {
315478
315540
  if (dry) return;
@@ -318088,39 +318150,126 @@ async function deliver3(s, uid, card, sha5) {
318088
318150
  function readyTaskPatch() {
318089
318151
  return { status: "ready", assignee: null, detailsPatch: { readyAt: new Date(Date.now()).toISOString() } };
318090
318152
  }
318091
- 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) {
318092
318232
  const review = asRecord3(card.details?.review), sha5 = review.sha;
318093
- 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);
318094
318240
  const token = `LIMIT_RUND ${card.id} ${sha5} R3`;
318095
318241
  const rulings = card.details?.rozstrzygniecia_reksia;
318096
318242
  const matching = Array.isArray(rulings) ? rulings.map(asRecord3).filter((ruling) => ruling.znalezisko === token) : [];
318097
- if (matching.length > 1) return null;
318243
+ if (matching.length > 1) return rejectGrant(diagnostic, "ambiguous_rulings", 3);
318098
318244
  const grant = matching[0] ?? asRecord3(asRecord3(card.details?.unblock).verdict), at3 = grant.at;
318099
- 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);
318100
318246
  if (matching.length === 1) {
318101
- 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);
318102
318248
  } else {
318103
318249
  const worker = asRecord3(card.details?.maszynista), blockedAt = card.details?.scope_blocked_at;
318104
- 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);
318105
318251
  }
318106
318252
  try {
318107
318253
  const full = asRecord3(JSON.parse((0, import_node_fs47.readFileSync)(checkedReceipt(review.receipt).path, "utf8")));
318108
318254
  const ciResult = asRecord3(asRecord3(card.details?.maszynista).ciResult);
318109
- 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) => {
318110
318258
  const { name: name3, status: status2, conclusion } = asRecord3(value);
318111
318259
  return status2 === "completed" && conclusion !== "success" && typeof name3 === "string" && REQUIRED_CHECKS2.some((required3) => name3.startsWith(required3));
318112
- }) || 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);
318113
318262
  } catch (error48) {
318114
- log2(`R4 ${card.id}: brak dowodu zako\u0144czonej R3: ${errorText5(error48)}`);
318115
- 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);
318116
318265
  }
318117
318266
  return { token, at: at3, sha: sha5, fromRound: 2, rulingSha256: (0, import_node_crypto32.createHash)("sha256").update(JSON.stringify(grant)).digest("hex") };
318118
318267
  }
318119
- async function consumeR3Grant(s, uid, card) {
318120
- const grant = r3Grant(card);
318268
+ async function consumeR3Grant(s, uid, card, diagnostic) {
318269
+ const grant = r3Grant(card, diagnostic);
318121
318270
  if (!grant || decideReviewMove("FAIL", 2, 0, true) !== "repair") return false;
318122
318271
  const fresh = await getTask2(uid, card.id);
318123
- 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;
318124
318273
  const review = { ...asRecord3(fresh.details?.review), round: 3, extraRoundGrant: { ...grant, briefSha256: contractSha(fresh) } };
318125
318274
  const maszynista = { ...asRecord3(fresh.details?.maszynista), phase: "repair", move: "repair" };
318126
318275
  await updateTask2(uid, card.id, {
@@ -318145,50 +318294,59 @@ function contractSha(card) {
318145
318294
  if (typeof declared === "string" && /^[a-f0-9]{64}$/i.test(declared) && declared.toLowerCase() !== computed.toLowerCase()) return null;
318146
318295
  return computed.toLowerCase();
318147
318296
  }
318148
- function r4Grant(card) {
318297
+ function r4Grant(card, diagnostic) {
318149
318298
  const review = asRecord3(card.details?.review), sha5 = review.sha, r3 = review.extraRoundGrant;
318150
- 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);
318151
318306
  const current = contractSha(card);
318152
- if (!current) return null;
318307
+ if (!current) return rejectGrant(diagnostic, "contract", 4);
318153
318308
  const token = `LIMIT_RUND ${card.id} ${sha5} R4`;
318154
318309
  const rulings = card.details?.rozstrzygniecia_reksia;
318155
318310
  const matching = Array.isArray(rulings) ? rulings.map(asRecord3).filter((ruling2) => ruling2.znalezisko === token) : [];
318156
- if (matching.length !== 1) return null;
318311
+ if (matching.length !== 1) return rejectGrant(diagnostic, "ambiguous_rulings", 4);
318157
318312
  const ruling = matching[0], at3 = ruling.at, declared = ruling.nowy_brief_sha256;
318158
- 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);
318159
318315
  const used = asRecord3(review.extraRound4Grant);
318160
- 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);
318161
318317
  try {
318162
318318
  const full = asRecord3(JSON.parse((0, import_node_fs47.readFileSync)(checkedReceipt(review.receipt).path, "utf8")));
318163
- 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);
318164
318322
  if (full.verdict === "FAIL") {
318165
- 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);
318166
318324
  const previous = asRecord3(r3).briefSha256;
318167
318325
  if (typeof previous === "string") {
318168
- if (previous.toLowerCase() === current) return null;
318326
+ if (previous.toLowerCase() === current) return rejectGrant(diagnostic, "brief_used", 4);
318169
318327
  } else {
318170
318328
  const r3Ruling = [...Array.isArray(rulings) ? rulings : [], asRecord3(card.details?.unblock).verdict].find((candidate) => candidate != null && rulingSha(candidate) === asRecord3(r3).rulingSha256);
318171
318329
  const r3Brief = asRecord3(r3Ruling).nowy_brief_sha256;
318172
- if (typeof r3Brief === "string" && r3Brief.toLowerCase() === current) return null;
318330
+ if (typeof r3Brief === "string" && r3Brief.toLowerCase() === current) return rejectGrant(diagnostic, "brief_used", 4);
318173
318331
  }
318174
318332
  } else if (full.verdict === "PASS") {
318175
318333
  const ciResult = asRecord3(asRecord3(card.details?.maszynista).ciResult), previousSha = asRecord3(r3).sha;
318176
318334
  if (typeof previousSha !== "string" || !/^[a-f0-9]{40}$/.test(previousSha) || previousSha === sha5 || ciResult.sha !== sha5 || !Array.isArray(ciResult.runs) || !ciResult.runs.some((value) => {
318177
318335
  const { name: name3, status: status2, conclusion } = asRecord3(value);
318178
318336
  return status2 === "completed" && conclusion !== "success" && typeof name3 === "string" && REQUIRED_CHECKS2.some((required3) => name3.startsWith(required3));
318179
- })) return null;
318180
- } else return null;
318337
+ })) return rejectGrant(diagnostic, "ci", 4);
318338
+ } else return rejectGrant(diagnostic, "receipt_verdict", 4);
318181
318339
  } catch (error48) {
318182
- log2(`runda 3\u21924 ${card.id}: brak dowodu zako\u0144czonej rundy 3: ${errorText5(error48)}`);
318183
- 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);
318184
318342
  }
318185
318343
  return { token, at: at3, sha: sha5, fromRound: 3, briefSha256: current, rulingSha256: rulingSha(ruling) };
318186
318344
  }
318187
- async function consumeR4Grant(s, uid, card) {
318188
- const grant = r4Grant(card);
318345
+ async function consumeR4Grant(s, uid, card, diagnostic) {
318346
+ const grant = r4Grant(card, diagnostic);
318189
318347
  if (!grant) return false;
318190
318348
  const fresh = await getTask2(uid, card.id);
318191
- 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;
318192
318350
  const review = { ...asRecord3(fresh.details?.review), round: 4, extraRound4Grant: grant };
318193
318351
  const maszynista = { ...asRecord3(fresh.details?.maszynista), phase: "repair", move: "repair" };
318194
318352
  await updateTask2(uid, card.id, {
@@ -318207,19 +318365,41 @@ async function consumeR4Grant(s, uid, card) {
318207
318365
  lastTick(s, "repair", `CR: jednorazowa runda 3\u21924 dla ${grant.sha}`, true, card.id);
318208
318366
  return true;
318209
318367
  }
318210
- async function recoverReviewRoundGrants(s, uid, cards) {
318368
+ async function recoverReviewRoundGrants(s, uid, cards, pending) {
318211
318369
  if (DRY2) return;
318370
+ const diagnostics = pending ?? /* @__PURE__ */ new Map();
318371
+ let failure3;
318212
318372
  for (const snapshot2 of cards) {
318213
- const details2 = snapshot2.details ?? {};
318214
- const rulings = details2.rozstrzygniecia_reksia;
318215
- const review = asRecord3(details2.review);
318216
- const tokens = [`LIMIT_RUND ${snapshot2.id} ${review.sha} R3`, `LIMIT_RUND ${snapshot2.id} ${review.sha} R4`];
318217
- 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;
318218
- const fresh = await getTask2(uid, snapshot2.id);
318219
- if (fresh?.status !== "blocked" || !recoveryDetailsMatch(fresh, snapshot2)) continue;
318220
- if (r3Grant(fresh)) await consumeR3Grant(s, uid, fresh);
318221
- 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
+ }
318222
318400
  }
318401
+ if (!pending) await flushReviewGrantDiagnostics(uid, diagnostics);
318402
+ if (failure3) throw failure3;
318223
318403
  }
318224
318404
  async function applyReview(s, uid, card, verdict, notes) {
318225
318405
  const previous = asRecord3(card.details?.review);
@@ -325479,8 +325659,9 @@ async function main2() {
325479
325659
  outcome = "failed";
325480
325660
  log2(`FAIL powr\xF3t pakowania: ${errorText6(error48)}`);
325481
325661
  }
325662
+ const grantDiagnostics = /* @__PURE__ */ new Map();
325482
325663
  try {
325483
- await recoverReviewRoundGrants(s, uid, activationCards);
325664
+ await recoverReviewRoundGrants(s, uid, activationCards, grantDiagnostics);
325484
325665
  } catch (error48) {
325485
325666
  runtimeFailed = true;
325486
325667
  outcome = "failed";
@@ -325552,12 +325733,13 @@ async function main2() {
325552
325733
  };
325553
325734
  await leadPhase();
325554
325735
  try {
325555
- await recoverBlockedWorkers(s, uid, projectId2);
325736
+ await recoverBlockedWorkers(s, uid, projectId2, DRY2, grantDiagnostics);
325556
325737
  } catch (error48) {
325557
325738
  runtimeFailed = true;
325558
325739
  outcome = "failed";
325559
325740
  log2(`FAIL powr\xF3t po blokerze: ${errorText6(error48)}`);
325560
325741
  }
325742
+ await flushReviewGrantDiagnostics(uid, grantDiagnostics);
325561
325743
  await leadPhase();
325562
325744
  let dispatchableReadyCount = "UNKNOWN";
325563
325745
  let dispatchError;
@@ -325948,7 +326130,7 @@ var init_tick = __esm({
325948
326130
  REVIEW_SCAN_FIELDS = [...REVIEW_RECOVERY_FIELDS];
325949
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"];
325950
326132
  DECISION_REFRESH_DETAILS_KEYS = [...DECISION_DETAILS_KEYS];
325951
- BLOCKED_WORKER_DETAILS_KEYS = ["maszynista", "landed", "reksio_withheld"];
326133
+ BLOCKED_WORKER_DETAILS_KEYS = ["maszynista", "landed", "reksio_withheld", "rozstrzygniecia_reksia"];
325952
326134
  ENABLED_SCAN_DETAILS_KEYS = ["card_class", "landed", "enabled_check", "enabled_evidence", "enabled_auto"];
325953
326135
  RESERVATION_DETAILS_KEYS = [...SCOPE_RESERVATION_DETAILS_KEYS, "origin"];
325954
326136
  RESERVATION_SCAN_DETAILS_KEYS = [...RESERVATION_DETAILS_KEYS, "test", "landed", "retest"];
@@ -326141,6 +326323,7 @@ init_tick();
326141
326323
  executeDeliveredTest,
326142
326324
  executeTesterJob,
326143
326325
  findEngineProject,
326326
+ flushReviewGrantDiagnostics,
326144
326327
  handleCiNoChecksAlarm,
326145
326328
  handleDiskPressure,
326146
326329
  hostActivationAlarm,
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.31 \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/docs/README.en.md CHANGED
@@ -1,4 +1,4 @@
1
- # robisie — from account to accepted card (package 0.5.31) <!-- 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
 
package/docs/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # robisie — od konta do odebranej karty (paczka 0.5.31) <!-- 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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "robisie",
3
- "version": "0.5.31",
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",