@passioncode-ai/fabric-agent-adapter 0.34.0 → 0.35.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.
- package/CHANGELOG.md +61 -0
- package/README.md +4 -1
- package/package.json +1 -1
- package/plugins/fabric-agent-adapter/.claude-plugin/plugin.json +1 -1
- package/plugins/fabric-agent-adapter/skills/adapting-projects-to-fabric/SKILL.md +1 -1
- package/plugins/fabric-agent-adapter/skills/adapting-projects-to-fabric/scripts/fabric_identifiers.py +8 -1
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/SKILL.md +1 -1
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/references/profiles.md +3 -1
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric-profiles.mjs +48 -31
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_estate.py +40 -5
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_identifiers.py +8 -1
- package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_profiles.py +67 -65
- package/plugins/fabric-agent-adapter/skills/creating-fabric-agents/SKILL.md +1 -1
- package/plugins/fabric-agent-adapter/skills/working-with-fabric/SKILL.md +8 -6
- package/plugins/fabric-agent-adapter/skills/working-with-fabric/references/native-host-hooks.md +53 -0
- package/plugins/fabric-agent-adapter/skills/working-with-fabric/references/session-hooks.md +5 -1
- package/plugins/fabric-agent-adapter/skills/working-with-fabric/scripts/fabric_session.py +30 -11
- package/plugins/fabric-agent-adapter/skills/working-with-fabric/scripts/host_hooks.py +178 -0
- package/plugins/fabric-agent-adapter/skills/working-with-fabric/scripts/hosts/context.mjs +33 -0
- package/plugins/fabric-agent-adapter/skills/working-with-fabric/scripts/hosts/hermes/__init__.py +135 -0
- package/plugins/fabric-agent-adapter/skills/working-with-fabric/scripts/hosts/hermes/plugin.yaml +5 -0
- package/plugins/fabric-agent-adapter/skills/working-with-fabric/scripts/hosts/openclaw/index.mjs +45 -0
- package/plugins/fabric-agent-adapter/skills/working-with-fabric/scripts/hosts/openclaw/openclaw.plugin.json +11 -0
- package/plugins/fabric-agent-adapter/skills/working-with-fabric/scripts/hosts/openclaw/package.json +10 -0
- package/plugins/fabric-agent-adapter/skills/working-with-fabric/scripts/hosts/opencode/fabric.mjs +24 -0
- package/plugins/fabric-agent-adapter/skills/working-with-fabric/scripts/hosts/pi/fabric.mjs +36 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,66 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.35.0 - 2026-10-16
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- Codex SessionStart emits explicit JSON. Its preamble began with `[fabric-agent-adapter]`, which Codex treats as JSON-looking output and rejected with `hook returned invalid session start JSON output`.
|
|
8
|
+
- The Codex hook installer updates a stale owned command while preserving its matcher, timeout and unrelated hooks; ambiguous duplicate entries are refused.
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Native bounded context adapters for Hermes prompt sections, OpenCode system transforms, OpenClaw `before_prompt_build`, and Pi `before_agent_start`; no model calls or lifecycle enrollment from these hooks.
|
|
13
|
+
- Dry-run native installers with source preflight, config hash fences, managed-file checks and preservation of unrelated settings and explicit OpenClaw denials. Hermes opt-in uses its own CLI.
|
|
14
|
+
- Optional native loader probes, negative permission and timeout tests, and a sourced capability survey of all 30 Switchboard hosts plus Tabby. Native context loading is separate from live Fabric admission.
|
|
15
|
+
|
|
16
|
+
## 0.34.1 - 2026-10-15
|
|
17
|
+
|
|
18
|
+
A review of 0.33.0 and 0.34.0 found the profile and route rules disagreeing with the contract on JSON they never met in
|
|
19
|
+
its vectors. The kits now answer as the contract's TypeScript does on any input. The contract pin is unchanged
|
|
20
|
+
(`d8146cf`).
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
|
|
24
|
+
- **FAC-SEM-059 (`runner-profile`) compared loosely.** Python read a missing member and `null` as the same and `1`
|
|
25
|
+
and `true` as equal: an unknown login with `runnerKind: null`, or an allow-list `true` against a profile `1`, passed.
|
|
26
|
+
Node threw on a login or runner kind whose own `toString` member is data. Both now compare with `===`, show such a
|
|
27
|
+
value as its JSON, and read only the vendor table's own members.
|
|
28
|
+
- **FAC-SEM-060 compared a recorded resolution loosely.** Python's `!=` called `1` and `true` equal; Node's
|
|
29
|
+
`JSON.stringify` comparison called `NaN` and `null` equal. Both now use the contract's `jsonEqual`, where NaN equals
|
|
30
|
+
nothing.
|
|
31
|
+
- **A refusal (`model-classes-empty`) named its policy wrongly on hostile input.** Node threw on an id or revision
|
|
32
|
+
whose own `toString` is data; Python wrote `[object Object]`, read `null` as `undefined`, and did not read a revision
|
|
33
|
+
as `Number()` does (`"0x10"`, `[5]`, `null`). Both now use the contract's `show` and `toNumber`; a revision that is
|
|
34
|
+
not a number is written as null.
|
|
35
|
+
- **Route rules (FAC-SEM-028…034) threw or misread hostile JSON.** Node used `String()` where the contract uses `show`;
|
|
36
|
+
Python wrote `[object Object]`, and compared a probe's runner kind and a drive with `!=` (`1` equal to `true`).
|
|
37
|
+
- **The doctor's `model_usable` raised on a catalogue row whose id is an object** (Python), and threw on a policy id
|
|
38
|
+
whose own `toString` is data (Node).
|
|
39
|
+
- **Python wrote and compared JSON values unlike JavaScript** (found by an independent review of this fix):
|
|
40
|
+
- a lone surrogate (`"\ud800"`, valid JSON) raised `TypeError` wherever a message wrote a value, because
|
|
41
|
+
`_json_stringify` used the RFC 8785 writer that refuses one; it now escapes it as `JSON.stringify` does;
|
|
42
|
+
- members whose keys are array indexes came out in the order written, where JavaScript writes them first and
|
|
43
|
+
ascending, so two equal hostile runner kinds were not a FAC-SEM-028 duplicate;
|
|
44
|
+
- integers past 2**53 compared exactly, where JavaScript compares doubles (`9007199254740993` is
|
|
45
|
+
`9007199254740992`), and integers past the double range raised `OverflowError` where JavaScript reads Infinity;
|
|
46
|
+
- a probe index was written as an exact integer instead of JavaScript's number (`1e+21`).
|
|
47
|
+
These helpers are shared with the estate and identifier kits, whose vectors stay green.
|
|
48
|
+
- **Node looked a rule kind up on inherited members**: `routeProblems("__proto__", …)` threw and `"constructor"`
|
|
49
|
+
answered the value; both now answer `undefined`, as the contract does.
|
|
50
|
+
- **The task board broke the workspace's publication**: rows FAA-28 and FAA-27a split into six cells (an escaped
|
|
51
|
+
`\|`, and a fragment a 0.31.0 edit left behind). Both are fixed, and `test/validate.py` now refuses any board row that
|
|
52
|
+
does not split into the header's columns.
|
|
53
|
+
|
|
54
|
+
### Evidence
|
|
55
|
+
|
|
56
|
+
- 38 new profile cases and 21 new route cases (`make_profile_vectors.mjs`, `make_route_vectors.mjs`), each answered by
|
|
57
|
+
the contract's own rules; cases JavaScript cannot carry as an object (big integers, key order) keep their JSON text.
|
|
58
|
+
Against 0.34.0's kits the first 44 of them fail 27 Python subtests and two Node tests.
|
|
59
|
+
- The reviewer's side-by-side comparison of the contract, the Node kit and the Python kit on 17 hostile inputs: 17 of
|
|
60
|
+
17 identical after the fix (Python 1 of 17 before).
|
|
61
|
+
- Unit tests for the doctor and the rule dispatch on hostile input, in both kits; `BoardRowTests` for the board check.
|
|
62
|
+
- Planted defects in the new code, all caught; two were redundant code, now removed.
|
|
63
|
+
|
|
3
64
|
## 0.34.0 - 2026-10-15
|
|
4
65
|
|
|
5
66
|
The adapter is pinned at contract `d8146cf`. The profile kits now read what a lane reads (DEC-0083; FAA-45, contract
|
package/README.md
CHANGED
|
@@ -40,7 +40,10 @@ and the board's unread count; UserPromptSubmit adds one line only when that coun
|
|
|
40
40
|
session left claimed. Stop, UserPromptSubmit and SessionEnd act only when the running Fabric advertises
|
|
41
41
|
`session-hooks/1`. All are silent in a session Fabric launched, never block the session, read no token and always
|
|
42
42
|
exit 0. `fabric_session.py watch-mail` waits for board mail under a background watcher, and `install-host-hooks
|
|
43
|
-
--host codex|kimi`
|
|
43
|
+
--host codex|kimi|hermes|opencode|openclaw|pi` installs each host's native context bridge (dry run unless `--apply`).
|
|
44
|
+
Codex receives structured SessionStart JSON; Hermes, OpenCode, OpenClaw and Pi use native plugin APIs.
|
|
45
|
+
See the [native host matrix](plugins/fabric-agent-adapter/skills/working-with-fabric/references/native-host-hooks.md)
|
|
46
|
+
for activation, reload and verification limits. The
|
|
44
47
|
[hooks reference](plugins/fabric-agent-adapter/skills/working-with-fabric/references/session-hooks.md) lists what
|
|
45
48
|
they need from Fabric; the [board reference](plugins/fabric-agent-adapter/skills/working-with-fabric/references/project-board.md)
|
|
46
49
|
is the board-first workflow.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@passioncode-ai/fabric-agent-adapter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.0",
|
|
4
4
|
"description": "Create Fabric-compatible agents, run them as always-alive local services with dashboards (fabric-service/0.1), and adapt existing projects to the Fabric Agent Contract. This package is the installer CLI.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "python3 test/validate.py && python3 -m unittest discover -s test -q && node --test 'test/*.test.mjs'"
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"name": "fabric-agent-adapter",
|
|
4
4
|
"displayName": "Fabric Agent Adapter",
|
|
5
5
|
"description": "Create new Fabric-compatible agents, build them as always-alive local services with dashboards (fabric-service/0.1), and adapt existing projects to the Fabric Agent Contract through evidence-backed MCP, A2A, or local-runner provider bundles; and teach a coding agent to work in a project through Fabric (fabric-mcp, fabric_whoami, claim and release), with Claude Code session hooks.",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.35.0",
|
|
7
7
|
"author": {
|
|
8
8
|
"name": "PassionCode.ai",
|
|
9
9
|
"url": "https://passioncode.ai/"
|
|
@@ -5,7 +5,7 @@ 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.
|
|
6
6
|
metadata:
|
|
7
7
|
author: PassionCode.ai
|
|
8
|
-
version: "0.
|
|
8
|
+
version: "0.35.0"
|
|
9
9
|
contract-version: "0.1.0"
|
|
10
10
|
contract-commit: "d8146cfb0a1c74fc6432284c4356bb0c864b37b5"
|
|
11
11
|
---
|
|
@@ -163,12 +163,19 @@ def normal_identifier(value: Any) -> Optional[str]:
|
|
|
163
163
|
return _urn_form(authority, path, query) if scheme.lower() == "urn" else _generic_form(scheme, authority, path, query, fragment)
|
|
164
164
|
|
|
165
165
|
|
|
166
|
+
def _double(value: Any) -> float:
|
|
167
|
+
try:
|
|
168
|
+
return float(value)
|
|
169
|
+
except OverflowError:
|
|
170
|
+
return float("inf") if value > 0 else float("-inf")
|
|
171
|
+
|
|
172
|
+
|
|
166
173
|
def _strict_equal(a: Any, b: Any) -> bool:
|
|
167
174
|
"""JavaScript's === on parsed JSON: numbers by value, booleans only with booleans, objects by identity."""
|
|
168
175
|
if isinstance(a, bool) or isinstance(b, bool):
|
|
169
176
|
return isinstance(a, bool) and isinstance(b, bool) and a == b
|
|
170
177
|
if isinstance(a, (int, float)) and isinstance(b, (int, float)):
|
|
171
|
-
return a == b
|
|
178
|
+
return _double(a) == _double(b) # as JavaScript holds them: 2**53 + 1 is 2**53
|
|
172
179
|
if isinstance(a, (dict, list)) or isinstance(b, (dict, list)):
|
|
173
180
|
return a is b
|
|
174
181
|
return type(a) is type(b) and a == b
|
|
@@ -18,7 +18,7 @@ license: AGPL-3.0-only OR LicenseRef-PassionCode-Commercial
|
|
|
18
18
|
compatibility: Python 3.9+ or Node.js 20+ for the kits; the probe needs Python 3.9+. launchd steps are macOS-only; Linux services install a systemd user unit and Windows ones a per-user Scheduled Task with the kits' writers. Dashboard handoff optionally uses Fabric Dashboards MCP link/host_status/open; without it, report unresolved host capability. The contract checkout is optional.
|
|
19
19
|
metadata:
|
|
20
20
|
author: PassionCode.ai
|
|
21
|
-
version: "0.
|
|
21
|
+
version: "0.35.0"
|
|
22
22
|
contract-version: "0.1.0"
|
|
23
23
|
extension: "fabric-service/0.1"
|
|
24
24
|
extension-commit: "d8146cfb0a1c74fc6432284c4356bb0c864b37b5"
|
|
@@ -39,7 +39,9 @@ and name the policy; never fall back to a model outside it. No level at all is `
|
|
|
39
39
|
(a model catalogued once; a provider never both ordered and ignored, a base slug covering its variants), a
|
|
40
40
|
`model-profiles` set (an id once), a `runner-profile` (a subscription only in its vendor's runner — Claude in Claude
|
|
41
41
|
Code, Kimi in Kimi Code, ChatGPT in Codex; a key route's allow-list is its own model profile; a key named by reference,
|
|
42
|
-
never by value) and a recorded `profile-resolution` (it equals the order's answer).
|
|
42
|
+
never by value) and a recorded `profile-resolution` (it equals the order's answer). Every rule compares as the contract
|
|
43
|
+
does — `===` (`1` and `true` differ, `null` is not absent) and its `jsonEqual` for a recorded resolution, where NaN
|
|
44
|
+
equals nothing — and never raises on hostile JSON: a value whose own `toString` member is data is shown as its JSON.
|
|
43
45
|
|
|
44
46
|
## A lane that reads user content
|
|
45
47
|
|
package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric-profiles.mjs
CHANGED
|
@@ -36,12 +36,25 @@ const show = (value) => {
|
|
|
36
36
|
return JSON.stringify(value) ?? typeof value;
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (
|
|
43
|
-
|
|
39
|
+
/** The contract's jsonEqual: arrays by item, objects by own member whatever the order, anything else by ===, so 1 and
|
|
40
|
+
* true differ and NaN equals nothing (a JSON.stringify comparison would call NaN and null equal). */
|
|
41
|
+
function jsonEqual(a, b) {
|
|
42
|
+
if (Array.isArray(a) || Array.isArray(b)) return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((item, i) => jsonEqual(item, b[i]));
|
|
43
|
+
if (isObject(a) || isObject(b)) {
|
|
44
|
+
if (!isObject(a) || !isObject(b)) return false;
|
|
45
|
+
const keys = Object.keys(a);
|
|
46
|
+
return keys.length === Object.keys(b).length && keys.every((key) => Object.hasOwn(b, key) && jsonEqual(a[key], b[key]));
|
|
47
|
+
}
|
|
48
|
+
return a === b;
|
|
44
49
|
}
|
|
50
|
+
/** The contract's toNumber: Number(value), or NaN where Number() throws (an object whose own toString is data). */
|
|
51
|
+
const toNumber = (value) => {
|
|
52
|
+
try {
|
|
53
|
+
return Number(value);
|
|
54
|
+
} catch {
|
|
55
|
+
return Number.NaN;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
45
58
|
|
|
46
59
|
/** FAC-SEM-060: the request's profile, else the agent's, else the binding's or project's, else the estate default. */
|
|
47
60
|
export function resolveModelProfile({ catalogue, profiles, choices = {}, policy } = {}) {
|
|
@@ -62,7 +75,7 @@ export function resolveModelProfile({ catalogue, profiles, choices = {}, policy
|
|
|
62
75
|
});
|
|
63
76
|
if (within.length) return { from: level, profile: id, models: within };
|
|
64
77
|
const meta = isObject(policy.meta) ? policy.meta : {};
|
|
65
|
-
return { refused: 'model-classes-empty', profile: id, policy: { id:
|
|
78
|
+
return { refused: 'model-classes-empty', profile: id, policy: { id: show(meta.id), revision: toNumber(meta.revision) } };
|
|
66
79
|
}
|
|
67
80
|
|
|
68
81
|
const finding = (code, instancePath, message) => ({ code, instancePath, message });
|
|
@@ -95,12 +108,12 @@ function modelProfiles(value) {
|
|
|
95
108
|
function runnerProfile(value) {
|
|
96
109
|
const findings = [];
|
|
97
110
|
if (value.route === 'subscription' && isObject(value.subscription)) {
|
|
98
|
-
const login =
|
|
111
|
+
const login = show(value.subscription.login);
|
|
99
112
|
const runner = Object.hasOwn(SUBSCRIPTION_RUNNER, login) ? SUBSCRIPTION_RUNNER[login] : undefined;
|
|
100
|
-
if (runner !== value.runnerKind) findings.push(finding('FAC-SEM-059', '/runnerKind', `a ${login} subscription runs only in ${runner ?? "its vendor's runner"}, not in ${
|
|
113
|
+
if (runner !== value.runnerKind) findings.push(finding('FAC-SEM-059', '/runnerKind', `a ${login} subscription runs only in ${runner ?? "its vendor's runner"}, not in ${show(value.runnerKind)}; another runner takes the key route`));
|
|
101
114
|
}
|
|
102
115
|
if (value.route === 'key' && isObject(value.key)) {
|
|
103
|
-
if (value.key.modelAllowList !== value.modelProfile) findings.push(finding('FAC-SEM-059', '/key/modelAllowList', `the key admits the models of ${
|
|
116
|
+
if (value.key.modelAllowList !== value.modelProfile) findings.push(finding('FAC-SEM-059', '/key/modelAllowList', `the key admits the models of ${show(value.key.modelAllowList)}, but the profile runs ${show(value.modelProfile)}`));
|
|
104
117
|
if (typeof value.key.ref === 'string' && secretValue(value.key.ref)) findings.push(finding('FAC-SEM-059', '/key/ref', 'the key is named by its secret reference, never by its value'));
|
|
105
118
|
}
|
|
106
119
|
return findings;
|
|
@@ -167,7 +180,9 @@ function openVendorRoutes(value) {
|
|
|
167
180
|
|
|
168
181
|
/** The contract's profileRules: findings for a model-catalogue, model-profiles, runner-profile or profile-resolution; else undefined. */
|
|
169
182
|
export function profileProblems(kind, value) {
|
|
170
|
-
|
|
183
|
+
const table = { 'model-catalogue': modelCatalogue, 'model-profiles': modelProfiles, 'runner-profile': runnerProfile, 'profile-resolution': (v) => [...profileResolution(v), ...openVendorRoutes(v)] };
|
|
184
|
+
// Own members only: a kind such as `constructor` or `__proto__` names no rule.
|
|
185
|
+
return typeof kind === 'string' && Object.hasOwn(table, kind) ? table[kind](value) : undefined;
|
|
171
186
|
}
|
|
172
187
|
|
|
173
188
|
// ---- the doctor's checks ----
|
|
@@ -231,15 +246,16 @@ export function runnerCheck(entry, { searchPath = process.env.PATH, run = spawnS
|
|
|
231
246
|
|
|
232
247
|
/** Problems with running `model` here: not in the catalogue, or a class the project's policy does not allow. */
|
|
233
248
|
export function modelUsable(model, catalogue, policy) {
|
|
249
|
+
// The last row of an id wins, as the Map the resolver builds; a model that is not a string matches no row.
|
|
234
250
|
const rows = new Map(list(isObject(catalogue) ? catalogue.models : undefined).map((row) => [row.id, row]));
|
|
235
|
-
if (!rows.has(model)) return [`model ${model} is not in the model catalogue`];
|
|
251
|
+
if (typeof model !== 'string' || !rows.has(model)) return [`model ${show(model)} is not in the model catalogue`];
|
|
236
252
|
if (isObject(policy) && Array.isArray(policy.modelClasses)) {
|
|
237
253
|
const allowed = new Set(strings(policy.modelClasses));
|
|
254
|
+
const policyId = show((isObject(policy.meta) ? policy.meta : {}).id);
|
|
238
255
|
const admission = strings(rows.get(model).classes).filter((c) => c !== OPEN_VENDOR);
|
|
239
|
-
const policyId = String((isObject(policy.meta) ? policy.meta : {}).id);
|
|
240
256
|
if (!admission.length) return [`model ${model} has no class but ${OPEN_VENDOR}, which admits nothing, so policy ${policyId} does not allow it`];
|
|
241
257
|
const outside = admission.filter((c) => !allowed.has(c));
|
|
242
|
-
if (outside.length) return [`model ${model} has class ${outside.join(', ')}, which policy ${
|
|
258
|
+
if (outside.length) return [`model ${model} has class ${outside.join(', ')}, which policy ${policyId} does not allow`];
|
|
243
259
|
}
|
|
244
260
|
return [];
|
|
245
261
|
}
|
|
@@ -277,14 +293,14 @@ export const PROBE_RESULTS = Object.freeze(['not-catalogued', 'not-admitted', 'n
|
|
|
277
293
|
const routeCandidates = (value) => (Array.isArray(value?.candidates) ? value.candidates.filter(isObject) : []);
|
|
278
294
|
const objectAt = (value, key) => (isObject(value?.[key]) ? value[key] : {});
|
|
279
295
|
// A revision reference compared whole; its id is an identifier, so it enters the key in its normal form (DEC-0076).
|
|
280
|
-
const refKey = (ref) => (isObject(ref) ? `${
|
|
296
|
+
const refKey = (ref) => (isObject(ref) ? `${show(normalIdentifier(ref.id) ?? ref.id)}@${show(ref.revision)}#${show(ref.contentHash)}` : '');
|
|
281
297
|
const sameRef = (a, b) => refKey(a) !== '' && refKey(a) === refKey(b);
|
|
282
298
|
|
|
283
299
|
function runnerRoute(value) {
|
|
284
300
|
const findings = [];
|
|
285
301
|
const kinds = new Set();
|
|
286
302
|
routeCandidates(value).forEach((candidate, index) => {
|
|
287
|
-
const kind =
|
|
303
|
+
const kind = show(candidate.runnerKind);
|
|
288
304
|
if (kinds.has(kind)) findings.push(finding('FAC-SEM-028', `/candidates/${index}/runnerKind`, `runner kind ${kind} appears in the route more than once`));
|
|
289
305
|
kinds.add(kind);
|
|
290
306
|
const session = objectAt(candidate, 'session');
|
|
@@ -300,25 +316,25 @@ function routeBundle(value) {
|
|
|
300
316
|
const findings = [];
|
|
301
317
|
routeCandidates(route).forEach((candidate, index) => {
|
|
302
318
|
const key = refKey(candidate.provider);
|
|
303
|
-
if (!admitted.has(key)) findings.push(finding('FAC-SEM-030', `/route/candidates/${index}/provider`, `candidate ${
|
|
319
|
+
if (!admitted.has(key)) findings.push(finding('FAC-SEM-030', `/route/candidates/${index}/provider`, `candidate ${show(candidate.runnerKind)} names provider ${key}, which is not a revision admitted for ${show(route.capability)}`));
|
|
304
320
|
});
|
|
305
321
|
if (isObject(value.binding)) {
|
|
306
322
|
const binding = value.binding;
|
|
307
323
|
const disagree = (where, message) => findings.push(finding('FAC-SEM-032', `/binding/${where}`, message));
|
|
308
324
|
// DEC-0076: project and capability are identifiers, compared by normal form.
|
|
309
|
-
if (!sameIdentifier(binding.project, route.project)) disagree('project', `the binding is for ${
|
|
310
|
-
if (!sameIdentifier(binding.capability, route.capability)) disagree('capability', `the binding binds ${
|
|
311
|
-
if (binding.profileKind !== 'local-runner') disagree('profileKind', `a runner route serves the local-runner profile, not ${
|
|
325
|
+
if (!sameIdentifier(binding.project, route.project)) disagree('project', `the binding is for ${show(binding.project)}, the route for ${show(route.project)}`);
|
|
326
|
+
if (!sameIdentifier(binding.capability, route.capability)) disagree('capability', `the binding binds ${show(binding.capability)}, the route orders ${show(route.capability)}`);
|
|
327
|
+
if (binding.profileKind !== 'local-runner') disagree('profileKind', `a runner route serves the local-runner profile, not ${show(binding.profileKind)}`);
|
|
312
328
|
if (!routeCandidates(route).some((c) => sameRef(c.provider, binding.provider))) disagree('provider', `the binding's provider ${refKey(binding.provider)} is not a candidate of the route`);
|
|
313
329
|
if (binding.runnerRoute !== undefined && !sameRef(binding.runnerRoute, route.meta)) disagree('runnerRoute', `the binding pins ${refKey(binding.runnerRoute)}, not this route ${refKey(route.meta)}`);
|
|
314
330
|
}
|
|
315
331
|
if (Array.isArray(value.catalogue)) {
|
|
316
|
-
const byKind = new Map(value.catalogue.filter(isObject).map((entry) => [
|
|
332
|
+
const byKind = new Map(value.catalogue.filter(isObject).map((entry) => [show(entry.kind), entry]));
|
|
317
333
|
routeCandidates(route).forEach((candidate, index) => {
|
|
318
|
-
const kind =
|
|
334
|
+
const kind = show(candidate.runnerKind);
|
|
319
335
|
const entry = byKind.get(kind);
|
|
320
336
|
if (!entry) { findings.push(finding('FAC-SEM-033', `/route/candidates/${index}/runnerKind`, `runner kind ${kind} has no entry in the host's catalogue`)); return; }
|
|
321
|
-
if (candidate.drive !== undefined && !Object.hasOwn(objectAt(entry, 'drives'),
|
|
337
|
+
if (candidate.drive !== undefined && !Object.hasOwn(objectAt(entry, 'drives'), show(candidate.drive))) findings.push(finding('FAC-SEM-033', `/route/candidates/${index}/drive`, `the catalogue entry for ${kind} offers no drive ${show(candidate.drive)}`));
|
|
322
338
|
});
|
|
323
339
|
}
|
|
324
340
|
return findings;
|
|
@@ -331,14 +347,14 @@ function routeEvent(value) {
|
|
|
331
347
|
const findings = [];
|
|
332
348
|
const wrong = (where, message) => findings.push(finding('FAC-SEM-034', `/event${where}`, message));
|
|
333
349
|
if (!sameRef(event.route, route.meta)) wrong('/route', `the event names route ${refKey(event.route)}, not ${refKey(route.meta)}`);
|
|
334
|
-
if (!sameIdentifier(event.project, route.project)) wrong('/project', `the event is for ${
|
|
335
|
-
if (!sameIdentifier(event.capability, route.capability)) wrong('/capability', `the event names ${
|
|
350
|
+
if (!sameIdentifier(event.project, route.project)) wrong('/project', `the event is for ${show(event.project)}, the route for ${show(route.project)}`);
|
|
351
|
+
if (!sameIdentifier(event.capability, route.capability)) wrong('/capability', `the event names ${show(event.capability)}, the route orders ${show(route.capability)}`);
|
|
336
352
|
const indexOf = (ref) => (typeof ref.index === 'number' && Number.isInteger(ref.index) ? ref.index : -1);
|
|
337
353
|
const candidateAt = (ref, where) => {
|
|
338
354
|
const index = indexOf(ref);
|
|
339
355
|
const candidate = index >= 0 ? list[index] : undefined;
|
|
340
356
|
if (!candidate || candidate.runnerKind !== ref.runnerKind || (ref.provider !== undefined && !sameRef(candidate.provider, ref.provider))) {
|
|
341
|
-
wrong(where, `candidate ${
|
|
357
|
+
wrong(where, `candidate ${show(ref.index)} (${show(ref.runnerKind)}) is not that position of the route`);
|
|
342
358
|
return undefined;
|
|
343
359
|
}
|
|
344
360
|
return candidate;
|
|
@@ -346,8 +362,8 @@ function routeEvent(value) {
|
|
|
346
362
|
const probes = Array.isArray(event.probes) ? event.probes.filter(isObject) : [];
|
|
347
363
|
probes.forEach((probe, position) => {
|
|
348
364
|
const candidate = candidateAt(probe, `/probes/${position}`);
|
|
349
|
-
if (candidate && probe.result === 'no-held-session' && objectAt(candidate, 'session').spawn !== 'never') wrong(`/probes/${position}/result`, `${
|
|
350
|
-
if (candidate && probe.result === 'spawn-failed' && objectAt(candidate, 'session').spawn !== 'allowed') wrong(`/probes/${position}/result`, `${
|
|
365
|
+
if (candidate && probe.result === 'no-held-session' && objectAt(candidate, 'session').spawn !== 'never') wrong(`/probes/${position}/result`, `${show(probe.runnerKind)} may spawn, so finding no held session does not pass it over`);
|
|
366
|
+
if (candidate && probe.result === 'spawn-failed' && objectAt(candidate, 'session').spawn !== 'allowed') wrong(`/probes/${position}/result`, `${show(probe.runnerKind)} has spawn: never, so it cannot have failed to spawn`);
|
|
351
367
|
});
|
|
352
368
|
const expectProbes = (count) => {
|
|
353
369
|
const indexes = probes.map(indexOf);
|
|
@@ -365,9 +381,9 @@ function routeEvent(value) {
|
|
|
365
381
|
const chosen = candidateAt(selected, '/selected');
|
|
366
382
|
if (chosen) {
|
|
367
383
|
const session = objectAt(chosen, 'session');
|
|
368
|
-
if (selected.session === 'attached' && session.attach !== 'preferred') wrong('/selected/session', `${
|
|
369
|
-
if (selected.session === 'spawned' && session.spawn !== 'allowed') wrong('/selected/session', `${
|
|
370
|
-
if (chosen.drive !== undefined && selected.drive !== undefined && selected.drive !== chosen.drive) wrong('/selected/drive', `the route runs ${
|
|
384
|
+
if (selected.session === 'attached' && session.attach !== 'preferred') wrong('/selected/session', `${show(selected.runnerKind)} has attach: never, so the host cannot attach it`);
|
|
385
|
+
if (selected.session === 'spawned' && session.spawn !== 'allowed') wrong('/selected/session', `${show(selected.runnerKind)} has spawn: never, so the host cannot spawn it`);
|
|
386
|
+
if (chosen.drive !== undefined && selected.drive !== undefined && selected.drive !== chosen.drive) wrong('/selected/drive', `the route runs ${show(selected.runnerKind)} through ${show(chosen.drive)}, not ${show(selected.drive)}`);
|
|
371
387
|
if (event.sticky === true) {
|
|
372
388
|
// A sticky relaunch keeps the conversation's runner and walks nothing above it.
|
|
373
389
|
if (route.recovery === 'reprobe') wrong('/sticky', 'a route with recovery: reprobe walks from the top at every launch');
|
|
@@ -394,5 +410,6 @@ function routeEvent(value) {
|
|
|
394
410
|
*/
|
|
395
411
|
export function routeProblems(kind, value) {
|
|
396
412
|
if (!isObject(value)) return undefined;
|
|
397
|
-
|
|
413
|
+
const table = { 'runner-route': runnerRoute, 'route-bundle': routeBundle, 'route-event': routeEvent };
|
|
414
|
+
return typeof kind === 'string' && Object.hasOwn(table, kind) ? table[kind](value) : undefined;
|
|
398
415
|
}
|
package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_estate.py
CHANGED
|
@@ -90,6 +90,14 @@ def _number(value: Any) -> bool:
|
|
|
90
90
|
return isinstance(value, (int, float)) and not isinstance(value, bool)
|
|
91
91
|
|
|
92
92
|
|
|
93
|
+
def _double(value: Any) -> float:
|
|
94
|
+
"""A JSON number as JavaScript holds it: the nearest double, and an integer beyond the double range ±Infinity."""
|
|
95
|
+
try:
|
|
96
|
+
return float(value)
|
|
97
|
+
except OverflowError:
|
|
98
|
+
return math.inf if value > 0 else -math.inf
|
|
99
|
+
|
|
100
|
+
|
|
93
101
|
def _same(a: Any, b: Any) -> bool:
|
|
94
102
|
"""JavaScript's === (and a Set's SameValueZero) on parsed JSON: an object equals only itself."""
|
|
95
103
|
if a is _MISSING or b is _MISSING:
|
|
@@ -99,7 +107,7 @@ def _same(a: Any, b: Any) -> bool:
|
|
|
99
107
|
if isinstance(a, bool) or isinstance(b, bool):
|
|
100
108
|
return isinstance(a, bool) and isinstance(b, bool) and a == b
|
|
101
109
|
if _number(a) and _number(b):
|
|
102
|
-
return a == b
|
|
110
|
+
return _double(a) == _double(b) # 2**53 + 1 is 2**53 in JavaScript
|
|
103
111
|
return type(a) is type(b) and a == b
|
|
104
112
|
|
|
105
113
|
|
|
@@ -137,7 +145,7 @@ def _js_to_number(value: Any) -> float:
|
|
|
137
145
|
radix = _JS_RADIX.fullmatch(text)
|
|
138
146
|
if radix:
|
|
139
147
|
digits, base = next((radix.group(k), b) for k, b in (("x", 16), ("o", 8), ("b", 2)) if radix.group(k))
|
|
140
|
-
return
|
|
148
|
+
return _double(int(digits, base))
|
|
141
149
|
return math.nan
|
|
142
150
|
|
|
143
151
|
|
|
@@ -173,10 +181,37 @@ def _strict_string(value: Any) -> str:
|
|
|
173
181
|
return _js_string(value)
|
|
174
182
|
|
|
175
183
|
|
|
184
|
+
_INDEX_KEY = re.compile(r"0|[1-9][0-9]*", re.ASCII)
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def _js_keys(value: Dict[str, Any]) -> List[str]:
|
|
188
|
+
"""An object's own keys in the order JavaScript lists them: array-index keys ("0" … "4294967294", no leading zero)
|
|
189
|
+
ascending, then the others in the order written."""
|
|
190
|
+
index = sorted((k for k in value if _INDEX_KEY.fullmatch(k) and int(k) <= 2 ** 32 - 2), key=int)
|
|
191
|
+
taken = set(index)
|
|
192
|
+
return index + [k for k in value if k not in taken]
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def _js_json_string(text: str) -> str:
|
|
196
|
+
"""JSON.stringify of a string (well-formed, ES2019): a lone surrogate is escaped as \\uXXXX, never refused."""
|
|
197
|
+
out = ['"']
|
|
198
|
+
for ch in text:
|
|
199
|
+
code = ord(ch)
|
|
200
|
+
if ch in _delegation._ESCAPES:
|
|
201
|
+
out.append(_delegation._ESCAPES[ch])
|
|
202
|
+
elif code < 0x20 or 0xD800 <= code <= 0xDFFF:
|
|
203
|
+
out.append("\\u%04x" % code)
|
|
204
|
+
else:
|
|
205
|
+
out.append(ch)
|
|
206
|
+
out.append('"')
|
|
207
|
+
return "".join(out)
|
|
208
|
+
|
|
209
|
+
|
|
176
210
|
def _json_stringify(value: Any) -> str:
|
|
177
|
-
"""JSON.stringify for a parsed JSON value: members in
|
|
211
|
+
"""JSON.stringify for a parsed JSON value: members in JavaScript's key order, numbers as JavaScript writes them, a
|
|
212
|
+
lone surrogate escaped."""
|
|
178
213
|
if isinstance(value, dict):
|
|
179
|
-
return "{" + ",".join(
|
|
214
|
+
return "{" + ",".join(_js_json_string(k) + ":" + _json_stringify(value[k]) for k in _js_keys(value)) + "}"
|
|
180
215
|
if isinstance(value, list):
|
|
181
216
|
return "[" + ",".join(_json_stringify(v) for v in value) + "]"
|
|
182
217
|
if value is None:
|
|
@@ -186,7 +221,7 @@ def _json_stringify(value: Any) -> str:
|
|
|
186
221
|
if _number(value):
|
|
187
222
|
text = _js_string(value)
|
|
188
223
|
return "null" if text in ("NaN", "Infinity", "-Infinity") else text
|
|
189
|
-
return
|
|
224
|
+
return _js_json_string(value)
|
|
190
225
|
|
|
191
226
|
|
|
192
227
|
def _show(value: Any) -> str:
|
package/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_identifiers.py
CHANGED
|
@@ -163,12 +163,19 @@ def normal_identifier(value: Any) -> Optional[str]:
|
|
|
163
163
|
return _urn_form(authority, path, query) if scheme.lower() == "urn" else _generic_form(scheme, authority, path, query, fragment)
|
|
164
164
|
|
|
165
165
|
|
|
166
|
+
def _double(value: Any) -> float:
|
|
167
|
+
try:
|
|
168
|
+
return float(value)
|
|
169
|
+
except OverflowError:
|
|
170
|
+
return float("inf") if value > 0 else float("-inf")
|
|
171
|
+
|
|
172
|
+
|
|
166
173
|
def _strict_equal(a: Any, b: Any) -> bool:
|
|
167
174
|
"""JavaScript's === on parsed JSON: numbers by value, booleans only with booleans, objects by identity."""
|
|
168
175
|
if isinstance(a, bool) or isinstance(b, bool):
|
|
169
176
|
return isinstance(a, bool) and isinstance(b, bool) and a == b
|
|
170
177
|
if isinstance(a, (int, float)) and isinstance(b, (int, float)):
|
|
171
|
-
return a == b
|
|
178
|
+
return _double(a) == _double(b) # as JavaScript holds them: 2**53 + 1 is 2**53
|
|
172
179
|
if isinstance(a, (dict, list)) or isinstance(b, (dict, list)):
|
|
173
180
|
return a is b
|
|
174
181
|
return type(a) is type(b) and a == b
|