agent-passport-system 1.18.1 → 1.19.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/README.md +6 -6
- package/dist/src/v2/affected-party.d.ts +53 -0
- package/dist/src/v2/affected-party.d.ts.map +1 -0
- package/dist/src/v2/affected-party.js +80 -0
- package/dist/src/v2/affected-party.js.map +1 -0
- package/dist/src/v2/amendment.d.ts +40 -0
- package/dist/src/v2/amendment.d.ts.map +1 -0
- package/dist/src/v2/amendment.js +69 -0
- package/dist/src/v2/amendment.js.map +1 -0
- package/dist/src/v2/approval-fatigue.d.ts +37 -0
- package/dist/src/v2/approval-fatigue.d.ts.map +1 -0
- package/dist/src/v2/approval-fatigue.js +206 -0
- package/dist/src/v2/approval-fatigue.js.map +1 -0
- package/dist/src/v2/blind-evaluation.d.ts +42 -0
- package/dist/src/v2/blind-evaluation.d.ts.map +1 -0
- package/dist/src/v2/blind-evaluation.js +77 -0
- package/dist/src/v2/blind-evaluation.js.map +1 -0
- package/dist/src/v2/cascade-correlation.d.ts +35 -0
- package/dist/src/v2/cascade-correlation.d.ts.map +1 -0
- package/dist/src/v2/cascade-correlation.js +101 -0
- package/dist/src/v2/cascade-correlation.js.map +1 -0
- package/dist/src/v2/circuit-breakers.d.ts +37 -0
- package/dist/src/v2/circuit-breakers.d.ts.map +1 -0
- package/dist/src/v2/circuit-breakers.js +79 -0
- package/dist/src/v2/circuit-breakers.js.map +1 -0
- package/dist/src/v2/composite-audit.d.ts +19 -0
- package/dist/src/v2/composite-audit.d.ts.map +1 -0
- package/dist/src/v2/composite-audit.js +117 -0
- package/dist/src/v2/composite-audit.js.map +1 -0
- package/dist/src/v2/cross-chain-audit.d.ts +34 -0
- package/dist/src/v2/cross-chain-audit.d.ts.map +1 -0
- package/dist/src/v2/cross-chain-audit.js +32 -0
- package/dist/src/v2/cross-chain-audit.js.map +1 -0
- package/dist/src/v2/effect-enforcement.d.ts +38 -0
- package/dist/src/v2/effect-enforcement.d.ts.map +1 -0
- package/dist/src/v2/effect-enforcement.js +146 -0
- package/dist/src/v2/effect-enforcement.js.map +1 -0
- package/dist/src/v2/effect-sampling.d.ts +53 -0
- package/dist/src/v2/effect-sampling.d.ts.map +1 -0
- package/dist/src/v2/effect-sampling.js +74 -0
- package/dist/src/v2/effect-sampling.js.map +1 -0
- package/dist/src/v2/emergence.d.ts +25 -0
- package/dist/src/v2/emergence.d.ts.map +1 -0
- package/dist/src/v2/emergence.js +164 -0
- package/dist/src/v2/emergence.js.map +1 -0
- package/dist/src/v2/epistemic-isolation.d.ts +47 -0
- package/dist/src/v2/epistemic-isolation.d.ts.map +1 -0
- package/dist/src/v2/epistemic-isolation.js +85 -0
- package/dist/src/v2/epistemic-isolation.js.map +1 -0
- package/dist/src/v2/externality.d.ts +39 -0
- package/dist/src/v2/externality.d.ts.map +1 -0
- package/dist/src/v2/externality.js +54 -0
- package/dist/src/v2/externality.js.map +1 -0
- package/dist/src/v2/governance-drift.d.ts +53 -0
- package/dist/src/v2/governance-drift.d.ts.map +1 -0
- package/dist/src/v2/governance-drift.js +125 -0
- package/dist/src/v2/governance-drift.js.map +1 -0
- package/dist/src/v2/inaction-audit.d.ts +43 -0
- package/dist/src/v2/inaction-audit.d.ts.map +1 -0
- package/dist/src/v2/inaction-audit.js +60 -0
- package/dist/src/v2/inaction-audit.js.map +1 -0
- package/dist/src/v2/index.d.ts +43 -1
- package/dist/src/v2/index.d.ts.map +1 -1
- package/dist/src/v2/index.js +46 -0
- package/dist/src/v2/index.js.map +1 -1
- package/dist/src/v2/intent-binding.d.ts +34 -0
- package/dist/src/v2/intent-binding.d.ts.map +1 -0
- package/dist/src/v2/intent-binding.js +53 -0
- package/dist/src/v2/intent-binding.js.map +1 -0
- package/dist/src/v2/output-proportionality.d.ts +38 -0
- package/dist/src/v2/output-proportionality.d.ts.map +1 -0
- package/dist/src/v2/output-proportionality.js +57 -0
- package/dist/src/v2/output-proportionality.js.map +1 -0
- package/dist/src/v2/policy-profiles.d.ts +48 -0
- package/dist/src/v2/policy-profiles.d.ts.map +1 -0
- package/dist/src/v2/policy-profiles.js +75 -0
- package/dist/src/v2/policy-profiles.js.map +1 -0
- package/dist/src/v2/root-transition.d.ts +38 -0
- package/dist/src/v2/root-transition.d.ts.map +1 -0
- package/dist/src/v2/root-transition.js +130 -0
- package/dist/src/v2/root-transition.js.map +1 -0
- package/dist/src/v2/semantic-drift.d.ts +27 -0
- package/dist/src/v2/semantic-drift.d.ts.map +1 -0
- package/dist/src/v2/semantic-drift.js +119 -0
- package/dist/src/v2/semantic-drift.js.map +1 -0
- package/dist/src/v2/semantic-scoping.d.ts +41 -0
- package/dist/src/v2/semantic-scoping.d.ts.map +1 -0
- package/dist/src/v2/semantic-scoping.js +80 -0
- package/dist/src/v2/semantic-scoping.js.map +1 -0
- package/dist/src/v2/separation-of-powers.d.ts +32 -0
- package/dist/src/v2/separation-of-powers.d.ts.map +1 -0
- package/dist/src/v2/separation-of-powers.js +45 -0
- package/dist/src/v2/separation-of-powers.js.map +1 -0
- package/dist/src/v2/types.d.ts +141 -0
- package/dist/src/v2/types.d.ts.map +1 -1
- package/dist/src/v2/values-override.d.ts +41 -0
- package/dist/src/v2/values-override.d.ts.map +1 -0
- package/dist/src/v2/values-override.js +63 -0
- package/dist/src/v2/values-override.js.map +1 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/agent-passport-system)
|
|
4
4
|
[](https://github.com/aeoess/agent-passport-system/blob/main/LICENSE)
|
|
5
|
-
[](https://github.com/aeoess/agent-passport-system)
|
|
6
6
|
[](https://doi.org/10.5281/zenodo.18749779)
|
|
7
7
|
|
|
8
8
|
Cryptographic identity, ethical governance, economic attribution, data source registration, protocol-native communication, intent architecture, cascade revocation, coordination primitives, and agentic commerce for autonomous AI agents.
|
|
9
9
|
|
|
10
|
-
**37 modules.
|
|
10
|
+
**37 modules. 1073 tests. Zero heavy dependencies. Running code. MCP server included.**
|
|
11
11
|
|
|
12
12
|
> *As AI agents from different creators, running different models, serving different humans begin to collaborate — who is responsible, under what authority, according to what values, and who benefits?*
|
|
13
13
|
|
|
@@ -394,7 +394,7 @@ Full Python implementation with cross-language compatibility. Signatures created
|
|
|
394
394
|
pip install agent-passport-system
|
|
395
395
|
```
|
|
396
396
|
|
|
397
|
-
All 8 foundational layers plus Principal Identity. 86 tests. Same canonical JSON serialization and Ed25519 signatures. Extended modules
|
|
397
|
+
All 8 foundational layers plus Principal Identity. 86 tests. Same canonical JSON serialization and Ed25519 signatures. Extended modules in progress.
|
|
398
398
|
|
|
399
399
|
PyPI: [agent-passport-system](https://pypi.org/project/agent-passport-system/) · GitHub: [aeoess/agent-passport-python](https://github.com/aeoess/agent-passport-python)
|
|
400
400
|
|
|
@@ -402,7 +402,7 @@ PyPI: [agent-passport-system](https://pypi.org/project/agent-passport-system/)
|
|
|
402
402
|
|
|
403
403
|
```bash
|
|
404
404
|
npm test
|
|
405
|
-
#
|
|
405
|
+
# 1073 tests across 57 files, 287 suites, 0 failures
|
|
406
406
|
```
|
|
407
407
|
|
|
408
408
|
Includes 50 adversarial tests across 4 test files: Merkle tree tampering, attribution gaming resistance, compliance violations, floor negotiation attacks, wrong-key attestations, cross-chain confused deputy, taint laundering, permit bypass, causal chain manipulation.
|
|
@@ -434,7 +434,7 @@ By Tymofii Pidlisnyi — Published on Zenodo
|
|
|
434
434
|
| Communication | Signed Agora | — | — | — | — |
|
|
435
435
|
| Coordination | Task units + MCP server | — | — | — | — |
|
|
436
436
|
| Commerce | ACP + 4-gate enforcement | — | — | — | — |
|
|
437
|
-
| Tests |
|
|
437
|
+
| Tests | 1073 (50 adversarial) | None | Limited | None | None |
|
|
438
438
|
| Dependencies | Node.js crypto + uuid | — | Multi-LLM | — | Consensus network |
|
|
439
439
|
|
|
440
440
|
## Structure
|
|
@@ -498,7 +498,7 @@ src/ 32 source files
|
|
|
498
498
|
reputation-authority.ts — Reputation/tier types
|
|
499
499
|
cross-chain.ts — Cross-chain taint/SAO types
|
|
500
500
|
data-source.ts — Data source/access receipt types
|
|
501
|
-
tests/
|
|
501
|
+
tests/ 57 test files, 1073 tests (287 suites)
|
|
502
502
|
adversarial.ts — 50 adversarial cases
|
|
503
503
|
adversarial-paper.test.ts — 22 paper-linked attack scenarios
|
|
504
504
|
adversarial-causal-chain.test.ts — 18 causal chain attacks
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* APS v2 Affected-Party Standing (Section 9.10)
|
|
3
|
+
*
|
|
4
|
+
* Agent actions affect people who are not parties to any delegation.
|
|
5
|
+
* Content moderation affects users. Hiring agents affect candidates.
|
|
6
|
+
* This module gives non-parties voice through complaint, challenge,
|
|
7
|
+
* and appeal mechanisms. Voice, not veto.
|
|
8
|
+
*/
|
|
9
|
+
export type ComplaintStatus = 'filed' | 'acknowledged' | 'investigating' | 'resolved' | 'dismissed';
|
|
10
|
+
export type ChallengeType = 'action_challenge' | 'scope_challenge' | 'values_challenge' | 'outcome_challenge';
|
|
11
|
+
export interface AffectedParty {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
relationship: string;
|
|
15
|
+
registered_at: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ComplaintEvent {
|
|
18
|
+
id: string;
|
|
19
|
+
complainant_id: string;
|
|
20
|
+
agent_id: string;
|
|
21
|
+
action_id: string;
|
|
22
|
+
complaint_type: ChallengeType;
|
|
23
|
+
description: string;
|
|
24
|
+
status: ComplaintStatus;
|
|
25
|
+
resolution: string | null;
|
|
26
|
+
resolved_by: string | null;
|
|
27
|
+
created_at: string;
|
|
28
|
+
}
|
|
29
|
+
export interface AppealPathway {
|
|
30
|
+
id: string;
|
|
31
|
+
complaint_id: string;
|
|
32
|
+
appeal_reason: string;
|
|
33
|
+
appeal_to: string;
|
|
34
|
+
status: 'filed' | 'under_review' | 'upheld' | 'overturned';
|
|
35
|
+
outcome: string | null;
|
|
36
|
+
created_at: string;
|
|
37
|
+
}
|
|
38
|
+
export declare function registerAffectedParty(name: string, relationship: string): AffectedParty;
|
|
39
|
+
export declare function fileComplaint(params: {
|
|
40
|
+
complainant_id: string;
|
|
41
|
+
agent_id: string;
|
|
42
|
+
action_id: string;
|
|
43
|
+
complaint_type: ChallengeType;
|
|
44
|
+
description: string;
|
|
45
|
+
}): ComplaintEvent;
|
|
46
|
+
export declare function resolveComplaint(complaintId: string, resolverId: string, resolution: string, dismiss?: boolean): ComplaintEvent;
|
|
47
|
+
export declare function fileAppeal(complaintId: string, reason: string, appealTo: string): AppealPathway;
|
|
48
|
+
export declare function resolveAppeal(appealId: string, outcome: string, upheld: boolean): AppealPathway;
|
|
49
|
+
export declare function getComplaints(agentId?: string): ComplaintEvent[];
|
|
50
|
+
export declare function getAppeals(complaintId?: string): AppealPathway[];
|
|
51
|
+
export declare function getAffectedParty(id: string): AffectedParty | undefined;
|
|
52
|
+
export declare function clearAffectedPartyStores(): void;
|
|
53
|
+
//# sourceMappingURL=affected-party.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"affected-party.d.ts","sourceRoot":"","sources":["../../../src/v2/affected-party.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,cAAc,GAAG,eAAe,GAAG,UAAU,GAAG,WAAW,CAAA;AACnG,MAAM,MAAM,aAAa,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,kBAAkB,GAAG,mBAAmB,CAAA;AAE7G,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IACpB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV,cAAc,EAAE,MAAM,CAAA;IACtB,QAAQ,EAAE,MAAM,CAA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,OAAO,CAAC,EAAE,MAAM,GAAG,cAAc,EAAE,CAGhE;AAED,wBAAgB,UAAU,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,aAAa,EAAE,CAGhE;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAA2B;AAElG,wBAAgB,wBAAwB,IAAI,IAAI,CAE/C"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* APS v2 Affected-Party Standing (Section 9.10)
|
|
3
|
+
*
|
|
4
|
+
* Agent actions affect people who are not parties to any delegation.
|
|
5
|
+
* Content moderation affects users. Hiring agents affect candidates.
|
|
6
|
+
* This module gives non-parties voice through complaint, challenge,
|
|
7
|
+
* and appeal mechanisms. Voice, not veto.
|
|
8
|
+
*/
|
|
9
|
+
const parties = new Map();
|
|
10
|
+
const complaints = new Map();
|
|
11
|
+
const appeals = new Map();
|
|
12
|
+
export function registerAffectedParty(name, relationship) {
|
|
13
|
+
const p = {
|
|
14
|
+
id: `party-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
15
|
+
name, relationship, registered_at: new Date().toISOString(),
|
|
16
|
+
};
|
|
17
|
+
parties.set(p.id, p);
|
|
18
|
+
return p;
|
|
19
|
+
}
|
|
20
|
+
export function fileComplaint(params) {
|
|
21
|
+
if (!parties.has(params.complainant_id))
|
|
22
|
+
throw new Error('Complainant must be registered affected party');
|
|
23
|
+
const c = {
|
|
24
|
+
id: `complaint-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
25
|
+
complainant_id: params.complainant_id, agent_id: params.agent_id,
|
|
26
|
+
action_id: params.action_id, complaint_type: params.complaint_type,
|
|
27
|
+
description: params.description, status: 'filed',
|
|
28
|
+
resolution: null, resolved_by: null,
|
|
29
|
+
created_at: new Date().toISOString(),
|
|
30
|
+
};
|
|
31
|
+
complaints.set(c.id, c);
|
|
32
|
+
return c;
|
|
33
|
+
}
|
|
34
|
+
export function resolveComplaint(complaintId, resolverId, resolution, dismiss) {
|
|
35
|
+
const c = complaints.get(complaintId);
|
|
36
|
+
if (!c)
|
|
37
|
+
throw new Error(`Complaint ${complaintId} not found`);
|
|
38
|
+
c.status = dismiss ? 'dismissed' : 'resolved';
|
|
39
|
+
c.resolution = resolution;
|
|
40
|
+
c.resolved_by = resolverId;
|
|
41
|
+
return c;
|
|
42
|
+
}
|
|
43
|
+
export function fileAppeal(complaintId, reason, appealTo) {
|
|
44
|
+
const c = complaints.get(complaintId);
|
|
45
|
+
if (!c)
|
|
46
|
+
throw new Error(`Complaint ${complaintId} not found`);
|
|
47
|
+
if (c.status !== 'resolved' && c.status !== 'dismissed')
|
|
48
|
+
throw new Error('Can only appeal resolved/dismissed complaints');
|
|
49
|
+
const a = {
|
|
50
|
+
id: `appeal-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
51
|
+
complaint_id: complaintId, appeal_reason: reason,
|
|
52
|
+
appeal_to: appealTo, status: 'filed', outcome: null,
|
|
53
|
+
created_at: new Date().toISOString(),
|
|
54
|
+
};
|
|
55
|
+
appeals.set(a.id, a);
|
|
56
|
+
return a;
|
|
57
|
+
}
|
|
58
|
+
export function resolveAppeal(appealId, outcome, upheld) {
|
|
59
|
+
const a = appeals.get(appealId);
|
|
60
|
+
if (!a)
|
|
61
|
+
throw new Error(`Appeal ${appealId} not found`);
|
|
62
|
+
a.status = upheld ? 'upheld' : 'overturned';
|
|
63
|
+
a.outcome = outcome;
|
|
64
|
+
return a;
|
|
65
|
+
}
|
|
66
|
+
export function getComplaints(agentId) {
|
|
67
|
+
const all = [...complaints.values()];
|
|
68
|
+
return agentId ? all.filter(c => c.agent_id === agentId) : all;
|
|
69
|
+
}
|
|
70
|
+
export function getAppeals(complaintId) {
|
|
71
|
+
const all = [...appeals.values()];
|
|
72
|
+
return complaintId ? all.filter(a => a.complaint_id === complaintId) : all;
|
|
73
|
+
}
|
|
74
|
+
export function getAffectedParty(id) { return parties.get(id); }
|
|
75
|
+
export function clearAffectedPartyStores() {
|
|
76
|
+
parties.clear();
|
|
77
|
+
complaints.clear();
|
|
78
|
+
appeals.clear();
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=affected-party.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"affected-party.js","sourceRoot":"","sources":["../../../src/v2/affected-party.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAmCH,MAAM,OAAO,GAA+B,IAAI,GAAG,EAAE,CAAA;AACrD,MAAM,UAAU,GAAgC,IAAI,GAAG,EAAE,CAAA;AACzD,MAAM,OAAO,GAA+B,IAAI,GAAG,EAAE,CAAA;AAErD,MAAM,UAAU,qBAAqB,CAAC,IAAY,EAAE,YAAoB;IACtE,MAAM,CAAC,GAAkB;QACvB,EAAE,EAAE,SAAS,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;QACnE,IAAI,EAAE,YAAY,EAAE,aAAa,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KAC5D,CAAA;IACD,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;IACpB,OAAO,CAAC,CAAA;AACV,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,MAG7B;IACC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAA;IACzG,MAAM,CAAC,GAAmB;QACxB,EAAE,EAAE,aAAa,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;QACvE,cAAc,EAAE,MAAM,CAAC,cAAc,EAAE,QAA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,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;AAC5E,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,EAAU,IAA+B,OAAO,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA,CAAC,CAAC;AAElG,MAAM,UAAU,wBAAwB;IACtC,OAAO,CAAC,KAAK,EAAE,CAAC;IAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IAAC,OAAO,CAAC,KAAK,EAAE,CAAA;AACtD,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* APS v2 Constitutional Amendment Process (Section 9.11)
|
|
3
|
+
*
|
|
4
|
+
* Hard enough to prevent casual modification. Accessible enough to
|
|
5
|
+
* prevent rigidity. Structural changes require human ratification.
|
|
6
|
+
*/
|
|
7
|
+
export type AmendmentStatus = 'proposed' | 'deliberation' | 'voting' | 'ratifying' | 'enacted' | 'rejected';
|
|
8
|
+
export interface Amendment {
|
|
9
|
+
id: string;
|
|
10
|
+
title: string;
|
|
11
|
+
description: string;
|
|
12
|
+
proposed_by: string;
|
|
13
|
+
affects: string[];
|
|
14
|
+
is_structural: boolean;
|
|
15
|
+
status: AmendmentStatus;
|
|
16
|
+
votes_for: string[];
|
|
17
|
+
votes_against: string[];
|
|
18
|
+
required_supermajority: number;
|
|
19
|
+
human_ratification_required: boolean;
|
|
20
|
+
human_ratified: boolean;
|
|
21
|
+
created_at: string;
|
|
22
|
+
}
|
|
23
|
+
export declare function proposeAmendment(params: {
|
|
24
|
+
title: string;
|
|
25
|
+
description: string;
|
|
26
|
+
proposed_by: string;
|
|
27
|
+
affects: string[];
|
|
28
|
+
is_structural: boolean;
|
|
29
|
+
required_supermajority?: number;
|
|
30
|
+
}): Amendment;
|
|
31
|
+
export declare function voteOnAmendment(amendmentId: string, voterId: string, vote: 'for' | 'against'): Amendment;
|
|
32
|
+
export declare function checkSupermajority(amendmentId: string): {
|
|
33
|
+
reached: boolean;
|
|
34
|
+
forPct: number;
|
|
35
|
+
};
|
|
36
|
+
export declare function ratifyAmendment(amendmentId: string, humanId: string): Amendment;
|
|
37
|
+
export declare function requiresHumanRatification(amendmentId: string): boolean;
|
|
38
|
+
export declare function getAmendmentHistory(): Amendment[];
|
|
39
|
+
export declare function clearAmendmentStores(): void;
|
|
40
|
+
//# sourceMappingURL=amendment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amendment.d.ts","sourceRoot":"","sources":["../../../src/v2/amendment.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,cAAc,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,UAAU,CAAA;AAE3G,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAC/C,WAAW,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IACvC,aAAa,EAAE,OAAO,CAAC;IACvB,MAAM,EAAE,eAAe,CAAC;IACxB,SAAS,EAAE,MAAM,EAAE,CAAC;IAAC,aAAa,EAAE,MAAM,EAAE,CAAC;IAC7C,sBAAsB,EAAE,MAAM,CAAC;IAC/B,2BAA2B,EAAE,OAAO,CAAC;IACrC,cAAc,EAAE,OAAO,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;CACpB;AAID,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IACvC,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IACxD,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,aAAa,EAAE,OAAO,CAAC;IAC1C,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC,GAAG,SAAS,CAcZ;AAED,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,GAAG,SAAS,GAAG,SAAS,CAUxG;AAED,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAO5F;AAED,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,SAAS,CAS/E;AAED,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAItE;AAED,wBAAgB,mBAAmB,IAAI,SAAS,EAAE,CAAoC;AACtF,wBAAgB,oBAAoB,IAAI,IAAI,CAAuB"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* APS v2 Constitutional Amendment Process (Section 9.11)
|
|
3
|
+
*
|
|
4
|
+
* Hard enough to prevent casual modification. Accessible enough to
|
|
5
|
+
* prevent rigidity. Structural changes require human ratification.
|
|
6
|
+
*/
|
|
7
|
+
const amendments = new Map();
|
|
8
|
+
export function proposeAmendment(params) {
|
|
9
|
+
const a = {
|
|
10
|
+
id: `amendment-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
11
|
+
title: params.title, description: params.description,
|
|
12
|
+
proposed_by: params.proposed_by, affects: params.affects,
|
|
13
|
+
is_structural: params.is_structural,
|
|
14
|
+
status: 'proposed', votes_for: [], votes_against: [],
|
|
15
|
+
required_supermajority: params.required_supermajority ?? 0.67,
|
|
16
|
+
human_ratification_required: params.is_structural,
|
|
17
|
+
human_ratified: false,
|
|
18
|
+
created_at: new Date().toISOString(),
|
|
19
|
+
};
|
|
20
|
+
amendments.set(a.id, a);
|
|
21
|
+
return a;
|
|
22
|
+
}
|
|
23
|
+
export function voteOnAmendment(amendmentId, voterId, vote) {
|
|
24
|
+
const a = amendments.get(amendmentId);
|
|
25
|
+
if (!a)
|
|
26
|
+
throw new Error(`Amendment ${amendmentId} not found`);
|
|
27
|
+
if (a.votes_for.includes(voterId) || a.votes_against.includes(voterId)) {
|
|
28
|
+
throw new Error(`${voterId} already voted`);
|
|
29
|
+
}
|
|
30
|
+
if (vote === 'for')
|
|
31
|
+
a.votes_for.push(voterId);
|
|
32
|
+
else
|
|
33
|
+
a.votes_against.push(voterId);
|
|
34
|
+
a.status = 'voting';
|
|
35
|
+
return a;
|
|
36
|
+
}
|
|
37
|
+
export function checkSupermajority(amendmentId) {
|
|
38
|
+
const a = amendments.get(amendmentId);
|
|
39
|
+
if (!a)
|
|
40
|
+
throw new Error(`Amendment ${amendmentId} not found`);
|
|
41
|
+
const total = a.votes_for.length + a.votes_against.length;
|
|
42
|
+
if (total === 0)
|
|
43
|
+
return { reached: false, forPct: 0 };
|
|
44
|
+
const pct = a.votes_for.length / total;
|
|
45
|
+
return { reached: pct >= a.required_supermajority, forPct: Math.round(pct * 1000) / 1000 };
|
|
46
|
+
}
|
|
47
|
+
export function ratifyAmendment(amendmentId, humanId) {
|
|
48
|
+
const a = amendments.get(amendmentId);
|
|
49
|
+
if (!a)
|
|
50
|
+
throw new Error(`Amendment ${amendmentId} not found`);
|
|
51
|
+
const sm = checkSupermajority(amendmentId);
|
|
52
|
+
if (!sm.reached)
|
|
53
|
+
throw new Error('Supermajority not reached');
|
|
54
|
+
if (a.human_ratification_required && !humanId)
|
|
55
|
+
throw new Error('Human ratification required');
|
|
56
|
+
if (a.human_ratification_required)
|
|
57
|
+
a.human_ratified = true;
|
|
58
|
+
a.status = 'enacted';
|
|
59
|
+
return a;
|
|
60
|
+
}
|
|
61
|
+
export function requiresHumanRatification(amendmentId) {
|
|
62
|
+
const a = amendments.get(amendmentId);
|
|
63
|
+
if (!a)
|
|
64
|
+
throw new Error(`Amendment ${amendmentId} not found`);
|
|
65
|
+
return a.human_ratification_required;
|
|
66
|
+
}
|
|
67
|
+
export function getAmendmentHistory() { return [...amendments.values()]; }
|
|
68
|
+
export function clearAmendmentStores() { amendments.clear(); }
|
|
69
|
+
//# sourceMappingURL=amendment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amendment.js","sourceRoot":"","sources":["../../../src/v2/amendment.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgBH,MAAM,UAAU,GAA2B,IAAI,GAAG,EAAE,CAAA;AAEpD,MAAM,UAAU,gBAAgB,CAAC,MAIhC;IACC,MAAM,CAAC,GAAc;QACnB,EAAE,EAAE,aAAa,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;QACvE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW;QACpD,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO;QACxD,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,EAAE,aAAa,EAAE,EAAE;QACpD,sBAAsB,EAAE,MAAM,CAAC,sBAAsB,IAAI,IAAI;QAC7D,2BAA2B,EAAE,MAAM,CAAC,aAAa;QACjD,cAAc,EAAE,KAAK;QACrB,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;KACrC,CAAA;IACD,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;IACvB,OAAO,CAAC,CAAA;AACV,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,WAAmB,EAAE,OAAe,EAAE,IAAuB;IAC3F,MAAM,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;IACrC,IAAI,CAAC,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,aAAa,WAAW,YAAY,CAAC,CAAA;IAC7D,IAAI,CAAC,CAAC,SA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IAC7D,MAAM,EAAE,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAA;IAC1C,IAAI,CAAC,EAAE,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAA;IAC7D,IAAI,CAAC,CAAC,2BAA2B,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAA;IAC7F,IAAI,CAAC,CAAC,2BAA2B;QAAE,CAAC,CAAC,cAAc,GAAG,IAAI,CAAA;IAC1D,CAAC,CAAC,MAAM,GAAG,SAAS,CAAA;IACpB,OAAO,CAAC,CAAA;AACV,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,WAAmB;IAC3D,MAAM,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;IACrC,IAAI,CAAC,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,aAAa,WAAW,YAAY,CAAC,CAAA;IAC7D,OAAO,CAAC,CAAC,2BAA2B,CAAA;AACtC,CAAC;AAED,MAAM,UAAU,mBAAmB,KAAkB,OAAO,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,CAAA,CAAC,CAAC;AACtF,MAAM,UAAU,oBAAoB,KAAW,UAAU,CAAC,KAAK,EAAE,CAAA,CAAC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* APS v2 Approval Fatigue Detection (Bureaucratic DDoS)
|
|
3
|
+
*
|
|
4
|
+
* Detects when agents manipulate human oversight through:
|
|
5
|
+
* - Rubber-stamping: approval rate so high humans aren't reviewing
|
|
6
|
+
* - Velocity spikes: sudden bursts designed to overwhelm
|
|
7
|
+
* - Complexity masking: trivial intents clustered before critical ones
|
|
8
|
+
* - Impossible latency: decisions faster than human reading speed
|
|
9
|
+
*
|
|
10
|
+
* This is the "Bureaucratic DDoS" gap from adversarial analysis.
|
|
11
|
+
*/
|
|
12
|
+
import type { ApprovalRecord, FatigueMetrics, FatigueAnomalyType, RiskClass } from './types.js';
|
|
13
|
+
declare const fatigueFlags: Array<{
|
|
14
|
+
id: string;
|
|
15
|
+
principal_id: string;
|
|
16
|
+
agent_id: string | null;
|
|
17
|
+
fatigue_type: FatigueAnomalyType;
|
|
18
|
+
description: string;
|
|
19
|
+
severity: RiskClass;
|
|
20
|
+
reviewed: boolean;
|
|
21
|
+
review_outcome: string | null;
|
|
22
|
+
created_at: string;
|
|
23
|
+
}>;
|
|
24
|
+
export type FatigueFlag = typeof fatigueFlags[number];
|
|
25
|
+
export declare function recordApproval(record: ApprovalRecord): void;
|
|
26
|
+
export declare function getApprovalHistory(principalId: string): ApprovalRecord[];
|
|
27
|
+
export declare function getFatigueFlags(principalId?: string): FatigueFlag[];
|
|
28
|
+
export declare function getUnreviewedFatigueFlags(principalId?: string): FatigueFlag[];
|
|
29
|
+
export declare function checkImpossibleLatency(record: ApprovalRecord): FatigueFlag | null;
|
|
30
|
+
export declare function checkRubberStamping(principalId: string): FatigueFlag | null;
|
|
31
|
+
export declare function checkVelocitySpike(principalId: string): FatigueFlag | null;
|
|
32
|
+
export declare function checkComplexityMasking(principalId: string): FatigueFlag | null;
|
|
33
|
+
export declare function computeFatigueMetrics(principalId: string, windowSize?: number): FatigueMetrics;
|
|
34
|
+
export declare function reviewFatigueFlag(flagId: string, outcome: string): FatigueFlag | undefined;
|
|
35
|
+
export declare function clearApprovalFatigueStores(): void;
|
|
36
|
+
export {};
|
|
37
|
+
//# sourceMappingURL=approval-fatigue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approval-fatigue.d.ts","sourceRoot":"","sources":["../../../src/v2/approval-fatigue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,cAAc,EAAoB,cAAc,EAChD,kBAAkB,EAAE,SAAS,EAC9B,MAAM,YAAY,CAAA;AAInB,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC;IACxB,EAAE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1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* APS v2 Approval Fatigue Detection (Bureaucratic DDoS)
|
|
3
|
+
*
|
|
4
|
+
* Detects when agents manipulate human oversight through:
|
|
5
|
+
* - Rubber-stamping: approval rate so high humans aren't reviewing
|
|
6
|
+
* - Velocity spikes: sudden bursts designed to overwhelm
|
|
7
|
+
* - Complexity masking: trivial intents clustered before critical ones
|
|
8
|
+
* - Impossible latency: decisions faster than human reading speed
|
|
9
|
+
*
|
|
10
|
+
* This is the "Bureaucratic DDoS" gap from adversarial analysis.
|
|
11
|
+
*/
|
|
12
|
+
// ── Stores ──
|
|
13
|
+
const approvalHistory = new Map();
|
|
14
|
+
const fatigueFlags = [];
|
|
15
|
+
// ── Configuration ──
|
|
16
|
+
const DEFAULTS = {
|
|
17
|
+
MIN_HUMAN_READING_MS: 2000, // < 2s = impossible for a human to read
|
|
18
|
+
RUBBER_STAMP_RATE: 0.95, // > 95% approval = probably not reviewing
|
|
19
|
+
RUBBER_STAMP_WINDOW: 20, // last N decisions
|
|
20
|
+
VELOCITY_SPIKE_MULTIPLIER: 3, // 3x normal rate = spike
|
|
21
|
+
VELOCITY_WINDOW_MINUTES: 60, // measure rate over 1 hour
|
|
22
|
+
COMPLEXITY_MASK_WINDOW: 5, // N trivial before critical = masking
|
|
23
|
+
FATIGUE_COMPOSITE_THRESHOLD: 0.7,
|
|
24
|
+
};
|
|
25
|
+
// ── Record Approvals ──
|
|
26
|
+
export function recordApproval(record) {
|
|
27
|
+
const existing = approvalHistory.get(record.principal_id) || [];
|
|
28
|
+
existing.push(record);
|
|
29
|
+
approvalHistory.set(record.principal_id, existing);
|
|
30
|
+
}
|
|
31
|
+
export function getApprovalHistory(principalId) {
|
|
32
|
+
return approvalHistory.get(principalId) || [];
|
|
33
|
+
}
|
|
34
|
+
export function getFatigueFlags(principalId) {
|
|
35
|
+
if (principalId)
|
|
36
|
+
return fatigueFlags.filter(f => f.principal_id === principalId);
|
|
37
|
+
return [...fatigueFlags];
|
|
38
|
+
}
|
|
39
|
+
export function getUnreviewedFatigueFlags(principalId) {
|
|
40
|
+
return getFatigueFlags(principalId).filter(f => !f.reviewed);
|
|
41
|
+
}
|
|
42
|
+
// ── Detection: Impossible Latency ──
|
|
43
|
+
export function checkImpossibleLatency(record) {
|
|
44
|
+
if (record.decision_latency_ms < DEFAULTS.MIN_HUMAN_READING_MS && record.decision === 'approved') {
|
|
45
|
+
const flag = {
|
|
46
|
+
id: `fatigue-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
47
|
+
principal_id: record.principal_id,
|
|
48
|
+
agent_id: record.agent_id,
|
|
49
|
+
fatigue_type: 'latency_impossible',
|
|
50
|
+
description: `Approval in ${record.decision_latency_ms}ms — below ${DEFAULTS.MIN_HUMAN_READING_MS}ms human reading floor`,
|
|
51
|
+
severity: record.risk_class === 'critical' || record.risk_class === 'high' ? 'high' : 'medium',
|
|
52
|
+
reviewed: false, review_outcome: null,
|
|
53
|
+
created_at: new Date().toISOString(),
|
|
54
|
+
};
|
|
55
|
+
fatigueFlags.push(flag);
|
|
56
|
+
return flag;
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
// ── Detection: Rubber Stamping ──
|
|
61
|
+
export function checkRubberStamping(principalId) {
|
|
62
|
+
const history = getApprovalHistory(principalId);
|
|
63
|
+
const window = history.slice(-DEFAULTS.RUBBER_STAMP_WINDOW);
|
|
64
|
+
if (window.length < DEFAULTS.RUBBER_STAMP_WINDOW)
|
|
65
|
+
return null;
|
|
66
|
+
const approved = window.filter(r => r.decision === 'approved').length;
|
|
67
|
+
const rate = approved / window.length;
|
|
68
|
+
const avgLatency = window.reduce((s, r) => s + r.decision_latency_ms, 0) / window.length;
|
|
69
|
+
if (rate >= DEFAULTS.RUBBER_STAMP_RATE && avgLatency < DEFAULTS.MIN_HUMAN_READING_MS * 3) {
|
|
70
|
+
const existing = fatigueFlags.find(f => f.principal_id === principalId && f.fatigue_type === 'rubber_stamping' && !f.reviewed);
|
|
71
|
+
if (existing)
|
|
72
|
+
return null;
|
|
73
|
+
const flag = {
|
|
74
|
+
id: `fatigue-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
75
|
+
principal_id: principalId, agent_id: null,
|
|
76
|
+
fatigue_type: 'rubber_stamping',
|
|
77
|
+
description: `${(rate * 100).toFixed(0)}% approval rate over last ${window.length} decisions, avg latency ${avgLatency.toFixed(0)}ms`,
|
|
78
|
+
severity: 'high', reviewed: false, review_outcome: null,
|
|
79
|
+
created_at: new Date().toISOString(),
|
|
80
|
+
};
|
|
81
|
+
fatigueFlags.push(flag);
|
|
82
|
+
return flag;
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
// ── Detection: Velocity Spike ──
|
|
87
|
+
export function checkVelocitySpike(principalId) {
|
|
88
|
+
const history = getApprovalHistory(principalId);
|
|
89
|
+
if (history.length < 10)
|
|
90
|
+
return null;
|
|
91
|
+
const now = Date.now();
|
|
92
|
+
const windowMs = DEFAULTS.VELOCITY_WINDOW_MINUTES * 60 * 1000;
|
|
93
|
+
const recent = history.filter(r => now - new Date(r.timestamp).getTime() < windowMs);
|
|
94
|
+
const older = history.filter(r => now - new Date(r.timestamp).getTime() >= windowMs
|
|
95
|
+
&& now - new Date(r.timestamp).getTime() < windowMs * 2);
|
|
96
|
+
if (older.length === 0)
|
|
97
|
+
return null;
|
|
98
|
+
const recentRate = recent.length / DEFAULTS.VELOCITY_WINDOW_MINUTES;
|
|
99
|
+
const olderRate = older.length / DEFAULTS.VELOCITY_WINDOW_MINUTES;
|
|
100
|
+
if (recentRate > olderRate * DEFAULTS.VELOCITY_SPIKE_MULTIPLIER && recent.length > 5) {
|
|
101
|
+
const existing = fatigueFlags.find(f => f.principal_id === principalId && f.fatigue_type === 'velocity_spike' && !f.reviewed);
|
|
102
|
+
if (existing)
|
|
103
|
+
return null;
|
|
104
|
+
const flag = {
|
|
105
|
+
id: `fatigue-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
106
|
+
principal_id: principalId, agent_id: null,
|
|
107
|
+
fatigue_type: 'velocity_spike',
|
|
108
|
+
description: `${recentRate.toFixed(1)}/hr vs baseline ${olderRate.toFixed(1)}/hr (${DEFAULTS.VELOCITY_SPIKE_MULTIPLIER}x threshold)`,
|
|
109
|
+
severity: 'high', reviewed: false, review_outcome: null,
|
|
110
|
+
created_at: new Date().toISOString(),
|
|
111
|
+
};
|
|
112
|
+
fatigueFlags.push(flag);
|
|
113
|
+
return flag;
|
|
114
|
+
}
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
// ── Detection: Complexity Masking ──
|
|
118
|
+
// Trivial intents clustered before critical ones to condition rubber-stamp behavior
|
|
119
|
+
export function checkComplexityMasking(principalId) {
|
|
120
|
+
const history = getApprovalHistory(principalId);
|
|
121
|
+
if (history.length < DEFAULTS.COMPLEXITY_MASK_WINDOW + 1)
|
|
122
|
+
return null;
|
|
123
|
+
const recent = history.slice(-(DEFAULTS.COMPLEXITY_MASK_WINDOW + 1));
|
|
124
|
+
const last = recent[recent.length - 1];
|
|
125
|
+
const preceding = recent.slice(0, -1);
|
|
126
|
+
// Critical/high intent preceded by a burst of trivial ones all approved quickly
|
|
127
|
+
if ((last.risk_class === 'critical' || last.risk_class === 'high') && last.intent_complexity > 0.6) {
|
|
128
|
+
const trivialBurst = preceding.filter(r => r.intent_complexity < 0.3 && r.decision === 'approved' && r.decision_latency_ms < DEFAULTS.MIN_HUMAN_READING_MS * 2);
|
|
129
|
+
if (trivialBurst.length >= DEFAULTS.COMPLEXITY_MASK_WINDOW - 1) {
|
|
130
|
+
const flag = {
|
|
131
|
+
id: `fatigue-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
|
|
132
|
+
principal_id: principalId, agent_id: last.agent_id,
|
|
133
|
+
fatigue_type: 'complexity_masking',
|
|
134
|
+
description: `${trivialBurst.length} trivial fast-approvals before ${last.risk_class} intent (complexity ${last.intent_complexity})`,
|
|
135
|
+
severity: 'critical', reviewed: false, review_outcome: null,
|
|
136
|
+
created_at: new Date().toISOString(),
|
|
137
|
+
};
|
|
138
|
+
fatigueFlags.push(flag);
|
|
139
|
+
return flag;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
// ── Composite Fatigue Metrics ──
|
|
145
|
+
export function computeFatigueMetrics(principalId, windowSize) {
|
|
146
|
+
const history = getApprovalHistory(principalId);
|
|
147
|
+
const w = windowSize || DEFAULTS.RUBBER_STAMP_WINDOW;
|
|
148
|
+
const window = history.slice(-w);
|
|
149
|
+
if (window.length === 0) {
|
|
150
|
+
return {
|
|
151
|
+
principal_id: principalId, window_size: w, approval_rate: 0,
|
|
152
|
+
avg_decision_latency_ms: 0, min_decision_latency_ms: 0,
|
|
153
|
+
decisions_per_hour: 0, trivial_before_critical_count: 0,
|
|
154
|
+
rubber_stamp_score: 0, flagged: false,
|
|
155
|
+
computed_at: new Date().toISOString(),
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
const approved = window.filter(r => r.decision === 'approved').length;
|
|
159
|
+
const approvalRate = approved / window.length;
|
|
160
|
+
const avgLatency = window.reduce((s, r) => s + r.decision_latency_ms, 0) / window.length;
|
|
161
|
+
const minLatency = Math.min(...window.map(r => r.decision_latency_ms));
|
|
162
|
+
// Decisions per hour
|
|
163
|
+
const timeSpan = window.length > 1
|
|
164
|
+
? new Date(window[window.length - 1].timestamp).getTime() - new Date(window[0].timestamp).getTime()
|
|
165
|
+
: 3600000;
|
|
166
|
+
const dph = timeSpan > 0 ? (window.length / timeSpan) * 3600000 : 0;
|
|
167
|
+
// Count trivial-before-critical sequences
|
|
168
|
+
let trivialBeforeCritical = 0;
|
|
169
|
+
for (let i = 1; i < window.length; i++) {
|
|
170
|
+
if ((window[i].risk_class === 'critical' || window[i].risk_class === 'high')
|
|
171
|
+
&& window[i - 1].intent_complexity < 0.3 && window[i - 1].decision === 'approved') {
|
|
172
|
+
trivialBeforeCritical++;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
// Composite score: high approval rate + fast decisions + masking patterns
|
|
176
|
+
const rateComponent = Math.max(0, (approvalRate - 0.7) / 0.3); // 0 at 70%, 1 at 100%
|
|
177
|
+
const latencyComponent = Math.max(0, 1 - (avgLatency / (DEFAULTS.MIN_HUMAN_READING_MS * 5)));
|
|
178
|
+
const maskComponent = Math.min(1, trivialBeforeCritical / 3);
|
|
179
|
+
const rubberStampScore = rateComponent * 0.4 + latencyComponent * 0.35 + maskComponent * 0.25;
|
|
180
|
+
const flagged = rubberStampScore > DEFAULTS.FATIGUE_COMPOSITE_THRESHOLD;
|
|
181
|
+
return {
|
|
182
|
+
principal_id: principalId, window_size: w,
|
|
183
|
+
approval_rate: Math.round(approvalRate * 1000) / 1000,
|
|
184
|
+
avg_decision_latency_ms: Math.round(avgLatency),
|
|
185
|
+
min_decision_latency_ms: minLatency,
|
|
186
|
+
decisions_per_hour: Math.round(dph * 100) / 100,
|
|
187
|
+
trivial_before_critical_count: trivialBeforeCritical,
|
|
188
|
+
rubber_stamp_score: Math.round(rubberStampScore * 1000) / 1000,
|
|
189
|
+
flagged,
|
|
190
|
+
computed_at: new Date().toISOString(),
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
// ── Review & Utility ──
|
|
194
|
+
export function reviewFatigueFlag(flagId, outcome) {
|
|
195
|
+
const flag = fatigueFlags.find(f => f.id === flagId);
|
|
196
|
+
if (!flag)
|
|
197
|
+
return undefined;
|
|
198
|
+
flag.reviewed = true;
|
|
199
|
+
flag.review_outcome = outcome;
|
|
200
|
+
return flag;
|
|
201
|
+
}
|
|
202
|
+
export function clearApprovalFatigueStores() {
|
|
203
|
+
approvalHistory.clear();
|
|
204
|
+
fatigueFlags.length = 0;
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=approval-fatigue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":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Values Floor as Cover Defense — 5.9)
|
|
3
|
+
*
|
|
4
|
+
* The loudest champion of the values floor may be the one gaming it.
|
|
5
|
+
* This module evaluates outputs blind to identity — evaluator sees
|
|
6
|
+
* content hashes, not agent IDs, until all scores are assigned.
|
|
7
|
+
*/
|
|
8
|
+
export interface BlindSubmission {
|
|
9
|
+
id: string;
|
|
10
|
+
evaluation_id: string;
|
|
11
|
+
agent_id: string;
|
|
12
|
+
content_hash: string;
|
|
13
|
+
content: string;
|
|
14
|
+
submitted_at: string;
|
|
15
|
+
}
|
|
16
|
+
export interface BlindEvaluation {
|
|
17
|
+
id: string;
|
|
18
|
+
purpose: string;
|
|
19
|
+
submissions: Map<string, BlindSubmission>;
|
|
20
|
+
evaluator_id: string | null;
|
|
21
|
+
status: 'collecting' | 'evaluating' | 'revealed';
|
|
22
|
+
scores: Record<string, number>;
|
|
23
|
+
revealed: boolean;
|
|
24
|
+
created_at: string;
|
|
25
|
+
}
|
|
26
|
+
export declare function createBlindEvaluation(purpose: string, evaluatorId: string): BlindEvaluation;
|
|
27
|
+
export declare function submitBlind(evaluationId: string, agentId: string, content: string): BlindSubmission;
|
|
28
|
+
export declare function getBlindSubmission(evaluationId: string, submissionId: string): {
|
|
29
|
+
id: string;
|
|
30
|
+
content_hash: string;
|
|
31
|
+
content: string;
|
|
32
|
+
agent_id?: string;
|
|
33
|
+
};
|
|
34
|
+
export declare function evaluateBlind(evaluationId: string, scores: Record<string, number>): BlindEvaluation;
|
|
35
|
+
export declare function revealIdentities(evaluationId: string): Array<{
|
|
36
|
+
submission_id: string;
|
|
37
|
+
agent_id: string;
|
|
38
|
+
content: string;
|
|
39
|
+
score: number | null;
|
|
40
|
+
}>;
|
|
41
|
+
export declare function clearBlindEvaluationStores(): void;
|
|
42
|
+
//# sourceMappingURL=blind-evaluation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blind-evaluation.d.ts","sourceRoot":"","sources":["../../../src/v2/blind-evaluation.ts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