@passioncode-ai/passioncode 0.2.6 → 0.2.8
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 +17 -0
- package/family.json +1 -1
- package/package.json +1 -1
- package/payload/.claude-plugin/marketplace.json +2 -2
- package/payload/manifest.json +8 -8
- package/payload/plugins/fabric-agent-adapter/.claude-plugin/plugin.json +1 -1
- package/payload/plugins/fabric-agent-adapter/skills/adapting-projects-to-fabric/SKILL.md +1 -1
- package/payload/plugins/fabric-agent-adapter/skills/adapting-projects-to-fabric/scripts/fabric_identifiers.py +8 -1
- package/payload/plugins/fabric-agent-adapter/skills/building-fabric-services/SKILL.md +1 -1
- package/payload/plugins/fabric-agent-adapter/skills/building-fabric-services/references/profiles.md +3 -1
- package/payload/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric-profiles.mjs +48 -31
- package/payload/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_estate.py +40 -5
- package/payload/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_identifiers.py +8 -1
- package/payload/plugins/fabric-agent-adapter/skills/building-fabric-services/scripts/fabric_profiles.py +67 -65
- package/payload/plugins/fabric-agent-adapter/skills/creating-fabric-agents/SKILL.md +1 -1
- package/payload/plugins/fabric-agent-adapter/skills/working-with-fabric/SKILL.md +8 -6
- package/payload/plugins/fabric-agent-adapter/skills/working-with-fabric/references/native-host-hooks.md +53 -0
- package/payload/plugins/fabric-agent-adapter/skills/working-with-fabric/references/session-hooks.md +5 -1
- package/payload/plugins/fabric-agent-adapter/skills/working-with-fabric/scripts/fabric_session.py +30 -11
- package/payload/plugins/fabric-agent-adapter/skills/working-with-fabric/scripts/host_hooks.py +178 -0
- package/payload/plugins/fabric-agent-adapter/skills/working-with-fabric/scripts/hosts/context.mjs +33 -0
- package/payload/plugins/fabric-agent-adapter/skills/working-with-fabric/scripts/hosts/hermes/__init__.py +135 -0
- package/payload/plugins/fabric-agent-adapter/skills/working-with-fabric/scripts/hosts/hermes/plugin.yaml +5 -0
- package/payload/plugins/fabric-agent-adapter/skills/working-with-fabric/scripts/hosts/openclaw/index.mjs +45 -0
- package/payload/plugins/fabric-agent-adapter/skills/working-with-fabric/scripts/hosts/openclaw/openclaw.plugin.json +11 -0
- package/payload/plugins/fabric-agent-adapter/skills/working-with-fabric/scripts/hosts/openclaw/package.json +10 -0
- package/payload/plugins/fabric-agent-adapter/skills/working-with-fabric/scripts/hosts/opencode/fabric.mjs +24 -0
- package/payload/plugins/fabric-agent-adapter/skills/working-with-fabric/scripts/hosts/pi/fabric.mjs +36 -0
- package/payload/plugins/passioncode/.claude-plugin/plugin.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.8 - 2026-10-16
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- Fabric Agent Adapter is pinned at `v0.35.0` (previously `v0.34.1`), carrying
|
|
8
|
+
host-specific session hooks and their installation and verification tools.
|
|
9
|
+
See the [adapter release](https://github.com/passioncode-ai/fabric-agent-adapter/releases/tag/v0.35.0)
|
|
10
|
+
for supported hosts and activation requirements.
|
|
11
|
+
|
|
12
|
+
## 0.2.7 - 2026-10-15
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- **Fabric Agent Adapter is pinned at `v0.34.1`** (it was `v0.34.0`). v0.34.1 makes its profile and route rules
|
|
17
|
+
answer as the contract does on any JSON — strict comparisons, values shown as JavaScript writes them, numbers as
|
|
18
|
+
doubles — and the doctor's model check never raises (FAA-47).
|
|
19
|
+
|
|
3
20
|
## 0.2.6 - 2026-10-15
|
|
4
21
|
|
|
5
22
|
### Changed
|
package/family.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@passioncode-ai/passioncode",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"description": "Set up PassionCode.ai on a computer with one command — the apps from their verified releases, their MCP servers for every coding agent and the PassionCode.ai skills — and check and repair it with the same command or `doctor`.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"passioncode": "bin/passioncode.js"
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"name": "fabric-agent-adapter",
|
|
12
12
|
"displayName": "Fabric Agent Adapter",
|
|
13
13
|
"source": "./plugins/fabric-agent-adapter",
|
|
14
|
-
"version": "0.
|
|
14
|
+
"version": "0.35.0",
|
|
15
15
|
"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.",
|
|
16
16
|
"author": {
|
|
17
17
|
"name": "PassionCode.ai",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"name": "passioncode",
|
|
36
36
|
"displayName": "PassionCode.ai",
|
|
37
37
|
"source": "./plugins/passioncode",
|
|
38
|
-
"version": "0.2.
|
|
38
|
+
"version": "0.2.8",
|
|
39
39
|
"description": "Set up and check PassionCode.ai on a computer with one command (setting-up-passioncode), the organisation's working rules for every contributor's agent (working-in-passioncode), and a once-a-day check that keeps the PassionCode.ai set current.",
|
|
40
40
|
"author": {
|
|
41
41
|
"name": "PassionCode.ai",
|
package/payload/manifest.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"family": "passioncode",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"release": true,
|
|
5
5
|
"members": [
|
|
6
6
|
{
|
|
7
7
|
"name": "fabric-agent-adapter",
|
|
8
8
|
"displayName": "Fabric Agent Adapter",
|
|
9
9
|
"repo": "passioncode-ai/fabric-agent-adapter",
|
|
10
|
-
"ref": "v0.
|
|
11
|
-
"commit": "
|
|
12
|
-
"version": "0.
|
|
10
|
+
"ref": "v0.35.0",
|
|
11
|
+
"commit": "766dde0abadd929bcdb88a0d90fed23c114c3a7a",
|
|
12
|
+
"version": "0.35.0",
|
|
13
13
|
"via": "clone of https://***@github.com/passioncode-ai/fabric-agent-adapter.git",
|
|
14
14
|
"skills": [
|
|
15
15
|
"adapting-projects-to-fabric",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"legacyMarketplaces": [
|
|
24
24
|
"fabric-agent-adapter"
|
|
25
25
|
],
|
|
26
|
-
"contentHash": "sha256:
|
|
26
|
+
"contentHash": "sha256:6890c665e564ff5215ee809843622120bccf33b1a44d0499556d71058b958823",
|
|
27
27
|
"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.",
|
|
28
28
|
"author": {
|
|
29
29
|
"name": "PassionCode.ai",
|
|
@@ -62,9 +62,9 @@
|
|
|
62
62
|
"name": "passioncode",
|
|
63
63
|
"displayName": "PassionCode.ai",
|
|
64
64
|
"repo": "passioncode-ai/passioncode",
|
|
65
|
-
"ref": "v0.2.
|
|
65
|
+
"ref": "v0.2.8",
|
|
66
66
|
"commit": null,
|
|
67
|
-
"version": "0.2.
|
|
67
|
+
"version": "0.2.8",
|
|
68
68
|
"via": "this repository",
|
|
69
69
|
"skills": [
|
|
70
70
|
"setting-up-passioncode",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
],
|
|
73
73
|
"legacyPluginIds": [],
|
|
74
74
|
"legacyMarketplaces": [],
|
|
75
|
-
"contentHash": "sha256:
|
|
75
|
+
"contentHash": "sha256:055dcaab6c5986459556cf3bb5a472c9e7b6bad49562ac1d883def31d03d98a6",
|
|
76
76
|
"description": "Set up and check PassionCode.ai on a computer with one command (setting-up-passioncode), the organisation's working rules for every contributor's agent (working-in-passioncode), and a once-a-day check that keeps the PassionCode.ai set current.",
|
|
77
77
|
"author": {
|
|
78
78
|
"name": "PassionCode.ai",
|
|
@@ -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"
|
package/payload/plugins/fabric-agent-adapter/skills/building-fabric-services/references/profiles.md
CHANGED
|
@@ -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
|
|
|
@@ -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
|
}
|
|
@@ -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:
|
|
@@ -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
|