robisie 0.6.7 → 0.6.9

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,21 @@
1
1
  # Historia zmian klienta / Client changelog
2
2
 
3
+ ## [0.6.9](https://github.com/chuppa12/robisie-app/compare/client-v0.6.8...client-v0.6.9) (2026-11-19)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **maszynista:** linia compound_learning w raporcie Workera przyjmuje wcięcie, znacznik listy i kropkę ([b1a5beb](https://github.com/chuppa12/robisie-app/commit/b1a5beb626e10c5447679f2b3d6dc7f7529ec33d))
9
+
10
+ ## [0.6.8](https://github.com/chuppa12/robisie-app/compare/client-v0.6.7...client-v0.6.8) (2026-11-19)
11
+
12
+
13
+ ### Factory Cards
14
+
15
+ * Fabryka sama wstaje po zabitym takcie: gdy blokada factory run należy do martwego procesu albo powstała przed startem Maca, nadzorca przejmuje ją z wpisem w logu zamiast kończyć się kodem 2 i czekać na rękę ([422529d](https://github.com/chuppa12/robisie-app/commit/422529da24965e31b1be0922023cfe5e58a32793))
16
+ * praca workera task-mwmgmfgb-wfcimd (auto-commit) ([244d1a9](https://github.com/chuppa12/robisie-app/commit/244d1a9c591eab988c4f7534eac6cd6e3c75ba89))
17
+ * praca workera task-mwmiangd-zjzjou (auto-commit) ([c3b1c42](https://github.com/chuppa12/robisie-app/commit/c3b1c422bfefa8a8b41f56404a8e4d089c8e2175))
18
+
3
19
  ## [0.6.7](https://github.com/chuppa12/robisie-app/compare/client-v0.6.6...client-v0.6.7) (2026-11-18)
4
20
 
5
21
 
@@ -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.7";
3
+ export declare const PACKAGE_VERSION = "0.6.9";
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.7"; // x-release-please-version
3
+ export const PACKAGE_VERSION = "0.6.9"; // 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":"ecab7848938aefc2798695cefa13f0354f424afe","dirty":false}
1
+ {"schema":1,"sha":"62f5decaae109a865dd93e46dd28e272db9f429f","dirty":false}
@@ -1692,14 +1692,14 @@
1692
1692
  "staticOperations": {
1693
1693
  "beforePreflight": {
1694
1694
  "module": "maszynista/tick.ts",
1695
- "startLine": 10272,
1696
- "endLine": 10385,
1695
+ "startLine": 10276,
1696
+ "endLine": 10389,
1697
1697
  "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();"
1698
1698
  },
1699
1699
  "finalization": {
1700
1700
  "module": "maszynista/tick.ts",
1701
- "startLine": 10676,
1702
- "endLine": 10728,
1701
+ "startLine": 10680,
1702
+ "endLine": 10732,
1703
1703
  "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] ?? \"\"))) {"
1704
1704
  },
1705
1705
  "refreshTickReport": {
@@ -1725,6 +1725,6 @@
1725
1725
  "status": 0,
1726
1726
  "signal": null,
1727
1727
  "stdout": "v24.3.0\n",
1728
- "stderr": "(node:24538) 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"
1728
+ "stderr": "(node:24501) 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"
1729
1729
  }
1730
1730
  }
@@ -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.7";
37655
+ PACKAGE_VERSION = "0.6.9";
37656
37656
  SUPPORTED_CONTRACT_MAJOR = 1;
37657
37657
  DEFAULT_ORIGIN = "https://robisie.app";
37658
37658
  MCP_SERVER_NAME = "robisie";
@@ -317293,6 +317293,7 @@ __export2(tick_exports, {
317293
317293
  flushReviewGrantDiagnostics: () => flushReviewGrantDiagnostics,
317294
317294
  handleCiNoChecksAlarm: () => handleCiNoChecksAlarm,
317295
317295
  handleDiskPressure: () => handleDiskPressure,
317296
+ hasCompoundLearningLine: () => hasCompoundLearningLine,
317296
317297
  hostActivationAlarm: () => hostActivationAlarm,
317297
317298
  hostStateDir: () => hostStateDir,
317298
317299
  infrastructureChecks: () => infrastructureChecks,
@@ -323055,6 +323056,9 @@ function workerIdentity(meta4, client = engineClient()) {
323055
323056
  ...typeof meta4.provider === "string" && meta4.provider.trim() ? { provider: meta4.provider } : !client && meta4.backend === "codex" ? { provider: "openai" } : {}
323056
323057
  };
323057
323058
  }
323059
+ function hasCompoundLearningLine(report) {
323060
+ return /^[ \t]*(?:[-*][ \t]*)?compound_learning:[ \t]*(?:zero|one|attempted_unavailable)\.?[ \t]*$/im.test(report);
323061
+ }
323058
323062
  async function consumeActive(s, uid, a = s.actives[0], landing = { available: true }, bootAt, installation = tickInstallation) {
323059
323063
  if (!a) return false;
323060
323064
  const diagnostic = (phase, reason) => {
@@ -323476,7 +323480,7 @@ async function consumeActive(s, uid, a = s.actives[0], landing = { available: tr
323476
323480
  if (openCodeJob && outcome.status === "UNKNOWN" && !atCapacity) {
323477
323481
  return holdOpenCode("opencode-report-hold", `raport ${outcome.status}; bez retry i WORKER_FINISHED`);
323478
323482
  }
323479
- if (!atCapacity && openCodeResult?.status === "completed" && !/^[-*]?\s*compound_learning:\s*(zero|one|attempted_unavailable)\s*$/im.test(outcome.report)) {
323483
+ if (!atCapacity && openCodeResult?.status === "completed" && !hasCompoundLearningLine(outcome.report)) {
323480
323484
  return holdOpenCode("opencode-learning-hold", "brak compound_learning; uzupe\u0142nij przez tego samego Workera");
323481
323485
  }
323482
323486
  if (outcome.status === "WORKER_FINISHED" || outcome.status === "ALREADY_DONE") {
@@ -328915,6 +328919,7 @@ init_tick();
328915
328919
  flushReviewGrantDiagnostics,
328916
328920
  handleCiNoChecksAlarm,
328917
328921
  handleDiskPressure,
328922
+ hasCompoundLearningLine,
328918
328923
  hostActivationAlarm,
328919
328924
  hostStateDir,
328920
328925
  infrastructureChecks,
@@ -11,6 +11,8 @@ export interface FactoryRuntime {
11
11
  kill: typeof process.kill;
12
12
  signals: Pick<NodeJS.Process, "on" | "off">;
13
13
  sleep: (ms: number, signal: AbortSignal) => Promise<void>;
14
+ now?: () => number;
15
+ uptime?: () => number;
14
16
  nodeVersion: string;
15
17
  moduleUrl: string;
16
18
  }
@@ -1,7 +1,7 @@
1
1
  import { spawn } from "node:child_process";
2
2
  import { randomUUID } from "node:crypto";
3
- import { closeSync, fstatSync, lstatSync, mkdirSync, openSync, readFileSync, realpathSync, statSync, unlinkSync, writeFileSync } from "node:fs";
4
- import { constants } from "node:os";
3
+ import { closeSync, constants as fsConstants, fstatSync, linkSync, lstatSync, mkdirSync, mkdtempSync, openSync, readFileSync, readSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, utimesSync, writeFileSync, } from "node:fs";
4
+ import { constants, uptime } from "node:os";
5
5
  import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
6
6
  import { fileURLToPath } from "node:url";
7
7
  import { RobisieError } from "./context.js";
@@ -18,6 +18,181 @@ function sleep(ms, signal) {
18
18
  function errorCode(error) {
19
19
  return typeof error === "object" && error !== null && "code" in error ? error.code : undefined;
20
20
  }
21
+ function sameLock(left, right) {
22
+ return right.isFile() && left.dev === right.dev && left.ino === right.ino
23
+ && left.mtimeMs === right.mtimeMs && left.size === right.size;
24
+ }
25
+ function readSupervisorLock(path) {
26
+ try {
27
+ const stat = lstatSync(path);
28
+ // At most 16 PID digits, a space, 36 UUID characters and LF.
29
+ if (!stat.isFile() || stat.size > 54)
30
+ return null;
31
+ const fd = openSync(path, fsConstants.O_RDONLY | fsConstants.O_NOFOLLOW | fsConstants.O_NONBLOCK);
32
+ try {
33
+ if (!sameLock(stat, fstatSync(fd)))
34
+ return null;
35
+ const bytes = Buffer.alloc(stat.size + 1);
36
+ if (readSync(fd, bytes) !== stat.size || !sameLock(stat, fstatSync(fd)) || !sameLock(stat, lstatSync(path)))
37
+ return null;
38
+ return { stat, bytes: bytes.subarray(0, stat.size) };
39
+ }
40
+ finally {
41
+ closeSync(fd);
42
+ }
43
+ }
44
+ catch (error) {
45
+ if (errorCode(error) === "ENOENT" || errorCode(error) === "ELOOP")
46
+ return null;
47
+ throw error;
48
+ }
49
+ }
50
+ function predatesBoot(mtime, runtime) {
51
+ try {
52
+ // Use the earlier wall-clock sample and allow for whole-second uptime precision.
53
+ const now = runtime.now ?? Date.now;
54
+ const start = now();
55
+ const elapsed = (runtime.uptime ?? uptime)() * 1000;
56
+ const end = now();
57
+ const lowerBound = start - elapsed - 1000;
58
+ return Number.isFinite(end) && end >= start && end - start <= 1000
59
+ && elapsed > 0 && lowerBound > 0 && mtime < lowerBound;
60
+ }
61
+ catch {
62
+ return false;
63
+ }
64
+ }
65
+ function isDead(pid, runtime) {
66
+ try {
67
+ runtime.kill(pid, 0);
68
+ return false;
69
+ }
70
+ catch (error) {
71
+ return errorCode(error) === "ESRCH";
72
+ }
73
+ }
74
+ function openSupervisorLock(path) {
75
+ try {
76
+ return openSync(path, "wx", 0o600);
77
+ }
78
+ catch (error) {
79
+ if (errorCode(error) === "EEXIST")
80
+ return null;
81
+ throw error;
82
+ }
83
+ }
84
+ function staleOwner(lock, runtime) {
85
+ const token = lock.bytes.toString("utf8");
86
+ const match = /^([1-9]\d*) ([\da-f]{8}-[\da-f]{4}-[1-8][\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12})\n$/i.exec(token);
87
+ if (!match || match[0] !== token)
88
+ return null;
89
+ const pid = Number(match[1]);
90
+ if (!Number.isSafeInteger(pid) || (!predatesBoot(lock.stat.mtimeMs, runtime) && !isDead(pid, runtime)))
91
+ return null;
92
+ return { pid, uuid: match[2] };
93
+ }
94
+ function linkExclusive(from, to) {
95
+ try {
96
+ linkSync(from, to);
97
+ return true;
98
+ }
99
+ catch (error) {
100
+ if (errorCode(error) === "EEXIST")
101
+ return false;
102
+ throw error;
103
+ }
104
+ }
105
+ function claimRecovery(directory, preparedOwner, runtime) {
106
+ // Leave dead claims in place. All contenders for a dead owner must claim
107
+ // the same next slot, so a delayed contender cannot unlink a new owner's claim.
108
+ for (let attempt = 0;; attempt++) {
109
+ const path = join(directory, `owner-${attempt}`);
110
+ const owner = readSupervisorLock(path);
111
+ if (!owner)
112
+ return linkExclusive(preparedOwner, path) ? path : null;
113
+ if (!staleOwner(owner, runtime))
114
+ return null;
115
+ }
116
+ }
117
+ function archiveStaleLock(path, runtime) {
118
+ const old = readSupervisorLock(path);
119
+ if (!old)
120
+ return null;
121
+ const owner = staleOwner(old, runtime);
122
+ if (!owner)
123
+ return null;
124
+ const archive = `${path}.stale-${old.stat.mtimeMs}`;
125
+ const directory = `${archive}.recovery-${old.stat.dev}-${old.stat.ino}-${owner.uuid}`;
126
+ const snapshot = join(directory, "snapshot");
127
+ const matches = (file, candidate) => {
128
+ const current = readSupervisorLock(candidate);
129
+ return current !== null && sameLock(file.stat, current.stat) && file.bytes.equals(current.bytes);
130
+ };
131
+ try {
132
+ if (!matches(old, path))
133
+ return null;
134
+ // An archive without a matching transaction has unknown ownership.
135
+ if (!lstatSync(directory, { throwIfNoEntry: false }) && lstatSync(archive, { throwIfNoEntry: false }))
136
+ return null;
137
+ try {
138
+ mkdirSync(directory, { mode: 0o700 });
139
+ }
140
+ catch (error) {
141
+ if (errorCode(error) !== "EEXIST")
142
+ throw error;
143
+ }
144
+ if (!lstatSync(directory).isDirectory())
145
+ return null;
146
+ const stage = mkdtempSync(join(directory, "attempt-"));
147
+ try {
148
+ const preparedOwner = join(stage, "owner");
149
+ writeFileSync(preparedOwner, `${process.pid} ${randomUUID()}\n`, { flag: "wx", mode: 0o600 });
150
+ const claim = claimRecovery(directory, preparedOwner, runtime);
151
+ if (!claim)
152
+ return null;
153
+ let removed = false;
154
+ try {
155
+ if (!matches(old, path))
156
+ return null;
157
+ if (!lstatSync(snapshot, { throwIfNoEntry: false })) {
158
+ const preparedSnapshot = join(stage, "snapshot");
159
+ writeFileSync(preparedSnapshot, old.bytes, { flag: "wx", mode: 0o600 });
160
+ utimesSync(preparedSnapshot, old.stat.atimeMs / 1000, old.stat.mtimeMs / 1000);
161
+ if (!linkExclusive(preparedSnapshot, snapshot))
162
+ return null;
163
+ }
164
+ const preserved = readSupervisorLock(snapshot);
165
+ if (!preserved || (old.stat.dev === preserved.stat.dev && old.stat.ino === preserved.stat.ino)
166
+ || !old.bytes.equals(preserved.bytes))
167
+ return null;
168
+ linkExclusive(snapshot, archive);
169
+ // The archive must be this transaction's snapshot, including on retry.
170
+ if (!matches(preserved, archive) || !matches(old, path))
171
+ return null;
172
+ unlinkSync(path);
173
+ removed = true;
174
+ // Detach the directory before recursive cleanup. A contender may still
175
+ // be staging a claim and must not race the removal of these names.
176
+ const retired = `${directory}.retired-${randomUUID()}`;
177
+ renameSync(directory, retired);
178
+ rmSync(retired, { recursive: true, force: true });
179
+ }
180
+ finally {
181
+ if (!removed)
182
+ rmSync(claim, { force: true });
183
+ }
184
+ }
185
+ finally {
186
+ rmSync(stage, { recursive: true, force: true });
187
+ }
188
+ }
189
+ catch (error) {
190
+ if (errorCode(error) === "ENOENT")
191
+ return null;
192
+ throw error;
193
+ }
194
+ return { pid: owner.pid, mtime: old.stat.mtime.toISOString(), archive };
195
+ }
21
196
  /** A dangling symlink is an error, not a nonexistent ancestor we may create through. */
22
197
  function physical(path) {
23
198
  try {
@@ -175,14 +350,14 @@ export async function runFactory(ctx, options, overrides = {}) {
175
350
  checkInstallation();
176
351
  const lockPath = join(state, ".factory-run.lock");
177
352
  const lockStep = `Potwierdź, że poprzedni nadzorca i jego takt nie działają; dopiero wtedy usuń blokadę „${lockPath}” i ponów polecenie.`;
178
- let fd;
179
- try {
180
- fd = openSync(lockPath, "wx", 0o600);
181
- }
182
- catch (error) {
183
- if (errorCode(error) === "EEXIST")
353
+ let fd = openSupervisorLock(lockPath);
354
+ let reclaimed = null;
355
+ if (fd === null) {
356
+ reclaimed = archiveStaleLock(lockPath, runtime);
357
+ if (reclaimed)
358
+ fd = openSupervisorLock(lockPath);
359
+ if (fd === null)
184
360
  fail(2, "Blokada factory run już istnieje.", lockStep);
185
- throw error;
186
361
  }
187
362
  try {
188
363
  lock = { path: lockPath, stat: fstatSync(fd), token: `${process.pid} ${randomUUID()}\n` };
@@ -191,6 +366,8 @@ export async function runFactory(ctx, options, overrides = {}) {
191
366
  finally {
192
367
  closeSync(fd);
193
368
  }
369
+ if (reclaimed)
370
+ ctx.out(`Przejęto martwą blokadę factory run: pid=${reclaimed.pid} mtime=${reclaimed.mtime} archive=${reclaimed.archive}.`);
194
371
  while (!stopSignal) {
195
372
  checkInstallation();
196
373
  if (stopSignal)
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.7 \u2014 plik zarz\u0105dzany przez `npx robisie`; `npx robisie uninstall` go usunie -->";
20
+ export declare const MANAGED_LINE = "<!-- robisie:managed 0.6.9 \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.7) <!-- x-release-please-version -->
1
+ # robisie — from account to accepted card (package 0.6.9) <!-- 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.7) <!-- x-release-please-version -->
1
+ # robisie — od konta do odebranej karty (paczka 0.6.9) <!-- 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.7",
3
+ "version": "0.6.9",
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",