@passioncode-ai/fabric-agent-adapter 0.55.0 → 0.57.0

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.
Files changed (59) hide show
  1. package/CHANGELOG.md +242 -0
  2. package/README.md +5 -4
  3. package/SECURITY.md +6 -5
  4. package/package.json +1 -1
  5. package/plugins/fabric-agent-adapter/.claude-plugin/plugin.json +1 -1
  6. package/plugins/fabric-agent-adapter/hooks/hooks.json +1 -1
  7. package/plugins/fabric-agent-adapter/skills/adapting-projects-to-fabric/SKILL.md +3 -3
  8. package/plugins/fabric-agent-adapter/skills/adapting-projects-to-fabric/references/provider-entry.md +18 -7
  9. package/plugins/fabric-agent-adapter/skills/adapting-projects-to-fabric/scripts/adapt_project.py +2 -2
  10. package/plugins/fabric-agent-adapter/skills/adapting-projects-to-fabric/scripts/fabric_provider.py +30 -6
  11. package/plugins/fabric-agent-adapter/skills/adapting-projects-to-fabric/scripts/fabric_secrets.py +73 -18
  12. package/plugins/fabric-agent-adapter/skills/building-fabric-services/SKILL.md +7 -6
  13. package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/board.md +70 -20
  14. package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/connectors.md +7 -1
  15. package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/delegation.md +12 -1
  16. package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/interop.md +19 -6
  17. package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/kit-modules.md +1 -0
  18. package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/lifecycle.md +1 -1
  19. package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/protocol.md +9 -4
  20. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric-actions.mjs +2 -1
  21. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric-board-link.mjs +16 -9
  22. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric-board-session.mjs +87 -156
  23. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric-board-slots.mjs +180 -0
  24. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric-board.mjs +1 -0
  25. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric-descriptor.mjs +4 -2
  26. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric-http.mjs +2 -0
  27. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric-interop-rules.mjs +15 -3
  28. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric-interop.mjs +2 -0
  29. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric-openrouter.mjs +12 -1
  30. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric-protocols.mjs +17 -4
  31. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_actions.py +2 -1
  32. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_board.py +1 -0
  33. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_board_link.py +32 -13
  34. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_board_session.py +115 -147
  35. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_board_slots.py +173 -0
  36. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_connections.py +9 -42
  37. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_delegation.py +53 -4
  38. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_descriptor.py +7 -3
  39. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_events.py +4 -2
  40. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_http.py +87 -11
  41. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_interop.py +19 -8
  42. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_interop_rules.py +30 -6
  43. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_openrouter.py +9 -1
  44. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_protocols.py +19 -3
  45. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_secrets.py +73 -18
  46. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_usage.py +1 -1
  47. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/kit.json +226 -26
  48. package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/sample_service.py +155 -21
  49. package/plugins/fabric-agent-adapter/skills/creating-fabric-agents/SKILL.md +3 -3
  50. package/plugins/fabric-agent-adapter/skills/creating-fabric-agents/references/agents-that-answer-people.md +11 -5
  51. package/plugins/fabric-agent-adapter/skills/working-with-fabric/SKILL.md +18 -18
  52. package/plugins/fabric-agent-adapter/skills/working-with-fabric/references/project-board.md +2 -1
  53. package/plugins/fabric-agent-adapter/skills/working-with-fabric/references/session-hooks.md +39 -13
  54. package/plugins/fabric-agent-adapter/skills/working-with-fabric/scripts/fabric_session.py +6 -2
  55. package/plugins/fabric-agent-adapter/skills/working-with-fabric/scripts/fabric_session_cli.py +17 -3
  56. package/plugins/fabric-agent-adapter/skills/working-with-fabric/scripts/fabric_session_env.py +23 -6
  57. package/plugins/fabric-agent-adapter/skills/working-with-fabric/scripts/fabric_session_mcp.py +10 -39
  58. package/plugins/fabric-agent-adapter/skills/working-with-fabric/scripts/fabric_session_paths.py +190 -0
  59. package/plugins/fabric-agent-adapter/skills/working-with-fabric/scripts/host_hooks.py +1 -1
@@ -13,7 +13,10 @@ once, and `sample.draft` is a job that stops for a titled choice before it compl
13
13
  Opt-in, off by default: `serve --board-project <Project uuid>` also answers that Project's `sample.echo` requests on
14
14
  Fabric's project board (fabric-project-comms/0.1, FAA-12b) with fabric_board.Responder, from a board.respond grant whose
15
15
  credential is in `<data>/board.credential` (0600; `--board-credential` names another file). The request body is data:
16
- the gate admits plain text of at most 2,000 characters, and the answer is a reply carrying the same text.
16
+ the gate admits plain text of at most 2,000 characters, and the answer is a reply carrying the same text. Its
17
+ dashboard's Take back has the tool `board.take-back`, which the manifest lists when registered with the same
18
+ `--board-project`; a serve whose board mode differs from the registered manifest at its start logs
19
+ `service.manifest.mismatch`.
17
20
  """
18
21
 
19
22
  from __future__ import annotations
@@ -52,8 +55,29 @@ PAGE = """<!doctype html><html lang="en"><head><meta charset="utf-8">
52
55
  <nav class="fd-nav" aria-label="Sections"><ul class="fd-nav-list"><li><a href="#events" aria-current="page">Events</a></li>
53
56
  <li><a href="#about">About</a></li></ul></nav></div>
54
57
  <main class="fd-page"><section id="events"><h2>Events</h2><ul>{rows}</ul></section>
55
- <section id="about"><h2>About</h2><p class="fd-hint">A sample fabric-service/0.1 service built on the kit.</p></section></main>
58
+ {board}<section id="about"><h2>About</h2><p class="fd-hint">A sample fabric-service/0.1 service built on the kit.</p></section></main>
56
59
  </body></html>"""
60
+ # FAA-157: a moved board slot comes back only by the operator's act, a button on this page. The button posts from the
61
+ # operator's signed-in dashboard session with the request header; a service token alone cannot reach it.
62
+ BOARD_SECTION = """<section id="board"><h2>Project board</h2><p class="fd-hint">These slots were moved to another
63
+ session; this service no longer answers them there. Take back asks for one again: the service enrolls once the other
64
+ session lets it go, or at once when it restarts with accepted work for the slot.</p><ul>{items}</ul>
65
+ <script src="/board.js" defer></script></section>"""
66
+ #: The dashboard's Take back button and its tool (FAA-157, DEC-0121): the operator's decision, relayed in `_meta`.
67
+ TAKE_BACK = {"id": "board.take-back", "title": "Take back", "tool": "board.take-back", "gate": "relayed"}
68
+ TAKE_BACK_INPUT = {"type": "object", "properties": {"capability": {"type": "string"}}, "required": ["capability"],
69
+ "additionalProperties": False}
70
+ BOARD_ITEM = '<li>{capability} <button type="button" data-take-back="{capability}">Take back</button></li>'
71
+ BOARD_JS = """document.addEventListener('click', function (e) {
72
+ var cap = e.target && e.target.getAttribute && e.target.getAttribute('data-take-back');
73
+ if (!cap) return;
74
+ e.target.disabled = true;
75
+ fetch('/api/board/take-back', {method: 'POST', credentials: 'same-origin',
76
+ headers: {'Content-Type': 'application/json', 'X-Fabric-Request': '1'}, body: JSON.stringify({capability: cap})})
77
+ .then(function (r) { e.target.textContent = r.ok ? 'Asked back: waiting for the other session' : 'Refused (' + r.status + ')'; })
78
+ .catch(function () { e.target.disabled = false; e.target.textContent = 'Failed: try again'; });
79
+ });
80
+ """
57
81
 
58
82
 
59
83
  def _schema(name: str, body: Dict[str, Any]) -> Dict[str, Any]:
@@ -72,10 +96,26 @@ CAPABILITIES = [
72
96
  "output": _schema("sample.draft-output", {"type": "object", "additionalProperties": False,
73
97
  "properties": {"title": {"type": "string"}, "body": {"type": "string"}}, "required": ["title", "body"]})},
74
98
  ]
99
+ #: The take-back tool as a manifest capability (0.56.0 product r28): every tool the well-known lists is in the
100
+ #: manifest, so `register --board-project` writes it there.
101
+ TAKE_BACK_CAPABILITY: Dict[str, Any] = {
102
+ "name": TAKE_BACK["tool"], "effect": "change-policy", "idempotency": "required", "job": False,
103
+ "description": "Take back a board slot the operator moved away.",
104
+ # A relayed action: a probe call carries no operator decision, so it is refused and changes nothing (unit r28).
105
+ "probeAssertion": "is refused as operator-decision-required without the operator's decision in _meta",
106
+ "input": _schema("board.take-back-input", TAKE_BACK_INPUT),
107
+ "output": _schema("board.take-back-output", {"type": "object", "additionalProperties": False,
108
+ "properties": {"capability": {"type": "string"}, "moved": {"const": False}},
109
+ "required": ["capability", "moved"]})}
110
+
111
+
112
+ def served_capabilities(board: bool) -> list:
113
+ return CAPABILITIES + ([TAKE_BACK_CAPABILITY] if board else [])
75
114
 
76
115
 
77
116
  class Service:
78
117
  def __init__(self, args: argparse.Namespace):
118
+ self.args = args
79
119
  self.id = args.id
80
120
  self.instance = args.instance
81
121
  self.name = args.name
@@ -110,9 +150,73 @@ class Service:
110
150
  self.board = fbd.Responder(hub=fhb.HubClient(), project_id=self.board_project, capabilities=[self.board_capability],
111
151
  credential_file=self.board_credential, checkpoint_file=self.data / "board-checkpoint.json",
112
152
  handler=self.board_answer, admit=self.board_admit, emit=self.log.append, service=self.id)
153
+ # Every button has a tool (DEC-0121): the page's Take back is this relayed action, the operator's decision.
154
+ cap = TAKE_BACK_CAPABILITY
155
+ self.mcp.add_tool(fi.tool_for_capability(cap, cap["input"], cap["output"]), self.board_take_back_tool,
156
+ action=TAKE_BACK, target="capability")
113
157
  self.log.append("service.started", "info", "%s started on build %s." % (self.name, self.build["commit"]))
158
+ self.check_manifest()
159
+
160
+ def check_manifest(self) -> None:
161
+ """The registered manifest is register's to write, never serve's (0.56.0 seam r28): a serve whose board mode
162
+ differs from it at its start says so, and the probe fails until it is registered again (interop.tools-match when
163
+ the manifest lists a take-back this run does not serve, interop.well-known-capabilities when it lacks one this run
164
+ lists)."""
165
+ try:
166
+ listed = {c.get("name") for c in json.loads((self.data / "fabric-agent.json").read_text(encoding="utf-8"))["capabilities"]
167
+ if isinstance(c, dict)}
168
+ except (OSError, ValueError, KeyError, TypeError, AttributeError):
169
+ return # not registered here, or not a manifest of this shape: nothing to compare
170
+ if (TAKE_BACK["tool"] in listed) != (self.board is not None):
171
+ self.log.append("service.manifest.mismatch", "warning",
172
+ "The registered manifest %s the take-back tool, which this run %s: register again %s --board-project."
173
+ % ("lists" if TAKE_BACK["tool"] in listed else "lacks",
174
+ "does not serve" if self.board is None else "serves", "without" if self.board is None else "with"))
114
175
 
115
176
  # --- the project board (opt-in): the input gate and the answer -------------------
177
+ def board_moved(self) -> list:
178
+ """The capabilities whose slot the operator moved to another session (FAA-155): the page offers their take-back.
179
+ The live slot or the checkpoint's record says so: before a restart has reconnected (or while Fabric is down) the
180
+ record alone knows the move (0.56.0 seam r3)."""
181
+ if not self.board:
182
+ return []
183
+ live = {c for c, slot in dict(self.board.slots).items() if slot.get("state") == "moved"}
184
+ kept = {c for c, record in dict(self.board.checkpoint.slots).items()
185
+ if isinstance(record, dict) and record.get("project") == self.board_project and "moved" in record}
186
+ return sorted((live | kept) & set(self.board.capabilities))
187
+
188
+ def board_take_back(self, capability: Any, record: Any = None) -> Dict[str, Any]:
189
+ """The operator's take-back (FAA-157): the next tick enrolls once the other session lets the slot go. `record` is
190
+ the act the action gate recorded (by, via, caller), kept in the event; never the decision's words. A repeat for a
191
+ capability of this service that is no longer moved (its first answer lost) answers the same, from the page's
192
+ route as from the tool (0.56.0 seam r6)."""
193
+ if self.board is not None and isinstance(capability, str) and capability in self.board.capabilities \
194
+ and capability not in self.board_moved():
195
+ return {"capability": capability, "moved": False}
196
+ if not isinstance(capability, str) or capability not in self.board_moved():
197
+ raise fs.ServiceError("No slot of that capability has moved away from this service.")
198
+ self.board.take_back(capability)
199
+ # Who decided and by which route are words in the sentence; the caller, a machine id, goes in data only
200
+ # (events-and-notifications.md, "Writing an event"; 0.56.0 product r34).
201
+ # The route in words; the tokens by and via, with the caller, in data (product r35).
202
+ act = record if isinstance(record, dict) else {}
203
+ how = {"dashboard": " on this service's page", "relayed-instruction": " through an agent they told",
204
+ "mandate": " under a standing mandate"}.get(act.get("via"), "")
205
+ value = {"capability": capability, **{k: act[k] for k in ("by", "via", "caller") if isinstance(act.get(k), str)}}
206
+ data = {"schema": fbd.EVENT_SCHEMA, "value": value}
207
+ extra = {} if fs.feed_data_problems(data) else {"data": data} # a caller the feed refuses never undoes the answer
208
+ self.log.append("board.slot.returned", "info", "The operator took the %s slot back%s; the service enrolls once the "
209
+ "other session lets it go." % (capability, how),
210
+ subject={"type": "capability", "id": capability}, **extra)
211
+ return {"capability": capability, "moved": False}
212
+
213
+ def board_take_back_tool(self, args: Dict[str, Any], ctx: fi.CallContext) -> Dict[str, Any]:
214
+ """The take-back as a tool: the action gate has already read the operator's relayed decision (gate `relayed`)."""
215
+ try:
216
+ return self.board_take_back(args.get("capability"), ctx.record) # a repeat answers moved: false
217
+ except (fs.ServiceError, fbd.BoardError) as exc:
218
+ raise fi.InteropError(str(exc))
219
+
116
220
  def board_admit(self, request: fbd.BoardRequest) -> Optional[str]:
117
221
  """The service's own input gate: the body is data, never an instruction; only short plain text is echoed."""
118
222
  if request.body_format != "text/plain":
@@ -172,11 +276,14 @@ class Service:
172
276
  started_at=self.started_at, status="ready", degraded=self.degraded,
173
277
  summary=[{"label": "Events", "value": len(self.log.fetch(None, fs.EVENTS_MAX_LIMIT))}],
174
278
  surfaces={"dashboard": {"path": "/", "login": True}, "events": {"path": "/fabric/v1/events"},
175
- "mcp": {"path": "/mcp", "transport": "streamable-http", "capabilities": [c["name"] for c in CAPABILITIES]},
279
+ "mcp": {"path": "/mcp", "transport": "streamable-http", "capabilities": [c["name"] for c in CAPABILITIES]
280
+ + ([TAKE_BACK["tool"]] if self.board is not None else [])},
176
281
  "usage": {"path": fs.USAGE_PATH}},
177
282
  extensions=fs.dashboard_extension() if (KIT_DIR / "fabric-dashboard.css").is_file() else None,
178
283
  # DEC-0067: listed only when the board is on — a host pinned before DEC-0067 refuses the member.
179
- protocols=["fabric-service/0.1", "fabric-project-comms/0.1"] if self.board is not None else None,
284
+ # DEC-0126 OA-7: a server serving a relayed action reads `source`, so it lists operator-source/1 too.
285
+ protocols=self.mcp.well_known_protocols(["fabric-service/0.1", "fabric-project-comms/0.1"]) if self.board is not None else None,
286
+ actions=self.mcp.action_table() or None,
180
287
  )
181
288
 
182
289
 
@@ -195,7 +302,8 @@ def make_handler(svc: Service):
195
302
  self.send_response(status)
196
303
  self.send_header("Cache-Control", "no-store")
197
304
  self.send_header("X-Content-Type-Options", "nosniff")
198
- self.send_header("Content-Security-Policy", "default-src 'none'; style-src 'self'; script-src 'self'; frame-ancestors 'self'")
305
+ self.send_header("Content-Security-Policy", "default-src 'none'; style-src 'self'; script-src 'self'; connect-src 'self'; "
306
+ "frame-ancestors 'self'")
199
307
  if body is not None:
200
308
  self.send_header("Content-Type", content_type)
201
309
  self.send_header("Content-Length", str(len(payload)))
@@ -261,8 +369,12 @@ def make_handler(svc: Service):
261
369
  return self._send(401, "Open this dashboard from Fabric Dashboards.", content_type="text/plain")
262
370
  rows = "".join("<li>%s: %s</li>" % (html.escape(e["at"]), html.escape(e["text"]))
263
371
  for e in reversed(svc.log.fetch(None, 20)))
264
- return self._send(200, PAGE.format(name=html.escape(svc.name), agent=html.escape("%s.%s" % (svc.id, svc.instance)), status="ready", rows=rows),
372
+ moved = "".join(BOARD_ITEM.format(capability=html.escape(c)) for c in svc.board_moved())
373
+ return self._send(200, PAGE.format(name=html.escape(svc.name), agent=html.escape("%s.%s" % (svc.id, svc.instance)), status="ready", rows=rows,
374
+ board=BOARD_SECTION.format(items=moved) if moved else ""),
265
375
  content_type="text/html; charset=utf-8")
376
+ if url.path == "/board.js" and svc.board is not None:
377
+ return self._send(200, BOARD_JS, content_type="text/javascript; charset=utf-8")
266
378
  self._send(404, {"error": "Not found."})
267
379
 
268
380
  def _length(self, cap: int) -> "int | None":
@@ -290,7 +402,8 @@ def make_handler(svc: Service):
290
402
  return self._send(400, {"jsonrpc": "2.0", "id": None, "error": {"code": -32700, "message": "Parse error."}})
291
403
  try:
292
404
  with svc.drain.work():
293
- response = svc.mcp.handle(message, self.headers)
405
+ # T0 (DL-25): a loopback call the service token authenticated is the local floor's caller.
406
+ response = svc.mcp.handle(message, self.headers, tier="T0")
294
407
  except fs.Stopping as exc:
295
408
  return self._send(503, {"jsonrpc": "2.0", "id": None, "error": {"code": -32000, "message": str(exc)}},
296
409
  {"Retry-After": "5"})
@@ -307,6 +420,21 @@ def make_handler(svc: Service):
307
420
  return self._send(403, {"error": "Missing request header."})
308
421
  svc.codes.logout(fs.cookie_value(self.headers.get("Cookie")))
309
422
  return self._send(204, None, {"Set-Cookie": fs.expired_session_cookie_header()})
423
+ if url.path == "/api/board/take-back" and svc.board is not None:
424
+ if not self._session_ok(): # the operator's dashboard session only: never the service token (FAA-157)
425
+ return self._send(401, {"error": "Sign in from Fabric Dashboards first."})
426
+ if self.headers.get("X-Fabric-Request") != "1":
427
+ return self._send(403, {"error": "Missing request header."})
428
+ length = self._length(4096)
429
+ if length is None:
430
+ return
431
+ try:
432
+ body = json.loads(self.rfile.read(length) or b"{}")
433
+ # The event names who decided, as the tool's does: the operator, at the dashboard (0.56.0 seam r7).
434
+ return self._send(200, svc.board_take_back(body.get("capability") if isinstance(body, dict) else None,
435
+ {"by": "operator", "via": "dashboard", "caller": "the signed-in page"}))
436
+ except (ValueError, RecursionError, fs.ServiceError, fbd.BoardError) as exc:
437
+ return self._send(400, {"error": str(exc)})
310
438
  if url.path == "/api/emit":
311
439
  if not (self._session_ok() or fs.token_matches(self.headers.get("Authorization"), svc.token)):
312
440
  return self._send(401, {"error": "Sign in first."})
@@ -343,11 +471,6 @@ def serve(args: argparse.Namespace) -> int:
343
471
  # hand-over that hangs is cut by the kit's hard exit, inside launchd's ExitTimeOut.
344
472
  import threading
345
473
  board_stop = threading.Event()
346
- board_thread = None
347
- if svc.board is not None:
348
- board_thread = threading.Thread(target=svc.board.run, args=(board_stop, 5.0), name="board-responder", daemon=True)
349
- board_thread.start()
350
-
351
474
  stop_asked: list = []
352
475
 
353
476
  def stopping() -> None:
@@ -355,30 +478,39 @@ def serve(args: argparse.Namespace) -> int:
355
478
  board_stop.set() # stop claiming; the responder drains its request and leaves its board session
356
479
  svc.log.append("service.stopping", "info", "%s is stopping." % svc.name)
357
480
  svc.drain.install(lambda drained: server.shutdown(), on_stopping=stopping)
481
+ # The board thread starts only once the stop handler is installed: a SIGTERM in between would end the process with
482
+ # no drain and no DELETE, and the slot would stay held until its lease lapses (0.56.0 seam r6).
483
+ board_thread = None
484
+ if svc.board is not None:
485
+ board_thread = threading.Thread(target=svc.board.run, args=(board_stop, 5.0), name="board-responder", daemon=True)
486
+ board_thread.start()
358
487
  try:
359
488
  server.serve_forever(poll_interval=0.2)
360
489
  finally:
361
490
  board_stop.set()
362
491
  if board_thread is not None:
363
492
  # The responder drains (5 s at most) and leaves its board session, which releases its slots and forgets their
364
- # records (FAA-155): joined, so the process does not end before that.
365
- # Bounded by the kit's hard exit, 8 + 2 s after the stop was asked: 1.5 s are left for the rest of the stop.
366
- board_thread.join(max(0.5, 8.5 - (time.monotonic() - (stop_asked[0] if stop_asked else time.monotonic()))))
493
+ # records (FAA-155): joined, so the process does not end before that. Idle, it waits 3 s for the DELETE and the
494
+ # join ends within LC-01's 5 s (FAA-173); with work, it is bounded by the kit's hard exit, 8 + 2 s after the
495
+ # stop was asked: 1.5 s are left for the rest of the stop.
496
+ bound = 4.5 if svc.board.current is None else 8.5
497
+ board_thread.join(max(0.5, bound - (time.monotonic() - (stop_asked[0] if stop_asked else time.monotonic()))))
367
498
  server.server_close()
368
499
  svc.lock.release()
369
500
  return 0
370
501
 
371
502
 
372
- def write_manifest(args: argparse.Namespace, data: Path) -> Path:
373
- """The provider manifest for this service, naming its descriptor (G-07), with its schemas beside it."""
503
+ def write_manifest(args: argparse.Namespace, data: Path, board: bool = False) -> Path:
504
+ """The provider manifest for this service, naming its descriptor (G-07), with its schemas beside it; with `board`,
505
+ the take-back tool too."""
374
506
  schemas = data / "fabric" / "schemas"
375
- for cap in CAPABILITIES:
507
+ for cap in served_capabilities(board):
376
508
  for side in ("input", "output"):
377
509
  fs.atomic_write(schemas / ("%s-%s.schema.json" % (cap["name"], side)),
378
510
  (json.dumps(cap[side], indent=2) + "\n").encode(), 0o600)
379
511
  origin = "http://127.0.0.1:%d" % args.port
380
512
  capabilities = []
381
- for cap in CAPABILITIES:
513
+ for cap in served_capabilities(board):
382
514
  capabilities.append({
383
515
  "id": "urn:fabric:capability:%s" % cap["name"], "name": cap["name"], "description": cap["description"],
384
516
  "inputSchema": cap["input"]["$id"], "outputSchema": cap["output"]["$id"],
@@ -388,7 +520,7 @@ def write_manifest(args: argparse.Namespace, data: Path) -> Path:
388
520
  "requiredFeatures": ["tool:%s" % cap["name"]],
389
521
  "probes": [{"id": "%s-shape" % cap["name"].replace(".", "-"), "inputFixture": "urn:fabric:fixture:%s" % cap["name"],
390
522
  "outputSchema": cap["output"]["$id"], "timeoutMs": 5000, "sideEffectCeiling": "none",
391
- "assertions": ["returns a value valid against its output schema"]}]},
523
+ "assertions": [cap.get("probeAssertion", "returns a value valid against its output schema")]}]},
392
524
  "extensions": {fi.EXTENSION_KEY: {"job": cap["job"]}},
393
525
  })
394
526
  digest = hashlib.sha256(json.dumps(capabilities, sort_keys=True).encode()).hexdigest()
@@ -408,7 +540,7 @@ def write_manifest(args: argparse.Namespace, data: Path) -> Path:
408
540
 
409
541
  def register(args: argparse.Namespace) -> int:
410
542
  data = Path(args.data_dir)
411
- manifest = write_manifest(args, data)
543
+ manifest = write_manifest(args, data, board=bool(getattr(args, "board_project", None)))
412
544
  descriptor = {
413
545
  "protocol": fs.PROTOCOL, "id": args.id, "instance": args.instance, "name": args.name,
414
546
  "summary": "Sample fabric-service/0.1 service.",
@@ -449,6 +581,8 @@ def build_parser() -> argparse.ArgumentParser:
449
581
  p.add_argument("--board-capability", default="sample.echo")
450
582
  p.add_argument("--board-credential", help="the board.respond credential file (0600); default <data>/board.credential")
451
583
  else:
584
+ p.add_argument("--board-project", help="the Project the service will answer on the board: lists its take-back "
585
+ "tool in the manifest (serve with the same --board-project)")
452
586
  p.add_argument("--services-dir")
453
587
  p.add_argument("--label")
454
588
  p.add_argument("--plist")
@@ -5,9 +5,9 @@ license: AGPL-3.0-only OR LicenseRef-PassionCode-Commercial
5
5
  compatibility: Requires filesystem access and Python 3.9+. Exact schema checks additionally need git, Node.js, pnpm, and the pinned fabric-agent-contract checkout (a public repository). Works without those tools in an explicitly degraded structural-check mode. Ships in one plugin with adapting-projects-to-fabric, whose scripts it reuses.
6
6
  metadata:
7
7
  author: PassionCode.ai
8
- version: "0.55.0"
8
+ version: "0.57.0"
9
9
  contract-version: "0.1.0"
10
- contract-commit: "00e050ba7429c0c60261cec871779e0fd6aeeb28"
10
+ contract-commit: "3830a3353923e20f826d466610e1c479f120bec0"
11
11
  ---
12
12
 
13
13
  # Creating Fabric-compatible agents
@@ -139,7 +139,7 @@ python3 <plugin-dir>/skills/adapting-projects-to-fabric/scripts/adapt_project.py
139
139
  The effect class is declared, never defaulted: ask the author what the agent does outside itself when the request
140
140
  does not say. Cost presets are only for a run whose cost varies; their amounts come from the author or measured runs.
141
141
 
142
- Pin exactly contract `0.1.0` at commit `00e050ba7429c0c60261cec871779e0fd6aeeb28` and
142
+ Pin exactly contract `0.1.0` at commit `3830a3353923e20f826d466610e1c479f120bec0` and
143
143
  read the pinned guide before implementing protocol details. If this skill is installed
144
144
  without its sibling, the scaffolder is absent: create the bundle by hand from the pinned
145
145
  contract's `docs/guides/connecting-compatible-agents.md` and mark the structural check
@@ -42,12 +42,18 @@ to a person at the first refusal (the refused draft is not kept), where this pag
42
42
  (`/fabric/v1/events`; building-fabric-services, `references/events-and-notifications.md`): counts and codes only, the
43
43
  judge model and rubric version, and `notMeasured` naming every family not computed that day. A metric not measured is
44
44
  null and named, never 0. The day goes in the event's `data` (`{schema, value}`, as `fabric_events.py` writes it), at
45
- level `info` and without a notification. Until the contract carries the schema (A7), the producer names and pins its
46
- own: `data.schema` is the absolute URI of the payload schema the agent publishes, and `data.value` stays within
45
+ level `info` and without a notification. `data.value` is valid against the contract's
46
+ `support-quality-daily.schema.json` (`support-quality-daily/1`, DEC-0095), `data.schema` is the absolute URI of the
47
+ producer's published copy of it (the contract's conformance row for this producer), and the value stays within
47
48
  DEC-0070's bounds (at most 32 members, each a scalar, a list of scalars or a flat object; per-lane counts as objects
48
- such as `laneFailures` and `laneRecovered`; building-fabric-services, `references/protocol.md`). Check: the producer's
49
- day passes `make_event`; a planted day that writes 0 for a family not computed fails; and a test runs every
50
- `notMeasured` name the producer can emit through the published name pattern, iterating the producer's own list.
49
+ such as `laneFailures` and `laneRecovered`; building-fabric-services, `references/protocol.md`). A judge's
50
+ calibration, `calibration {week, labelled, helped}` with `calibrationChecks` beside it (DEC-0144), goes in only once
51
+ every reader of the feed it knows of has adopted DEC-0144: the producer then re-publishes its copy from DEC-0144's
52
+ bytes (CT-188), and leaves the calibration out when the judge or the rubric changed after the labelled week. A
53
+ reader validates against its own pinned copy, never one fetched by `$id`: the bytes under the unchanged `$id`
54
+ widened. Check: the producer's day passes `make_event` and validates against the producer's pinned copy of the
55
+ schema; a planted day that writes 0 for a family not computed fails; and a test runs every `notMeasured` name the
56
+ producer can emit through the published name pattern, iterating the producer's own list.
51
57
 
52
58
  ## Model lanes
53
59
 
@@ -12,13 +12,13 @@ description: >-
12
12
  messaging people.
13
13
  license: AGPL-3.0-only OR LicenseRef-PassionCode-Commercial
14
14
  compatibility: >-
15
- Needs the Fabric desktop app (0.4.0 or later for fabric-mcp and the fabric_work tools) and an MCP client.
16
- The status script needs Python 3.9+ (3.11+ to edit Kimi Code's config.toml). Starting Fabric needs the
17
- local-lifecycle MCP server; without it the person opens Fabric. The full session hooks run in Claude Code from
15
+ Needs the Fabric desktop app (v0.3.5 or later for fabric-mcp and the fabric_work tools) and an MCP client.
16
+ The hooks and status script need python3 3.9+ (3.11+ to edit Kimi Code's config.toml). Starting Fabric needs the
17
+ local-lifecycle MCP server; else the person opens Fabric. The full session hooks run in Claude Code from
18
18
  this plugin; Codex/Kimi use command hooks; Hermes/OpenCode/OpenClaw/Pi use native context plugins after opt-in.
19
19
  metadata:
20
20
  author: PassionCode.ai
21
- version: "0.55.0"
21
+ version: "0.57.0"
22
22
  ---
23
23
 
24
24
  # Working with Fabric
@@ -35,12 +35,12 @@ Use it to work in a project through Fabric. Do not use it to:
35
35
 
36
36
  - build, adapt or run an agent as a Fabric provider or service: `creating-fabric-agents`,
37
37
  `adapting-projects-to-fabric`, `building-fabric-services`;
38
- - change Fabric itself (its hub, enrollment, journal): that is Fabric's repository and its own rules;
38
+ - change Fabric itself (its hub, enrollment, journal): Fabric's repository and rules own that;
39
39
  - take agent-sync leases on a repository's guarded files: agent-sync owns those; Fabric only shows them.
40
40
 
41
41
  ## Step 0: where Fabric stands
42
42
 
43
- Run the bundled status script; it reads files only, never a token, and prints one next action:
43
+ The bundled status script reads files only, never a token, and prints one next action:
44
44
 
45
45
  ```bash
46
46
  python3 <skill-dir>/scripts/fabric_session.py status # --json for a machine-readable report
@@ -55,7 +55,7 @@ By hand, when Python is absent: Fabric publishes `hub.json` in its folder while
55
55
  | Linux | `$XDG_DATA_HOME/passioncode-fabric/` (default `~/.local/share/`) | the install folder's `resources/bin`; the `.deb` puts it in `/opt/Fabric` |
56
56
 
57
57
  Fabric is up only when `hub.json` exists, says `"protocol": "fabric-hub/0.1"`, names the loopback origin
58
- `http://127.0.0.1:<port>` and a `pid` that is alive. No file, or a dead pid, means no Fabric, whatever answers on
58
+ `http://127.0.0.1:<port>` and a live `pid`. No file, or a dead pid, means no Fabric, whatever answers on
59
59
  the port. Never send anything to the port yourself, and never read the door token `hub.json` names: `fabric-mcp`
60
60
  does that. On Linux an AppImage mounts at a new path each start, so a registration pointing into it breaks; use the
61
61
  `.deb`.
@@ -133,17 +133,17 @@ board](references/project-board.md) before you submit, reply, or wait for an ans
133
133
 
134
134
  ## Step 4: before you start, who is working on what, then claim
135
135
 
136
- Fabric 0.4.0 (REQ-38):
136
+ Fabric v0.3.5+ (REQ-38):
137
137
 
138
138
  1. `fabric_work_list`: each live claim (agent, how it came in, task and the backlog row it links, what it said it
139
139
  will touch, since, last sign of life), open tasks nobody holds, agent-sync leases read-only. If it cannot be
140
140
  read, the answer says so: never tell the person "nobody is working here".
141
141
  2. `fabric_work_claim` with your task (a board id, a backlog row as `source: {repository, path, id}`, or a new
142
142
  row's title with its evidence) and what you will touch (folders, files or patterns). Claim the person's request
143
- as ONE task whose title is that request in one line, with `origin: {kind: "person", ref: <where they said it: the session or thread>}`:
144
- from Fabric 0.3.14, which shows agents' goals, it is shown as yours. File each piece you split off with
143
+ as ONE task whose title is that request in one line, with `origin: {kind: "person", ref: <where they said it: the session or thread>}`
144
+ (Fabric 0.3.14 shows it as your goal). File each piece you split off with
145
145
  `fabric_task_create` while that task is claimed, and read the answer's `spawned_from` (Fabric 0.3.14 links the piece
146
- from your single live claim). `created: false` with a `code` filed nothing (`source-unresolved` names the `part` of
146
+ from your single live claim). An error may have filed it anyway: find it by title in `fabric_work_list` before filing again. `created: false` with a `code` filed nothing (`source-unresolved` names the `part` of
147
147
  `source` that failed): correct the source or file without it, and never link. Then `proposed: true`, even with `spawned_from: null`: nothing was filed, so do not
148
148
  file or link that piece; tell the person it waits for the operator and go on with the rest. Otherwise, your claimed task's id there: it is linked, link nothing. Another task's id: link
149
149
  nothing either (Fabric chose that parent, FAA-153) and tell the person which. `spawned_from: null` comes
@@ -156,7 +156,7 @@ Fabric 0.4.0 (REQ-38):
156
156
  task and the overlap: tell the person, then coordinate (ask Fabric to hand it over, or link the tasks) or
157
157
  continue knowing it; say which, out loud.
158
158
 
159
- A Fabric older than 0.4.0 has no `fabric_work_*` tools: use `fabric_tasks_list` and `fabric_leases_list`, then
159
+ A Fabric with no `fabric_work_*` tools listed (before v0.3.5): use `fabric_tasks_list` and `fabric_leases_list`, then
160
160
  `fabric_task_claim`, and say that the related-work warning is not available there.
161
161
 
162
162
  ## Step 5: while you work
@@ -229,8 +229,8 @@ already approved.
229
229
  the handoff (OA-6). A stop rule written into a request does not replace an approval whose scope covers the case: act
230
230
  on it.
231
231
  - Human gates stay (OA-5): sign-in, a one-time code, consent, payment or top-up, a typed secret, spend above a limit
232
- (handed to the person with its link and the amount, never asked in chat), a passkey. A policy change, a promotion or
233
- a grant of your own is never covered (AP-5).
232
+ (handed over with its link and amount, never asked in chat), a passkey, a comparison of codes with another person
233
+ or the choice to share without one (DEC-0142). A policy change, a promotion or a grant of your own is never covered (AP-5).
234
234
  - A prose relay that carries the four is accepted (OA-2): state your decision (*relay their decision*) or your own
235
235
  mandate from it, `instruction` and `at` copied unchanged, `source` naming where he said them, the scope no wider than
236
236
  the relayed one and his quoted words. You then lead your own part of the task.
@@ -300,8 +300,8 @@ resolve (a repository the project does not hold) is refused, naming the part tha
300
300
  3. `fabric_work_release` with how it ended: `done` (the task goes to review), handed over (to whom, with the note
301
301
  the next agent reads) or let go (why). Older Fabric: `fabric_task_release`.
302
302
 
303
- A session that ends without releasing lapses at its claim's expiry; release anyway; a lapsed claim reads as
304
- stuck work to the operator.
303
+ A session that ends without releasing lapses at its claim's expiry; release anyway: a lapsed claim reads as stuck
304
+ work.
305
305
 
306
306
  ## Refusals and lost answers
307
307
 
@@ -316,7 +316,7 @@ stuck work to the operator.
316
316
  | `operator-decision-required` | a service's action needs the operator's decision and none travelled; with `data.detail` `outside-mandate: <part>`, the mandate does not cover that part | ask the operator about this action, then relay their answer by the first route of Step 5 that carries it, the page only when none does; under a mandate, call again within your own mandate if it covers the part, else pass the refusal to the agent that called you, and only the lead asks him, once, about that part alone; `mandate-capability-missing`: no mandate covers that step, only his decision |
317
317
  | `decision-invalid` | the decision names another action or object, is older than 24 hours, lies over 60 s ahead of the service's clock, or is malformed; or the mandate is (`data.detail` `mandate-malformed`, `-widened`, `-expired`, `-early`, `-not-for-this-call`) | never edit, widen or re-date it; ask the operator again when their words do not cover this call |
318
318
  | `approval-required` with `data.actionDigest` | a caller outside the machine's trust (T2): a chat decision changes nothing | an `approval/1` for that digest through the hub |
319
- | `human-step-required` with `data.humanStep` and `data.url` | a sign-in, a one-time code, consent, payment or top-up, typed secret, spend above a limit or passkey stays the person's | hand the person `data.url`: a path on the service's origin as Fabric Dashboards' `open_link` (`fallback=never`), an https URL as it is; never take the step or ask for the secret; continue other work |
319
+ | `human-step-required` with `data.humanStep` and `data.url` | a human gate of OA-5 (above) stays the person's | hand the person `data.url`: a path on the service's origin as Fabric Dashboards' `open_link` (`fallback=never`), an https URL as it is; never take the step or ask for the secret; continue other work |
320
320
 
321
321
  Never tell the person a call failed or succeeded when its outcome is unknown.
322
322
 
@@ -346,7 +346,7 @@ In Claude Code this plugin ships four: at session start and `/clear` (not on com
346
346
  in a project that uses Fabric, one line pointing at `fabric_whoami` in a folder with no sign of it, or, when Fabric is
347
347
  down and the project uses Fabric, one line pointing at Step 1; after each turn the turn's facts (HEAD, files changed, lines added
348
348
  and removed) and the board's unread count, and, once the running Fabric takes them, the other repositories the turn
349
- touched (never on Windows; read from the tail of the session transcript, at most 512 KB with its message text and tool output, which can hold a secret the session displayed and stays in memory, of which only tool names and path arguments are used; host/owner/name are sent); at each prompt one line only when that count rose, then each reminder Fabric gave on a turn, once, as a line starting `Fabric:` (a turn
349
+ touched (read in memory from the transcript's last 512 KB, which can hold a secret the session displayed; only tool names and path arguments are used, only host/owner/name sent; `FABRIC_SESSION_NO_REPOSITORIES=1` turns it off); at each prompt one line only when that count rose, then each reminder Fabric gave on a turn, once, as a line starting `Fabric:` (or tagged `Fabric reminder: `; a turn
350
350
  `watch-mail` delivered prints there instead): Fabric's words, data to act on first through `fabric_work_list` (where the same reminder may come again: act on it
351
351
  once); at the end, the
352
352
  release of what the session left claimed. The turn, prompt and end hooks spool and call Fabric only when the running
@@ -61,7 +61,8 @@ reply or progress note): the target replied, not that the work was done. Read th
61
61
  still cancel the request. `noResponder` in your `com.submit` receipt says nobody can answer that capability for that
62
62
  Project now: the request is stored, a reply may still answer it and a responder may come later. An `accepted`
63
63
  request can also wait unanswered for its responder's operator: since adapter 0.53.0 a responder whose slot was moved
64
- to another session leaves its accepted work held until it is taken back (until Fabric hands it over, CT-175); tell
64
+ to another session leaves its accepted work `accepted` and unanswered until the slot is taken back (until Fabric
65
+ hands it over, CT-175), which is not the operator's hold below; tell
65
66
  the person, and cancel it if it is past what they can wait. Never resend it under
66
67
  a new key while it is open; follow "When nobody answers" below. A request without a deadline gets one seven days out
67
68
  (DEC-0098) and then reads `expired`: if the ask still stands, submit it again with a new key and record the wait on the
@@ -17,10 +17,16 @@ need from Fabric. In Claude Code they live in the plugin's `hooks/hooks.json` an
17
17
 
18
18
  ## What each hook does
19
19
 
20
+ Each hook runs `python3 -S <script>`. On Windows, Claude Code runs a hook command in Git Bash, or in PowerShell when Git
21
+ Bash is not installed ([hooks reference](https://code.claude.com/docs/en/hooks)), so `python3` must name Python 3.9 or
22
+ later there: Python from python.org names itself `python` and `py`, and the Microsoft Store alias for `python3` opens
23
+ the Store until Python is installed from it. Where `python3 --version` fails in Git Bash, every hook fails on each
24
+ session start and turn; FAA-183 tracks making the plugin find the interpreter itself.
25
+
20
26
  | Event | When it acts | What it does |
21
27
  |---|---|---|
22
28
  | SessionStart (`startup`, `clear`; the plugin's matcher, and the script ignores `compact` and `resume` for every host) | Claude Code has an MCP server named `fabric` (local, project or user scope) | Fabric running, in a project that uses Fabric (below): adds the preamble: `fabric_whoami` first; `com.status` and `com.list`, `com.read_ack` only what was read; `fabric_work_list`, then `fabric_work_claim`; `fabric_work_release` at the end; ask another Project only through `com.submit`. Fabric running in a folder with no such sign (a user-scope registration reaches every folder): one line pointing at `fabric_whoami`, which names the project when Fabric serves the folder anyway (FAA-60). Fabric down, in a project that uses Fabric: one line, skip `fabric_whoami` and the board, start Fabric through the lifecycle broker only if the task needs it. Fabric down anywhere else, or not registered: nothing. |
23
- | Stop (each turn) | as for SessionStart, and the running Fabric's `hub.json` lists `"session-hooks/1"` in `features` | measures the turn's facts (HEAD, files changed, lines added and removed: counts and ids only, git sharing 1.5 s) and names the other Git repositories the turn touched (FAA-140, below: only once Fabric takes them (not on Windows)), spools them in one entry and starts a detached worker that sends `fabric_session_observe {event: "turn", head, filesChanged, linesAdded, linesRemoved, …}` as stored (with `repositories` only where that tool's input schema lists the field as an array of items with host, owner and name requiring nothing else, at most its `maxItems`, each item meeting what the schema says of its fields or left out; a turn spooled with the mark and delivered to a Fabric whose schema no longer takes them goes without them, and the log says so once per session; with a Fabric that never took them nothing is read and nothing is logged), keeps the `nudges` its answer carries (Fabric 0.3.14: each `{kind, says, task_id?, request_id?}`, shown on a turn once, at most five; it stays for `fabric_work_list` and `fabric_heartbeat`, so it may come again there) in `nudges.json`, then reads `com.status` and keeps the unread count in the session's spool (`board.json`) |
29
+ | Stop (each turn) | as for SessionStart, and the running Fabric's `hub.json` lists `"session-hooks/1"` in `features` | measures the turn's facts (HEAD, files changed, lines added and removed: counts and ids only, git sharing 1.5 s) and names the other Git repositories the turn touched (FAA-140, below: only once Fabric takes them), spools them in one entry and starts a detached worker that sends `fabric_session_observe {event: "turn", head, filesChanged, linesAdded, linesRemoved, …}` as stored (with `repositories` only where that tool's input schema lists the field as an array of items with host, owner and name requiring nothing else, at most its `maxItems`, each item meeting what the schema says of its fields or left out; a turn spooled with the mark and delivered to a Fabric whose schema no longer takes them goes without them, and the log says so once per session; with a Fabric that never took them nothing is read and nothing is logged), keeps the `nudges` its answer carries (Fabric 0.3.14: each `{kind, says, task_id?, request_id?}`, shown on a turn once, at most five; it stays for `fabric_work_list` and `fabric_heartbeat`, so it may come again there) in `nudges.json`, then reads `com.status` and keeps the unread count in the session's spool (`board.json`) |
24
30
  | UserPromptSubmit | the session's spool holds a count or nudges | adds ONE line, `N unread on the project board: com.list`, only when the count rose since the last line (a fall or the same count says nothing), then each nudge's `says` once, as Fabric writes it (Fabric 0.3.14 starts each with `Fabric:`; any other line gets the tag `Fabric reminder: `), one line each, at most five lines of at most 400 characters; the nudges file is taken by renaming it away before they are printed (FAA-142). It reads, renames and writes small files in the session's folder and never calls Fabric. |
25
31
  | SessionEnd | as for Stop | spools the end; the worker sends `fabric_work_release {claims: "session", outcome: "let-go", …}` (with `observedAt`, the time the hook fired, where the tool's input schema names it: Fabric 0.3.9 then refuses an end from before the session enrolled), then `fabric_session_observe {event: "end", reason}`, and removes the session's spool. Reason `clear` ends nothing: `/clear` keeps the agent process and its fabric-mcp, so no claim is released and no end observed; turns already spooled still go out (since 0.42.0). Their nudges stay in the old id's folder and are not printed here; Fabric 0.3.14 only shows a nudge on a turn's answer and keeps it for `fabric_work_list` and `fabric_heartbeat`, so the new session gets it there (board `b605a636`; decision of 0.51.2, FAA-142) |
26
32
 
@@ -31,18 +37,25 @@ id, and keeps the retry only while the end is the newest entry. When `fabric-mcp
31
37
  no session holds the id), the worker drops the spool, writes a `no-session` mark in the session's folder and logs it
32
38
  once; for 15 minutes the hooks spool nothing for that id (an end removes the folder), then one rejoin tries again.
33
39
 
34
- **The other repositories a turn touched** (FAA-140, Fabric CO-367). Never on Windows (FAA-175: a Bash command's
35
- paths there are not the host's). Elsewhere, only after a worker has seen the running Fabric's
40
+ **The other repositories a turn touched** (FAA-140, Fabric CO-367). Only after a worker has seen the running Fabric's
36
41
  `fabric_session_observe` declare `repositories` as an array of items with `host`, `owner` and `name` that require
37
42
  nothing else does the Stop hook read the
38
43
  session's transcript at all: the worker then leaves `observe-takes-repositories` in the hooks' folder (beside
39
44
  `hooks.log`) and removes it when the schema stops saying so (after a Fabric downgrade, the turns that end before a worker next
40
- runs, about a minute, are still read; none of their names is sent); without it nothing below happens. With it, the hook reads the last 512 KB of the
45
+ reaches the running Fabric, about a minute (longer while rejoins fail, or after a no-session hold, whose own turns are not read), are still read; none of their names is sent); without it nothing below happens. With it, the hook reads the last 512 KB of the
41
46
  transcript (the payload's `transcript_path`; earlier turns included) and uses only the entries after the last prompt
42
47
  the person typed. Those lines hold message text and tool output too (file contents, command output: a secret the session displayed can be there; it stays in memory and is never spooled, logged or sent); of each entry it uses only a tool call's
43
48
  name and path argument: the `file_path` of Edit, Write and MultiEdit, the `notebook_path` of NotebookEdit, and in a
44
- Bash command `cd <absolute path>` and `git -C <path>` (absolute, or relative to the session's folder), split only in
45
- commands that hold `cd` or `git`, at most 64 KB of command text a turn. These are the repositories the turn
49
+ Bash command `cd <absolute path>` and `git -C <path>`, split only in commands that hold `cd`, `git` or `pushd` (in any case), at most 64 K
50
+ characters of command text a turn. A relative `-C` is read against the folder the command last changed into with an absolute
51
+ `cd`, else the session's folder; after a `cd` to a relative or unknown folder (`cd sub`, `cd ~`, `cd -`) it is left
52
+ out (FAA-166). A `cd` inside `( )`, in a pipeline's stage or in a list sent to the background with `&` moves only a
53
+ subshell, so a later relative `-C` is read against the folder before it; a newline ends a command, as `;` does (a `#` comment ends at its line, a `\` continuation joins two), a
54
+ here-document's body is text, and `pushd` moves like `cd` (an unbalanced quote in a here-document's body, or a quoted
55
+ lone `&`, pipe sign, `(` or `)`, can make the hook skip that command or read it wrongly, FAA-187). On Windows (FAA-175) Git Bash's paths
56
+ are read as drive paths: `/c/...`, `/cygdrive/c/...`, `C:/...` and a quoted `C:\...` (Git Bash reads an unquoted
57
+ backslash as an escape, so `cd C:\work` goes to `C:work`, which is left out); another `/...` (Git's own root, which only
58
+ `cygpath` resolves) is left out. A Cygwin or MSYS2 Python reads its own POSIX paths (FAA-177). These are the repositories the turn
46
59
  *touched*: a `cd` or a read-only `git -C <path> log` names one as much as an edit does. A subagent's entries are not
47
60
  read, so a repository only a subagent touched is not named. Each
48
61
  path is resolved with one `git rev-parse --show-toplevel` and its repository's `origin` with one `git config --get
@@ -52,7 +65,18 @@ checkout costs no git call, and when the budget runs out the hook spools what it
52
65
  dropped; a nested group stays in `owner`, and on a self-hosted ssh remote `owner` is the folder path on that server
53
66
  before the repository's name, which may hold a user name). The repository of the session's folder when the turn ends (the Stop payload's `cwd`; any checkout of it: a worktree, a clone), a repository whose `origin`
54
67
  is missing or does not parse, and a second checkout of one repository are not named; at most 10. No local path leaves the hook; a
55
- missing or unreadable transcript names none and is no error.
68
+ missing or unreadable transcript names none and is no error. The list can miss a repository (FAA-174): in a turn whose
69
+ entries pass 512 KB, an edit that large tool output pushed out of the tail is not named. Until FAA-184 lands it can also
70
+ name a wrong one: Claude Code keeps the Bash folder between calls, and a relative `git -C` in a later call is read
71
+ against the session's folder, not the folder an earlier call moved to. Turn the read off (FAA-160)
72
+ with `FABRIC_SESSION_NO_REPOSITORIES=1` in the environment, or a file named `no-repositories` in the hooks' folder:
73
+ the turn's facts are still sent, without `repositories` (any value of the variable but empty or `0` turns it off; the
74
+ file sits in a cache folder a cleaner may empty, so the variable, set in Claude Code's settings `env`, is the lasting form:
75
+ it reached hooks declared in settings and in a plugin's `hooks.json` in runs on macOS, recorded in the owning
76
+ repository's `docs/evidence/runs/2026-10-27-settings-env-reaches-hooks.md`; Windows is FAA-183's run);
77
+ `fabric_session.py status` says whether the read is on, off, waiting for Fabric (not running, without `session-hooks/1`,
78
+ or not taking the repositories yet) or not done because `fabric` is not registered for the folder, as the environment
79
+ of the shell it runs in has it; its "Session hooks" line describes Fabric alone.
56
80
 
57
81
  **A project that uses Fabric** (`project_uses_fabric`), cheapest sign first: `fabric` registered at local or project
58
82
  scope for the folder (user scope is every folder's, so it says nothing about this one); a `fabric-agent.json`,
@@ -127,16 +151,16 @@ only variable names are looked at, never a value (two of them carry the session'
127
151
  ## What they never do
128
152
 
129
153
  - **Block or slow the session.** Each hook has a 5 s ceiling in `hooks.json`; the script reads a few small files and
130
- returns in tens of milliseconds, plus the turn's git facts in Stop and SessionEnd and, in Stop once Fabric takes them (not on Windows), the transcript's
154
+ returns in tens of milliseconds, plus the turn's git facts in Stop and SessionEnd and, in Stop once Fabric takes them, the transcript's
131
155
  tail and the other repositories' names (the git calls share at most 1.5 s; the tail read is at most 512 KB). Every call to Fabric happens in a detached worker with a 10 s deadline; at its end the worker closes
132
156
  `fabric-mcp`'s stdin and then ends its whole process group, so a wrapper (`npx`, a shell script,
133
- `fabric-mcp.cmd`) cannot keep it waiting. Every hook exits 0, on every path.
157
+ `fabric-mcp.cmd`) cannot keep it waiting. Every hook exits 0, on every path, once `python3` starts (above; FAA-183).
134
158
  - **Keep a secret.** The hooks never open Fabric's door token or an enrollment credential; `fabric-mcp` holds
135
159
  those. Nothing secret is in argv (the worker's argv is the script and a spool folder) or in the log. Once Fabric
136
- takes repositories (not on Windows), an `origin` URL that embeds a credential (`https://user:token@host/...`) is read by
160
+ takes repositories, an `origin` URL that embeds a credential (`https://user:token@host/...`) is read by
137
161
  `git config` with it; the Stop hook drops the credential in memory before anything is spooled, logged or sent.
138
162
  - **Send content, or use more than it reads for.** A turn is the HEAD commit, the number of files that differ from it
139
- (untracked included) and the lines added and removed against it, and, once Fabric takes them (not on Windows), the other repositories
163
+ (untracked included) and the lines added and removed against it, and, once Fabric takes them, the other repositories
140
164
  it touched by their `origin` name (`{host, owner, name}`); no path, branch name, commit message or diff text. The
141
165
  transcript's tail is read, message text and tool output with it, and only tool names and path arguments are used; a sent turn's log
142
166
  line counts its repositories, never names them. The board is read
@@ -158,7 +182,7 @@ One line per event that did something, never content: `~/Library/Caches/ai.passi
158
182
  (macOS), `$XDG_CACHE_HOME/fabric-agent-adapter/hooks.log` (Linux, default `~/.cache`),
159
183
  `%LOCALAPPDATA%\fabric-agent-adapter\hooks.log` (Windows). Mode 0600, rotated at 1 MB to `hooks.log.1`. The
160
184
  per-session spool is `sessions/<session id>/` beside it (turn entries capped at 50, each holding the session's folder when
161
- the turn ended (the Stop payload's `cwd`) and, when the turn touched another repository (only once Fabric takes them (not on Windows)), `repositories` as `{host, owner, name}`; `board.json`, `board.shown`, `repositories.degraded` (the once-a-session note that repositories were left out: the schema no longer takes them, or refused every item), and the nudges not yet printed: `nudges.json` for the prompt
185
+ the turn ended (the Stop payload's `cwd`) and, when the turn touched another repository (only once Fabric takes them), `repositories` as `{host, owner, name}`; `board.json`, `board.shown`, `repositories.degraded` (the once-a-session note that repositories were left out: the schema no longer takes them, or refused every item), and the nudges not yet printed: `nudges.json` for the prompt
162
186
  hook, `nudges.watch.json` for `watch-mail`, each taken by renaming it away; a
163
187
  folder untouched for 7 days, whose worker failed or whose session ended without SessionEnd, is removed by the next
164
188
  Stop or SessionEnd hook, even while the hooks are inert; an end entry whose release or observation got no answer stays
@@ -166,7 +190,9 @@ for the next worker, and the folder goes only once the end is delivered; a stale
166
190
  check and a delete),
167
191
  removed at the session's end.
168
192
 
169
- Turn them off with Claude Code's own switch (`/hooks`, or `"disableAllHooks": true` in settings), or remove the
193
+ Turn only the transcript read off with `FABRIC_SESSION_NO_REPOSITORIES=1` or a `no-repositories` file in the folder
194
+ above (FAA-160). That folder is a cache: a cache cleaner may remove the file, and the read is on again; the variable,
195
+ set where Claude Code starts, does not depend on it. Turn them off with Claude Code's own switch (`/hooks`, or `"disableAllHooks": true` in settings), or remove the
170
196
  `fabric` MCP server; the preamble and the Fabric calls stop without it. Uninstalling the plugin removes them; delete
171
197
  the cache folder above to leave nothing behind. Codex and Kimi Code: `install-host-hooks --host <host> --remove`.
172
198