knosky 0.6.3 → 0.7.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 +149 -93
- package/CREDITS.md +14 -14
- package/LICENSE.md +76 -76
- package/LIMITATIONS.md +33 -23
- package/PRIVACY.md +30 -30
- package/README.md +170 -117
- package/SECURITY.md +78 -46
- package/action/post-comment.mjs +94 -89
- package/action.yml +62 -62
- package/bin/knosky.mjs +279 -105
- package/core/CONTRACT.md +70 -70
- package/core/append-only-checkpoint.mjs +215 -0
- package/core/audit-writer.mjs +317 -0
- package/core/benchmark-results.mjs +225 -225
- package/core/bundle.mjs +178 -178
- package/core/churn.mjs +23 -23
- package/core/ci.mjs +268 -268
- package/core/comparison.mjs +189 -189
- package/core/config.mjs +189 -189
- package/core/constants.mjs +13 -13
- package/core/contract.mjs +123 -123
- package/core/cross-repo.mjs +111 -111
- package/core/decision-codes.mjs +92 -0
- package/core/destination.mjs +161 -161
- package/core/district-classification.mjs +111 -0
- package/core/doctor-scorecard.mjs +369 -0
- package/core/domain-store.mjs +347 -0
- package/core/edges.mjs +43 -43
- package/core/escalate.mjs +68 -68
- package/core/freshness.mjs +198 -194
- package/core/fs-indexer.mjs +218 -218
- package/core/key-store.mjs +348 -348
- package/core/layout.mjs +46 -46
- package/core/ledger.mjs +176 -141
- package/core/local-ipc-identity.mjs +500 -0
- package/core/lod.mjs +155 -155
- package/core/mode-b.mjs +410 -0
- package/core/multi-model-benchmark.mjs +405 -405
- package/core/net-lockdown.mjs +421 -0
- package/core/onboarding.mjs +223 -223
- package/core/operator-auth.mjs +317 -0
- package/core/overlays.mjs +45 -45
- package/core/policy-lattice.mjs +142 -0
- package/core/pr-comment.mjs +198 -198
- package/core/protocol-spec.mjs +460 -460
- package/core/provenance.mjs +320 -0
- package/core/retrieve.mjs +63 -63
- package/core/route.mjs +304 -304
- package/core/schema.mjs +275 -275
- package/core/signing-tiers.mjs +1265 -0
- package/core/swarm-bench.mjs +106 -0
- package/core/swarm-coordinator.mjs +867 -0
- package/core/trust-root-rekey.mjs +410 -0
- package/mcp/server.mjs +264 -108
- package/package.json +56 -46
- package/renderer/art/kenney/buildingTiles_sheet.xml +130 -130
- package/renderer/art/kenney/cityDetails_sheet.xml +12 -12
- package/renderer/art/kenney/landscapeTiles_sheet.xml +129 -129
- package/renderer/art/kenney/sheet_allCars.xml +545 -545
- package/renderer/build-rich.mjs +43 -43
- package/renderer/city.template.html +808 -808
- package/ssot/decision-codes.json +133 -0
- package/ssot/ladder-l0-l3.md +232 -0
- package/ssot/tool-menu.json +130 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// Simple swarm benchmark harness (DEC-113 remaining — L3 foundation measure).
|
|
2
|
+
// Runs two agents: claim conflict + quota path; emits JSON summary. No network.
|
|
3
|
+
|
|
4
|
+
import { mkdtempSync, rmSync } from 'node:fs';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { tmpdir } from 'node:os';
|
|
7
|
+
import { createSwarmCoordinator } from './swarm-coordinator.mjs';
|
|
8
|
+
import { registerAgentWithLease, loadDomain } from './domain-store.mjs';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @param {object} [opts]
|
|
12
|
+
* @param {string} [opts.domainRoot]
|
|
13
|
+
* @returns {{ ok: boolean, metrics: object, events: object[] }}
|
|
14
|
+
*/
|
|
15
|
+
export function runSwarmBench(opts = {}) {
|
|
16
|
+
const tmp = opts.domainRoot
|
|
17
|
+
? null
|
|
18
|
+
: mkdtempSync(join(tmpdir(), 'ks-swarm-bench-'));
|
|
19
|
+
const domainRoot = opts.domainRoot || join(tmp, '.knosky');
|
|
20
|
+
const events = [];
|
|
21
|
+
const t0 = Date.now();
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
const domain = loadDomain(domainRoot);
|
|
25
|
+
const a = registerAgentWithLease(domain, {
|
|
26
|
+
agentId: 'bench-a',
|
|
27
|
+
classes: ['public', 'internal'],
|
|
28
|
+
});
|
|
29
|
+
if (!a.ok) throw new Error('register A failed: ' + a.reason);
|
|
30
|
+
const b = registerAgentWithLease(domain, {
|
|
31
|
+
agentId: 'bench-b',
|
|
32
|
+
classes: ['public', 'internal'],
|
|
33
|
+
});
|
|
34
|
+
if (!b.ok) throw new Error('register B failed: ' + b.reason);
|
|
35
|
+
const coord = createSwarmCoordinator({
|
|
36
|
+
domainRoot,
|
|
37
|
+
domain: loadDomain(domainRoot),
|
|
38
|
+
quotas: {
|
|
39
|
+
maxClaimsPerAgent: 2,
|
|
40
|
+
maxActionsPerWindow: 50,
|
|
41
|
+
antiProbeDenyThreshold: 20,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// A claims a file
|
|
46
|
+
const c1 = coord.claim({
|
|
47
|
+
agentId: a.agentId,
|
|
48
|
+
leaseId: a.leaseId,
|
|
49
|
+
resource: 'file:src/bench.js',
|
|
50
|
+
kind: 'file',
|
|
51
|
+
});
|
|
52
|
+
events.push({ step: 'a_claim', ok: c1.ok, code: c1.decision_code || c1.reason });
|
|
53
|
+
|
|
54
|
+
// B conflicts
|
|
55
|
+
const c2 = coord.claim({
|
|
56
|
+
agentId: b.agentId,
|
|
57
|
+
leaseId: b.leaseId,
|
|
58
|
+
resource: 'file:src/bench.js',
|
|
59
|
+
kind: 'file',
|
|
60
|
+
});
|
|
61
|
+
events.push({
|
|
62
|
+
step: 'b_conflict',
|
|
63
|
+
ok: !c2.ok,
|
|
64
|
+
code: c2.decision_code || c2.reason,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// Quota pressure on A
|
|
68
|
+
coord.claim({
|
|
69
|
+
agentId: a.agentId,
|
|
70
|
+
leaseId: a.leaseId,
|
|
71
|
+
resource: 'file:src/b2.js',
|
|
72
|
+
kind: 'file',
|
|
73
|
+
});
|
|
74
|
+
const c3 = coord.claim({
|
|
75
|
+
agentId: a.agentId,
|
|
76
|
+
leaseId: a.leaseId,
|
|
77
|
+
resource: 'file:src/b3.js',
|
|
78
|
+
kind: 'file',
|
|
79
|
+
});
|
|
80
|
+
events.push({
|
|
81
|
+
step: 'a_quota',
|
|
82
|
+
ok: !c3.ok || c3.reason === 'quota_claims' || c3.decision_code === 'DENY',
|
|
83
|
+
code: c3.decision_code || c3.reason,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const heat = coord.writeHeatmap();
|
|
87
|
+
const ms = Date.now() - t0;
|
|
88
|
+
const metrics = {
|
|
89
|
+
duration_ms: ms,
|
|
90
|
+
conflict_detected: events.find((e) => e.step === 'b_conflict')?.ok === true,
|
|
91
|
+
quota_enforced: events.find((e) => e.step === 'a_quota')?.ok === true,
|
|
92
|
+
heatmap_written: !!heat?.ok,
|
|
93
|
+
agents: 2,
|
|
94
|
+
};
|
|
95
|
+
const ok = metrics.conflict_detected && metrics.quota_enforced && metrics.heatmap_written;
|
|
96
|
+
return { ok, metrics, events, domainRoot, heatmapPath: heat?.path };
|
|
97
|
+
} finally {
|
|
98
|
+
if (tmp) {
|
|
99
|
+
try {
|
|
100
|
+
rmSync(tmp, { recursive: true, force: true });
|
|
101
|
+
} catch {
|
|
102
|
+
/* ignore */
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|