trantor 0.18.125 → 0.18.126
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/.claude-plugin/plugin.json +1 -1
- package/bin/crew-runner.mjs +29 -5
- package/bin/sync.mjs +7 -5
- package/lib/harvest.mjs +3 -1
- package/lib/seat-worktree.mjs +23 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trantor",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.126",
|
|
4
4
|
"description": "Trantor — the hub-world for AI agent crews: live message bus, presence, project Kanban/flow board + crew orchestration for independent AI coding agents (Claude, Codex, Gemini, Kimi, DeepSeek)",
|
|
5
5
|
"mcpServers": {
|
|
6
6
|
"relay": {
|
package/bin/crew-runner.mjs
CHANGED
|
@@ -14,7 +14,7 @@ import { signedHeaders } from "../lib/signed-fetch.mjs";
|
|
|
14
14
|
import { ensureEnrolled } from "../lib/enroll.mjs";
|
|
15
15
|
import { redactKeys } from "../lib/redact.mjs";
|
|
16
16
|
import { writeTurnState } from "../lib/turnstate.mjs";
|
|
17
|
-
import { applyWorktreeDeclaration, ensureSeatWorktree, provisioningLines, readWorktreeDeclaration } from "../lib/seat-worktree.mjs";
|
|
17
|
+
import { alignSeatWorktree, applyWorktreeDeclaration, ensureSeatWorktree, provisioningLines, readWorktreeDeclaration } from "../lib/seat-worktree.mjs";
|
|
18
18
|
import {
|
|
19
19
|
AUTH_MARKER_RE, classifyFailure, looksLikeAuthDeath,
|
|
20
20
|
verdictFor, substantiveOutput, stallVerdict, cutSignalFor,
|
|
@@ -118,9 +118,12 @@ function seatWorktree(sourceDir) {
|
|
|
118
118
|
|
|
119
119
|
const TURN_DIR = seatWorktree(DIR);
|
|
120
120
|
|
|
121
|
-
// #
|
|
122
|
-
//
|
|
123
|
-
const
|
|
121
|
+
// #13921: an explicit contract base wins; without one, fetch the current origin/main instead of
|
|
122
|
+
// trusting a cached local ref from when this seat worktree was created.
|
|
123
|
+
const originMainHead = () => {
|
|
124
|
+
spawnSync("git", ["fetch", "-q", "origin", "+refs/heads/main:refs/remotes/origin/main"], { cwd: TURN_DIR, stdio: "ignore", timeout: 20000 });
|
|
125
|
+
return gitOut(["rev-parse", "--verify", "--quiet", "refs/remotes/origin/main^{commit}"], TURN_DIR);
|
|
126
|
+
};
|
|
124
127
|
const resolvesHere = (sha) =>
|
|
125
128
|
spawnSync("git", ["cat-file", "-e", `${sha}^{commit}`], { cwd: TURN_DIR, stdio: "ignore", timeout: 8000 }).status === 0;
|
|
126
129
|
|
|
@@ -1516,6 +1519,11 @@ async function resolveWakeCard(messages, { session }) {
|
|
|
1516
1519
|
signal: AbortSignal.timeout(2500),
|
|
1517
1520
|
});
|
|
1518
1521
|
} catch {}
|
|
1522
|
+
if (releaseState) {
|
|
1523
|
+
const since = Date.now();
|
|
1524
|
+
writeTurnState(PERSONA, PROJ, { phase: "idle", since });
|
|
1525
|
+
await registerStatus("idle", { phase: "idle", phaseSince: since });
|
|
1526
|
+
}
|
|
1519
1527
|
|
|
1520
1528
|
// Wake messages this seat has PULLED off the bus but not yet worked successfully, plus the
|
|
1521
1529
|
// broadcasts batched behind them. Restored from disk first: a runner that was killed mid-turn
|
|
@@ -1873,7 +1881,8 @@ async function resolveWakeCard(messages, { session }) {
|
|
|
1873
1881
|
// served contract cites: #7763's rebinding covers confirmed message-card ids only, never a
|
|
1874
1882
|
// card cited in the text, so the unresolvable-base branch blocks the cited card.
|
|
1875
1883
|
const baseCard = card || servedContractCard(wakeForTurn, { session: SESSION });
|
|
1876
|
-
const
|
|
1884
|
+
const statedBase = contractBase(wakeForTurn);
|
|
1885
|
+
const base = statedBase || originMainHead();
|
|
1877
1886
|
if (base && baseCard && !resolvesHere(base)) {
|
|
1878
1887
|
const text = `cannot resolve base ${base} in ${TURN_DIR} (git cat-file -e failed) — #${baseCard} moved to blocked; push or fetch that sha, or name one this worktree can reach`;
|
|
1879
1888
|
log(text);
|
|
@@ -1885,6 +1894,21 @@ async function resolveWakeCard(messages, { session }) {
|
|
|
1885
1894
|
savePending([], pendingBcast);
|
|
1886
1895
|
return;
|
|
1887
1896
|
}
|
|
1897
|
+
if (base && TURN_DIR !== DIR && card && gitOut(["rev-parse", "--abbrev-ref", "HEAD"], TURN_DIR) === `seat/${PERSONA}`) {
|
|
1898
|
+
const aligned = alignSeatWorktree({ dir: TURN_DIR, project: PROJ, agent: PERSONA, base });
|
|
1899
|
+
if (!aligned.ok) {
|
|
1900
|
+
const text = `cannot align seat worktree for #${card}: ${aligned.reason}`;
|
|
1901
|
+
log(text);
|
|
1902
|
+
await api("/task/update", { id: card, status: "blocked", note: text, by: SESSION }).catch(() => {});
|
|
1903
|
+
const owed = assigners.map(a => a.from).filter(f => f && f !== SESSION);
|
|
1904
|
+
for (const to of (owed.length ? owed : ["all"]))
|
|
1905
|
+
await api("/send", { from: SESSION, to, text, project: PROJ, kind: "alert" }).catch(() => {});
|
|
1906
|
+
pendingWake = [];
|
|
1907
|
+
savePending([], pendingBcast);
|
|
1908
|
+
return;
|
|
1909
|
+
}
|
|
1910
|
+
if (aligned.parked) log(`preserved unharvested work at ${aligned.parked} before aligning to ${base}`);
|
|
1911
|
+
}
|
|
1888
1912
|
const baseText = base ? `\n${baseLine(base)}\n` : "";
|
|
1889
1913
|
// #6289: the session SHAPE (fresh vs resume) reads the served contract's raw citation — a wake
|
|
1890
1914
|
// whose card the board lacks still opens fresh, never a bare resume of the kickoff's CLI.
|
package/bin/sync.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// `trantor sync [<seat>]` (#7748): realign a seat branch with main from the harvest receipts.
|
|
3
|
-
//
|
|
3
|
+
// Commits absent from main must have a receipt or an equivalent patch on main; otherwise sync refuses.
|
|
4
4
|
import { existsSync } from "node:fs";
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { resolveProject, busDir } from "../lib/project.mjs";
|
|
@@ -27,15 +27,17 @@ const short = (s) => String(s || "").slice(0, 7);
|
|
|
27
27
|
if (r.refused) {
|
|
28
28
|
console.log(`${RED}sync refused${R} · ${r.branch} carries ${r.unharvested.length} commit(s) ${r.target.ref} does not, with no harvest receipt:`);
|
|
29
29
|
for (const c of r.unharvested) console.log(` ${short(c.sha)} ${c.subject}`);
|
|
30
|
-
if (r.harvested.length) console.log(`${D}${r.harvested.length} other commit(s) are
|
|
30
|
+
if (r.harvested.length) console.log(`${D}${r.harvested.length} other commit(s) are already harvested and would be dropped once these are.${R}`);
|
|
31
31
|
console.log(`${D}Harvest them (trantor harvest <seat-sha> <main-sha> --card N) or park them on another branch first. Receipts: ${receiptsPath(project)}${R}`);
|
|
32
32
|
process.exit(1);
|
|
33
33
|
}
|
|
34
34
|
if (!r.ok) { console.error(`${RED}sync failed${R}: ${r.reason}`); process.exit(1); }
|
|
35
35
|
if (r.noop) { console.log(`${D}${r.branch} already at ${r.target.ref} (${short(r.head)})${R}`); process.exit(0); }
|
|
36
|
-
const dropped = r.harvested.map(c =>
|
|
36
|
+
const dropped = r.harvested.map(c => c.receipt
|
|
37
|
+
? `${short(c.sha)}→${short(c.receipt.main)}`
|
|
38
|
+
: `${short(c.sha)} (patch already in target)`).join(", ");
|
|
37
39
|
if (r.dry) {
|
|
38
|
-
console.log(`${Y}[dry]${R} would move ${r.branch} ${short(r.head)} → ${r.target.ref} ${short(r.target.sha)}${dropped ? ` ${D}(
|
|
40
|
+
console.log(`${Y}[dry]${R} would move ${r.branch} ${short(r.head)} → ${r.target.ref} ${short(r.target.sha)}${dropped ? ` ${D}(harvested: ${dropped})${R}` : ""}`);
|
|
39
41
|
process.exit(0);
|
|
40
42
|
}
|
|
41
|
-
console.log(`${G}synced${R} ${r.branch} ${short(r.from)} → ${r.target.ref} ${short(r.to)}${dropped ? ` ${D}(
|
|
43
|
+
console.log(`${G}synced${R} ${r.branch} ${short(r.from)} → ${r.target.ref} ${short(r.to)}${dropped ? ` ${D}(harvested: ${dropped})${R}` : ""}`);
|
package/lib/harvest.mjs
CHANGED
|
@@ -64,12 +64,14 @@ export function syncTarget(dir, base) {
|
|
|
64
64
|
// Every commit the seat branch carries that the target does not, split by whether a receipt covers it.
|
|
65
65
|
export function auditSeat(dir, { branch, targetRef, receipts }) {
|
|
66
66
|
const log = out(dir, ["log", "--reverse", "--format=%H%x09%s", `${targetRef}..${branch}`]);
|
|
67
|
+
const cherry = out(dir, ["cherry", targetRef, branch]);
|
|
68
|
+
const equivalent = new Set(cherry.split("\n").filter(line => line.startsWith("- ")).map(line => line.slice(2).trim()));
|
|
67
69
|
const harvested = [], unharvested = [];
|
|
68
70
|
for (const line of log.split("\n").filter(Boolean)) {
|
|
69
71
|
const [sha, ...rest] = line.split("\t");
|
|
70
72
|
const subject = rest.join("\t");
|
|
71
73
|
const receipt = receipts.find(r => shaMatches(r.seat, sha));
|
|
72
|
-
(receipt ? harvested : unharvested).push({ sha, subject, receipt });
|
|
74
|
+
(receipt || equivalent.has(sha) ? harvested : unharvested).push({ sha, subject, receipt });
|
|
73
75
|
}
|
|
74
76
|
return { harvested, unharvested };
|
|
75
77
|
}
|
package/lib/seat-worktree.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
} from "node:fs";
|
|
7
7
|
import { homedir } from "node:os";
|
|
8
8
|
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
9
|
+
import { auditSeat, readReceipts } from "./harvest.mjs";
|
|
9
10
|
|
|
10
11
|
export const DECLARATION_PATH = join(".trantor", "worktree.json");
|
|
11
12
|
export const PREFLIGHT_CAP_MS = 5 * 60 * 1000;
|
|
@@ -24,6 +25,28 @@ function gitOut(args, cwd) {
|
|
|
24
25
|
return r.status === 0 ? String(r.stdout || "").trim() : "";
|
|
25
26
|
}
|
|
26
27
|
|
|
28
|
+
// Start a new contract from its pinned base only when the previous branch has no unharvested work.
|
|
29
|
+
// Refusing keeps the branch tip reachable and gives the orchestrator a clear reason to harvest it.
|
|
30
|
+
export function alignSeatWorktree({ dir, project, agent, base, receiptsRoot }) {
|
|
31
|
+
const branch = gitOut(["rev-parse", "--abbrev-ref", "HEAD"], dir);
|
|
32
|
+
const expected = `seat/${agent}`;
|
|
33
|
+
if (branch !== expected) return { ok: false, reason: `refusing to align ${dir}: expected ${expected}, found ${branch || "detached HEAD"}` };
|
|
34
|
+
if (!/^[0-9a-f]{7,40}$/i.test(String(base || "")) ||
|
|
35
|
+
spawnSync("git", ["cat-file", "-e", `${base}^{commit}`], { cwd: dir, stdio: "ignore", timeout: 8000 }).status !== 0)
|
|
36
|
+
return { ok: false, reason: `base ${base || "(missing)"} is not a commit in ${dir}` };
|
|
37
|
+
if (gitOut(["status", "--porcelain"], dir)) return { ok: false, reason: `refusing to reset dirty seat worktree ${dir}` };
|
|
38
|
+
|
|
39
|
+
const receipts = readReceipts(project, receiptsRoot);
|
|
40
|
+
const audit = auditSeat(dir, { branch, targetRef: base, receipts });
|
|
41
|
+
if (audit.unharvested.length) {
|
|
42
|
+
const commits = audit.unharvested.map(c => `${c.sha.slice(0, 7)} (${c.subject})`).join(", ");
|
|
43
|
+
return { ok: false, reason: `refusing to move ${branch}: ${audit.unharvested.length} unharvested commit(s) would be lost: ${commits}` };
|
|
44
|
+
}
|
|
45
|
+
const reset = spawnSync("git", ["reset", "--hard", base], { cwd: dir, encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], timeout: 15000 });
|
|
46
|
+
if (reset.status !== 0) return { ok: false, reason: `could not align to ${base}: ${String(reset.stderr || reset.stdout || "git reset failed").trim()}` };
|
|
47
|
+
return { ok: true, to: gitOut(["rev-parse", "HEAD"], dir), parked: "" };
|
|
48
|
+
}
|
|
49
|
+
|
|
27
50
|
// Returns { dir, created }: dir is the seat worktree, or sourceDir when no worktree applies
|
|
28
51
|
// (non-git source, opt-out, or a creation failure — loud, never fatal: stale beats broken).
|
|
29
52
|
export function ensureSeatWorktree({ sourceDir, project, agent, home = homedir(), env = process.env, log = console.log }) {
|