gcf-harness-aif-ext 0.9.9 → 0.9.10

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/README.md CHANGED
@@ -47,6 +47,8 @@ Updating keeps the hook entry valid — it points into the extension's install d
47
47
 
48
48
  0.5.1 is a fix release. During a run, `gcf/config.yml` is always readable, and a Grep inside `gcf/` reads only readset files. An import breaks a `depends:` cycle the pair checks closed and asks a D1 about it. It cuts a section longer than a segment at paragraphs, and lens and pair prompts carry a window around the quote. `/gcf-run` checks the plan against each pillar's invariant and asks each pillar's review question over the diff. Use it with core 0.4.1, which brings the parent feature into the readset.
49
49
 
50
+ 0.9.10 makes a main run's session marks its own (with core 0.10.2): the run sets `GCF_RUN_OWNER=run:<pid>`, its core calls and every agent session it starts (a fresh one after a handoff too) inherit it, and the core refuses the mark to anyone else. An item another session has claimed is refused with `worked by another agent session`. `/gcf-run` reports a refused claim and goes on with the next item; it never releases another session's mark, and neither does the run (`gcf-harness stop` still does: that is the human's). The readset-guard hook keeps only its own session's marks fresh (and marks that name nobody), so another session's mark expires when that session stops.
51
+
50
52
  0.9.9 changes no code: its peer range adds core 0.10.0, whose board read is schema 3 and names this harness as the domain's runner (the harness reads neither).
51
53
 
52
54
  0.9.8 changes no code: its peer range adds core 0.9.0, whose board read is schema 2 (the harness does not read it).
package/commands/run.js CHANGED
@@ -1192,6 +1192,9 @@ export const MAIN_RUN = '.main-run';
1192
1192
  */
1193
1193
  async function runMain(projectDir, ids, ctx) {
1194
1194
  const { logs } = ctx;
1195
+ // The owner of the items' marks: this run's core calls and every agent session it starts
1196
+ // (a fresh one after a handoff included) inherit it, so their `gcf claim` and moves pass.
1197
+ process.env.GCF_RUN_OWNER = `run:${process.pid}`;
1195
1198
  const releaseMain = await claim(logs, MAIN_RUN);
1196
1199
  if (!releaseMain)
1197
1200
  return ids.map((id) => ({
@@ -1216,6 +1219,7 @@ async function mainItem(projectDir, id, ctx) {
1216
1219
  const { core, logs, agentOf } = ctx;
1217
1220
  let r;
1218
1221
  let started = false;
1222
+ let marked = false;
1219
1223
  const head = headOf(projectDir);
1220
1224
  await rm(stopOf(logs, id), { force: true });
1221
1225
  // The checkout's lock names the item from now on: a stop before its session marks it.
@@ -1223,6 +1227,7 @@ async function mainItem(projectDir, id, ctx) {
1223
1227
  try {
1224
1228
  const claimed = await core(['claim', id]);
1225
1229
  if (!claimed.ok) throw new Error((claimed.err || claimed.out).trim());
1230
+ marked = true;
1226
1231
  const none = async () => {};
1227
1232
 
1228
1233
  // The agent recorded the item's move: no fresh session takes it over.
@@ -1253,7 +1258,8 @@ async function mainItem(projectDir, id, ctx) {
1253
1258
  r = { id, error: e.message };
1254
1259
  }
1255
1260
 
1256
- await core(['release', id]);
1261
+ // A refused claim leaves the mark alone: it is another session's.
1262
+ if (marked) await core(['release', id]);
1257
1263
  if (r.handoffLimit) await core(['block', id, '--reason', HANDOFF_LIMIT]);
1258
1264
  const item = await mainResult(core, r);
1259
1265
  await remember(logs, r, item);
package/extension.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/lee-to/ai-factory/2.x/schemas/extension.schema.json",
3
3
  "name": "gcf-harness-aif-ext",
4
- "version": "0.9.9",
4
+ "version": "0.9.10",
5
5
  "description": "GCF orchestration harness for Claude Code: one-command card pipeline, readset guard",
6
6
  "skills": [
7
7
  "skills/gcf-run",
@@ -122,16 +122,19 @@ const SESSION_TTL_MS = 120 * 60_000;
122
122
  /**
123
123
  * Keep the running marks of this checkout fresh (`gcf claim`): an agent reading files is a
124
124
  * session at work, even through a long stage with no gcf command. A mark already expired stays
125
- * expired: a session that stopped is not revived. Best effort, never in the way of the read.
126
- * shortcut: it refreshes every live mark of the checkout, not only this session's; one agent
127
- * works a main checkout at a time, so that is the same mark — key marks by session when two do.
125
+ * expired: a session that stopped is not revived. Only this session's marks, and marks that
126
+ * name no owner, are refreshed: another session's mark expires when that one stops. `owner` is
127
+ * the core's (lib/session-mark.js ownerOf), the hook input's `session_id` as the last resort.
128
+ * Best effort, never in the way of the read.
128
129
  */
129
- export function keepSessionsAlive(projectDir, now = Date.now()) {
130
+ export function keepSessionsAlive(projectDir, owner, now = Date.now()) {
130
131
  const runs = path.join(projectDir, '.gcf-session', 'runs');
131
132
  try {
132
133
  for (const name of readdirSync(runs).filter((n) => n.endsWith('.session'))) {
133
134
  const file = path.join(runs, name);
134
- if (now - statSync(file).mtimeMs < SESSION_TTL_MS) utimesSync(file, now / 1000, now / 1000);
135
+ if (now - statSync(file).mtimeMs >= SESSION_TTL_MS) continue;
136
+ const held = readFileSync(file, 'utf8').split('\n')[1]?.trim();
137
+ if (!held || held === owner) utimesSync(file, now / 1000, now / 1000);
135
138
  }
136
139
  } catch {
137
140
  // No runs directory, or a mark released meanwhile.
@@ -145,7 +148,11 @@ if (import.meta.url === `file://${entry}` || entry?.endsWith('readset-guard.js')
145
148
  // The directory the session started in: `cwd` follows a `cd` of the agent, and a manifest
146
149
  // not found there would allow every read.
147
150
  const projectDir = process.env.CLAUDE_PROJECT_DIR ?? input?.cwd ?? process.cwd();
148
- keepSessionsAlive(projectDir);
151
+ const env = process.env;
152
+ keepSessionsAlive(
153
+ projectDir,
154
+ env.GCF_RUN_OWNER || env.CLAUDE_CODE_SESSION_ID || input?.session_id || null,
155
+ );
149
156
  const manifest = readManifest(projectDir);
150
157
  const verdict = decide(input, projectDir, manifest);
151
158
  if (!verdict.allow) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gcf-harness-aif-ext",
3
- "version": "0.9.9",
3
+ "version": "0.9.10",
4
4
  "description": "GCF orchestration harness for Claude Code: one-command card pipeline, readset guard",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -10,6 +10,7 @@ purpose:
10
10
  - end every item in a state the core records: `submit` (waits for the human), `close` (gate auto, done) or `block` (needs the human)
11
11
  - outside `--worktree`, mark each item running after its gate passes: `ai-factory gcf claim <id>`; a move clears the mark, and an item left without one gets `ai-factory gcf release <id>`
12
12
  - a claimed item takes only its session's moves: run `submit`, `close` and `block` on it with `--claimed`
13
+ - a refused claim means another session works the item: report that item as taken and go on with the next; never `release` it, that is the human's call
13
14
 
14
15
  inputs:
15
16
  - 1 or more work item or design unit ids; a batch shares one playtest list and one play session, while each item's `gcf verify` runs the build and the tests itself