robisie 0.6.15 → 0.7.1

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,35 @@
1
1
  # Historia zmian klienta / Client changelog
2
2
 
3
+ ## [0.7.1](https://github.com/chuppa12/robisie-app/compare/client-v0.7.0...client-v0.7.1) (2026-11-20)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **maszynista:** świeża karta human u klienta nie zatrzymuje dispatchu wszystkich kart (stempel bez undefined) ([305f66c](https://github.com/chuppa12/robisie-app/commit/305f66c4cd24f9923317b3ab12f9e2e52e940616))
9
+
10
+ ## [0.7.0](https://github.com/chuppa12/robisie-app/compare/client-v0.6.15...client-v0.7.0) (2026-11-20)
11
+
12
+
13
+ ### Features
14
+
15
+ * **maszynista:** jeden kompilator intencji w repo na kanonie silnika (LUKI:947) ([b081481](https://github.com/chuppa12/robisie-app/commit/b08148109b73adced55834511f4d937aa63efe99))
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **maszynista:** odmowa roli klucza (403) przy zapisie sprawy nie zatrzymuje ruchu karty u klienta (luka D) ([35b11f3](https://github.com/chuppa12/robisie-app/commit/35b11f349371a40c0a49efcfa94882b4aee657f7))
21
+ * **maszynista:** odmowa roli klucza (403) przy zapisie sprawy nie zatrzymuje ruchu karty u klienta (luka D) ([17e9aa2](https://github.com/chuppa12/robisie-app/commit/17e9aa2933a0c8bcba42f103554df32119c452a6))
22
+ * **release:** smoke ponawia 404 tarballa dokładnie tej wersji (LUKI:945) ([cfa6bd8](https://github.com/chuppa12/robisie-app/commit/cfa6bd89dea5e76da174d40f12b06eef03123503))
23
+
24
+
25
+ ### Factory Cards
26
+
27
+ * Aktualizacja paczki (u nas i u klienta) odracza kodem 0 i bez alarmu przez cały job Testera albo odbiorcy, którego proces rozpoznaje jako job tej instalacji, także dłuższy niż 10 minut; nierozpoznany żywy PID i stary claim dalej odmawiają z alarmem ([4e17af1](https://github.com/chuppa12/robisie-app/commit/4e17af1b51d34870abd00a4918d50deb24483b13))
28
+ * praca workera task-mwo88lbs-hc9kvq (auto-commit) ([560d9db](https://github.com/chuppa12/robisie-app/commit/560d9db7eae546cffd2d7c4f6b797d0758c31a84))
29
+ * praca workera task-mwo8vkxh-9cai5a (auto-commit) ([168ffe8](https://github.com/chuppa12/robisie-app/commit/168ffe8408725cccfc156f5aa49e5c1232403e82))
30
+ * praca workera task-mwo9t5d7-j47ti7 (auto-commit) ([98ebc5c](https://github.com/chuppa12/robisie-app/commit/98ebc5cb0a44df1ac0b394f9afcb80d51a18c7ca))
31
+ * praca workera task-mwoao298-s87f9k (auto-commit) ([aeeee27](https://github.com/chuppa12/robisie-app/commit/aeeee277c42b3b11984a7aa83260a23231901175))
32
+
3
33
  ## [0.6.15](https://github.com/chuppa12/robisie-app/compare/client-v0.6.14...client-v0.6.15) (2026-11-19)
4
34
 
5
35
 
@@ -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.6.15";
3
+ export declare const PACKAGE_VERSION = "0.7.1";
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.6.15"; // x-release-please-version
3
+ export const PACKAGE_VERSION = "0.7.1"; // 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":"5c3872acc2f171f2a0916b5fc6b9dc89f4c8fc86","dirty":false}
1
+ {"schema":1,"sha":"bfd296712a2dc216f11ab22121421d1f22f2e2d9","dirty":false}
@@ -1704,14 +1704,14 @@
1704
1704
  "staticOperations": {
1705
1705
  "beforePreflight": {
1706
1706
  "module": "maszynista/tick.ts",
1707
- "startLine": 10276,
1708
- "endLine": 10389,
1707
+ "startLine": 10290,
1708
+ "endLine": 10403,
1709
1709
  "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();"
1710
1710
  },
1711
1711
  "finalization": {
1712
1712
  "module": "maszynista/tick.ts",
1713
- "startLine": 10680,
1714
- "endLine": 10732,
1713
+ "startLine": 10694,
1714
+ "endLine": 10746,
1715
1715
  "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] ?? \"\"))) {"
1716
1716
  },
1717
1717
  "refreshTickReport": {
@@ -1737,6 +1737,6 @@
1737
1737
  "status": 0,
1738
1738
  "signal": null,
1739
1739
  "stdout": "v24.3.0\n",
1740
- "stderr": "(node:24514) 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"
1740
+ "stderr": "(node:24450) 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"
1741
1741
  }
1742
1742
  }
@@ -37652,7 +37652,7 @@ var init_constants = __esm({
37652
37652
  "packages/client/src/constants.ts"() {
37653
37653
  "use strict";
37654
37654
  PACKAGE_NAME = "robisie";
37655
- PACKAGE_VERSION = "0.6.15";
37655
+ PACKAGE_VERSION = "0.7.1";
37656
37656
  SUPPORTED_CONTRACT_MAJOR = 1;
37657
37657
  DEFAULT_ORIGIN = "https://robisie.app";
37658
37658
  MCP_SERVER_NAME = "robisie";
@@ -316236,6 +316236,7 @@ function discoverImportingTests(files2, repo) {
316236
316236
  if (state.isSymbolicLink() || (0, import_node_fs43.realpathSync)(directory2) !== directory2) throw new Error(`${(0, import_node_path47.relative)(root, directory2)}: symlink w skanowanym drzewie; brak pe\u0142nej listy test\xF3w`);
316237
316237
  for (const entry2 of (0, import_node_fs43.readdirSync)(directory2, { withFileTypes: true })) {
316238
316238
  if (entry2.name === ".git" || entry2.name === "node_modules") continue;
316239
+ if (entry2.name === "update" && directory2 === (0, import_node_path47.resolve)(root, "maszynista")) continue;
316239
316240
  const absolute2 = (0, import_node_path47.resolve)(directory2, entry2.name);
316240
316241
  if (entry2.isSymbolicLink()) throw new Error(`${(0, import_node_path47.relative)(root, absolute2)}: symlink w skanowanym drzewie; brak pe\u0142nej listy test\xF3w`);
316241
316242
  if (entry2.isDirectory()) walk(absolute2, nestedOnly);
@@ -318883,7 +318884,15 @@ async function prepareCardEvent(uid, card, type, occurrence, proof, evidence2) {
318883
318884
  };
318884
318885
  const leadClass = leadClassOf(type, type === "host-activation" ? asRecord3(evidence2).code : proof.value.outcome);
318885
318886
  if (leadClass) record20.lead_class = leadClass;
318886
- const actual = await writeDecisionMatter2(uid, card.id, id2, record20);
318887
+ let actual;
318888
+ try {
318889
+ actual = await writeDecisionMatter2(uid, card.id, id2, record20);
318890
+ } catch (error48) {
318891
+ const cause = error48 instanceof Error ? error48.cause : void 0;
318892
+ if (quarantine || type === "host-activation" || !(cause instanceof PlanerClientError) || cause.operation !== "write_decision_matter" || cause.code !== "FORBIDDEN") throw error48;
318893
+ logSkippedCardEvent(card.id, "sprawa-niezapisana", `sprawa niezapisana: FORBIDDEN card_id=${card.id} event_type=${type}`);
318894
+ return;
318895
+ }
318887
318896
  if (!actual || !(0, import_node_util14.isDeepStrictEqual)(actual, record20)) throw new Error(`card-event HOLD zapis odm\xF3wiony ${id2}`);
318888
318897
  return checkedEvent(actual, card.id);
318889
318898
  }
@@ -323169,7 +323178,7 @@ async function reconcileBoardActives(s, uid, boardCards2, installation = tickIns
323169
323178
  const worker = asRecord3(boardCards2.find((card) => card.id === active.taskId)?.details?.maszynista);
323170
323179
  await appendBoundedDetail(uid, active.taskId, { maszynista: {
323171
323180
  ...stamp2,
323172
- ...engineClient() ? { clientPair: worker.clientPair, ...worker.clientReceiver !== void 0 ? { clientReceiver: worker.clientReceiver } : {}, startedAt: worker.startedAt } : {},
323181
+ ...engineClient() ? definedOnly({ clientPair: worker.clientPair, ...worker.clientReceiver !== void 0 ? { clientReceiver: worker.clientReceiver } : {}, startedAt: worker.startedAt }) : {},
323173
323182
  artifacts
323174
323183
  } });
323175
323184
  } catch (err) {
@@ -323198,6 +323207,9 @@ function workerIdentity(meta4, client = engineClient()) {
323198
323207
  ...typeof meta4.provider === "string" && meta4.provider.trim() ? { provider: meta4.provider } : !client && meta4.backend === "codex" ? { provider: "openai" } : {}
323199
323208
  };
323200
323209
  }
323210
+ function definedOnly(record20) {
323211
+ return Object.fromEntries(Object.entries(record20).filter(([, value]) => value !== void 0));
323212
+ }
323201
323213
  function hasCompoundLearningLine(report) {
323202
323214
  return /^[ \t]*(?:[-*][ \t]*)?compound_learning:[ \t]*(?:zero|one|attempted_unavailable)\.?[ \t]*$/im.test(report);
323203
323215
  }
@@ -323326,14 +323338,14 @@ async function consumeActive(s, uid, a = s.actives[0], landing = { available: tr
323326
323338
  if (decision.action === "recover_to_review") {
323327
323339
  const evidence3 = {
323328
323340
  maszynista: {
323329
- ...engineClient() ? {
323341
+ ...engineClient() ? definedOnly({
323330
323342
  clientPair: metadata.clientPair,
323331
323343
  ...metadata.clientReceiver !== void 0 ? { clientReceiver: metadata.clientReceiver } : {},
323332
323344
  backend: metadata.backend,
323333
323345
  model: metadata.model,
323334
323346
  engine: metadata.engine,
323335
323347
  startedAt: metadata.startedAt
323336
- } : {},
323348
+ }) : {},
323337
323349
  ...engineClient() ? {} : workerIdentity(metadata),
323338
323350
  branchLease: metadata.branchLease ?? null,
323339
323351
  at: (/* @__PURE__ */ new Date()).toISOString(),
@@ -327860,7 +327872,7 @@ async function dispatchNext(s, uid, projectId2, diskDependencies, cards = /* @__
327860
327872
  if (!DRY2) {
327861
327873
  const worker = asRecord3(c.details?.maszynista);
327862
327874
  await appendBoundedDetail(uid, c.id, { maszynista: {
327863
- ...engineClient() ? {
327875
+ ...engineClient() ? definedOnly({
327864
327876
  clientPair: worker.clientPair,
327865
327877
  ...worker.clientReceiver !== void 0 ? { clientReceiver: worker.clientReceiver } : {},
327866
327878
  backend: worker.backend,
@@ -327871,7 +327883,7 @@ async function dispatchNext(s, uid, projectId2, diskDependencies, cards = /* @__
327871
327883
  attempts: worker.attempts,
327872
327884
  worktree: worker.worktree,
327873
327885
  branch: worker.branch
327874
- } : {},
327886
+ }) : {},
327875
327887
  ...engineClient() ? {} : workerIdentity(worker),
327876
327888
  at: (/* @__PURE__ */ new Date()).toISOString(),
327877
327889
  verdict: "human",
@@ -534,25 +534,30 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
534
534
  }
535
535
  };
536
536
  const processBusy = () => {
537
- const result = runtime.exec('ps', ['-axo', 'pid=,command='], ctx.cwd, env);
538
- if (result.status !== 0 || result.signal !== null)
537
+ // macOS ps needs a UTF-8 locale to preserve argv paths. Sonoma may lack C.UTF-8.
538
+ const psEnv = ctx.platform === 'darwin' ? { ...env, LC_ALL: 'en_US.UTF-8' } : env;
539
+ const result = runtime.exec('ps', ['-axo', 'pid=,command='], ctx.cwd, psEnv);
540
+ if (result.status !== 0 || result.signal !== null || result.errorCode !== undefined)
539
541
  refuse('Nieustalony stan procesów fabryki.');
540
542
  let busy = null;
543
+ const jobs = { tester: new Set(), receiver: new Set() };
541
544
  for (const line of result.stdout.split('\n').filter(line => line.trim())) {
542
545
  const match = line.match(/^\s*([1-9]\d*)\s+(\S.*)$/);
543
- if (!match || !Number.isSafeInteger(Number(match[1])))
546
+ const pid = Number(match?.[1]);
547
+ if (!match || !Number.isSafeInteger(pid))
544
548
  refuse('Nieustalony stan procesów fabryki.');
545
- if (Number(match[1]) === runtime.pid)
549
+ if (pid === runtime.pid)
546
550
  continue;
547
- const tokens = match[2].trim().split(/\s+/).slice(0, 8), name = basename(tokens[0]);
551
+ const argv = match[2];
552
+ const tokens = argv.trim().split(/\s+/).slice(0, 8), name = basename(tokens[0]);
548
553
  const entry = tokens[1] === '--import' && tokens[2] === 'tsx' ? 3 : 1;
549
554
  const script = basename(tokens[entry] ?? '');
550
- const job = /\.(?:cjs|mjs|js)$/.test(script) && tokens[entry + 1] === '--job'
551
- && ['tester', 'receiver'].includes(tokens[entry + 2] ?? '') && Boolean(tokens[entry + 3]);
555
+ // ps flattens argv. Keep both paths whole around the launcher's fixed --job argument.
556
+ const job = name === 'node' ? argv.match(/^\S+\s+(?:--import\s+tsx\s+)?(\/.*?\.(?:cjs|mjs|js))\s+--job\s+(tester|receiver)\s+(.+)$/) : null;
552
557
  let factory = false;
553
558
  if (name === 'node' && (/^(?:tick|tester-job|receiver-job)\.(?:cjs|ts|js)$/.test(script) || script === 'cli.js' || job)) {
554
559
  readHostService();
555
- const path = processEntry(tokens[entry]);
560
+ const path = processEntry(job?.[1] ?? tokens[entry]);
556
561
  if (path) {
557
562
  const dirs = [dirname(fileURLToPath(runtime.moduleUrl))];
558
563
  if (hostService)
@@ -563,6 +568,12 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
563
568
  const cli = dirs.some(dir => processEntry(join(dir, 'cli.js')) === path);
564
569
  // build-engine.mjs emits tick.cjs; aliases must resolve to that entrypoint.
565
570
  const bundle = dirs.some(dir => processEntry(join(dir, 'engine/tick.cjs')) === path);
571
+ const family = job?.[2], input = job?.[3];
572
+ if (bundle && (family === 'tester' || family === 'receiver')) {
573
+ const target = family === 'tester' ? '.tester-job.input.json' : 'receiver-jobs/local';
574
+ if (input === join(state, target) || input === join(config.stateDir, target))
575
+ jobs[family].add(pid);
576
+ }
566
577
  const source = /^(?:tick|tester-job|receiver-job)\.(?:cjs|ts|js)$/.test(basename(path))
567
578
  && dirname(path) === join(repo, 'maszynista');
568
579
  factory = cli && tokens[entry + 1] === 'factory' && tokens[entry + 2] === 'run'
@@ -576,41 +587,114 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
576
587
  if (active)
577
588
  busy ??= `proces ${/^[A-Za-z0-9._-]+$/.test(name) ? name : 'fabryki'} PID ${match[1]}`;
578
589
  }
579
- return busy;
590
+ return { busy, jobs };
591
+ };
592
+ const unsettledClaim = (name) => refuse(`Nierozliczony claim ${name}; zachowaj stan.`);
593
+ const readClaim = (name, lock, promotion) => {
594
+ const path = join(state, name);
595
+ let file = null;
596
+ try {
597
+ file = stat(path);
598
+ if (!file)
599
+ return null;
600
+ if (!file.isFile())
601
+ throw new Error('unsafe claim');
602
+ const original = file;
603
+ const sameInode = (current) => current?.isFile() && current.ino === original.ino && current.dev === original.dev;
604
+ const promoted = () => {
605
+ if (!promotion || !sameInode(stat(join(state, promotion.target))))
606
+ return false;
607
+ promotion.detected = true;
608
+ return true;
609
+ };
610
+ let fd;
611
+ try {
612
+ fd = io.openSync(path, io.constants.O_RDONLY | io.constants.O_NOFOLLOW | io.constants.O_NONBLOCK);
613
+ }
614
+ catch (error) {
615
+ if (code(error) === 'ENOENT' && promoted())
616
+ return null;
617
+ throw error;
618
+ }
619
+ try {
620
+ if (!sameInode(io.fstatSync(fd)))
621
+ throw new Error('changed claim');
622
+ let pid;
623
+ if (lock) {
624
+ const bytes = io.readFileSync(fd);
625
+ try {
626
+ pid = json(bytes).pid;
627
+ }
628
+ catch { /* Successfully read bytes may not yet contain a usable PID. */ }
629
+ }
630
+ // process.kill accepts only signed 32-bit PIDs.
631
+ const livePid = typeof pid === 'number' && Number.isInteger(pid) && pid > 0 && pid <= 2_147_483_647
632
+ && alive(pid, name) ? pid : null;
633
+ const current = stat(path);
634
+ if (!current && promoted())
635
+ return null;
636
+ if (!current || !sameInode(current) || current.mtimeMs !== original.mtimeMs
637
+ || current.ctimeMs !== original.ctimeMs || current.size !== original.size)
638
+ throw new Error('changed claim');
639
+ return { mtimeMs: original.mtimeMs, livePid };
640
+ }
641
+ finally {
642
+ io.closeSync(fd);
643
+ }
644
+ }
645
+ catch {
646
+ if (file)
647
+ unsettledClaim(name);
648
+ refuse(`Nieczytelny claim ${name}; zachowaj stan.`);
649
+ }
650
+ };
651
+ const readClaimPair = (name, lock) => {
652
+ const pendingName = `${name}.pending`, promotion = { target: name, detected: false };
653
+ // The writer publishes pending to final. Read in that order to see a completed rename.
654
+ let pending = readClaim(pendingName, lock, promotion);
655
+ if (promotion.detected)
656
+ pending = readClaim(pendingName, lock);
657
+ const final = readClaim(name, lock);
658
+ if (promotion.detected && !final)
659
+ unsettledClaim(pendingName);
660
+ return [['', final], ['.pending', pending]];
580
661
  };
581
662
  const preflight = async () => {
582
663
  check();
583
- let busy = null;
584
- for (const claim of ['.tester-job.lock', '.tester-job.input.json', '.tester-job.result.json',
585
- ...['claim.json', 'started', 'wynik.json', 'stop.json', 'ack.json'].map(name => `receiver-jobs/local/${name}`)]) {
586
- for (const suffix of ['', '.pending']) {
587
- const name = claim + suffix, path = join(state, name);
588
- let exists = false;
589
- try {
590
- const file = stat(path);
664
+ let processes;
665
+ const scan = () => processes ??= processBusy();
666
+ let busy = null, qualified = null;
667
+ for (const [family, lock, ...companions] of [
668
+ ['tester', '.tester-job.lock', '.tester-job.input.json', '.tester-job.result.json'],
669
+ ['receiver', 'receiver-jobs/local/claim.json',
670
+ ...['started', 'wynik.json', 'stop.json', 'ack.json'].map(name => `receiver-jobs/local/${name}`)],
671
+ ]) {
672
+ const confirmed = new Map();
673
+ for (const [suffix, file] of readClaimPair(lock, true)) {
674
+ const name = lock + suffix;
675
+ if (!file)
676
+ continue;
677
+ if (file.livePid !== null && scan().jobs[family].has(file.livePid)) {
678
+ confirmed.set(suffix, file.mtimeMs);
679
+ qualified ??= `claim ${name}`;
680
+ }
681
+ else if (!(runtime.now() - file.mtimeMs <= 600_000))
682
+ unsettledClaim(name);
683
+ busy ??= file.livePid !== null ? `claim ${name}` : `claim ${name} czeka na rozliczenie przez takt`;
684
+ }
685
+ for (const companion of companions)
686
+ for (const [suffix, file] of readClaimPair(companion, false)) {
687
+ const name = companion + suffix;
591
688
  if (!file)
592
689
  continue;
593
- exists = true;
594
- if (!file.isFile() || !(runtime.now() - file.mtimeMs <= 600_000))
595
- throw new Error('unsafe claim');
596
- let live = false;
597
- if (claim === '.tester-job.lock' || claim === 'receiver-jobs/local/claim.json') {
598
- const bytes = regular(path);
599
- let pid;
600
- try {
601
- pid = json(bytes).pid;
602
- }
603
- catch { /* Successfully read bytes may not yet contain a usable PID. */ }
604
- // process.kill accepts only signed 32-bit PIDs.
605
- live = typeof pid === 'number' && Number.isInteger(pid) && pid > 0 && pid <= 2_147_483_647 && alive(pid, name);
606
- }
607
- busy ??= live ? `claim ${name}` : `claim ${name} czeka na rozliczenie przez takt`;
608
- }
609
- catch {
610
- refuse(`${exists ? 'Nierozliczony' : 'Nieczytelny'} claim ${name}; zachowaj stan.`);
690
+ const lockMtime = confirmed.get(suffix) ?? confirmed.get(suffix === '' ? '.pending' : '');
691
+ const minMtime = lockMtime === undefined ? runtime.now() - 600_000 : lockMtime - 60_000;
692
+ if (!(file.mtimeMs >= minMtime))
693
+ unsettledClaim(name);
694
+ busy ??= `claim ${name} czeka na rozliczenie przez takt`;
611
695
  }
612
- }
613
696
  }
697
+ busy = qualified ?? busy;
614
698
  for (const name of ['.tick.lock', '.factory-run.lock']) {
615
699
  const path = join(state, name);
616
700
  try {
@@ -631,7 +715,7 @@ export async function runInstallationUpdate(ctx, options, overrides = {}) {
631
715
  refuse(`Nieustalony stan blokady ${name}; zachowaj stan.`);
632
716
  }
633
717
  }
634
- const processReason = processBusy();
718
+ const processReason = scan().busy;
635
719
  busy ??= processReason;
636
720
  if (host) {
637
721
  const report = stat(lastTick);
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.6.15 \u2014 plik zarz\u0105dzany przez `npx robisie`; `npx robisie uninstall` go usunie -->";
20
+ export declare const MANAGED_LINE = "<!-- robisie:managed 0.7.1 \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.6.15) <!-- x-release-please-version -->
1
+ # robisie — from account to accepted card (package 0.7.1) <!-- 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.6.15) <!-- x-release-please-version -->
1
+ # robisie — od konta do odebranej karty (paczka 0.7.1) <!-- 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.6.15",
3
+ "version": "0.7.1",
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",