@mnemom/agent-alignment-protocol 0.3.0 → 0.5.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 CHANGED
@@ -6,7 +6,7 @@
6
6
  [![PyPI](https://img.shields.io/pypi/v/agent-alignment-protocol.svg)](https://pypi.org/project/agent-alignment-protocol/)
7
7
  [![npm](https://img.shields.io/npm/v/@mnemom/agent-alignment-protocol.svg)](https://www.npmjs.com/package/@mnemom/agent-alignment-protocol)
8
8
  [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)
9
- [![Spec](https://img.shields.io/badge/spec-v0.1.0-green.svg)](docs/SPEC.md)
9
+ [![Spec](https://img.shields.io/badge/spec-v0.4.0-green.svg)](docs/SPEC.md)
10
10
 
11
11
  **A transparency protocol for autonomous agents.**
12
12
 
package/dist/index.d.mts CHANGED
@@ -516,6 +516,13 @@ interface FleetCoherenceResult {
516
516
  /**
517
517
  * Verify a single AP-Trace against an Alignment Card.
518
518
  *
519
+ * IMPORTANT: This function provides STRUCTURAL verification only — it checks that
520
+ * a trace conforms to the declarations in an alignment card. It does NOT provide
521
+ * cryptographic integrity verification. Traces are not signed or hash-chained in
522
+ * the current version. A malicious agent can produce structurally valid traces for
523
+ * arbitrary behavior. For integrity guarantees, use AIP (Agent Integrity Protocol)
524
+ * in conjunction with AAP.
525
+ *
519
526
  * Performs the verification algorithm specified in SPEC Section 7.3:
520
527
  * 1. Autonomy compliance - action category matches autonomy envelope
521
528
  * 2. Escalation compliance - required escalations were performed
package/dist/index.d.ts CHANGED
@@ -516,6 +516,13 @@ interface FleetCoherenceResult {
516
516
  /**
517
517
  * Verify a single AP-Trace against an Alignment Card.
518
518
  *
519
+ * IMPORTANT: This function provides STRUCTURAL verification only — it checks that
520
+ * a trace conforms to the declarations in an alignment card. It does NOT provide
521
+ * cryptographic integrity verification. Traces are not signed or hash-chained in
522
+ * the current version. A malicious agent can produce structurally valid traces for
523
+ * arbitrary behavior. For integrity guarantees, use AIP (Agent Integrity Protocol)
524
+ * in conjunction with AAP.
525
+ *
519
526
  * Performs the verification algorithm specified in SPEC Section 7.3:
520
527
  * 1. Autonomy compliance - action category matches autonomy envelope
521
528
  * 2. Escalation compliance - required escalations were performed
package/dist/index.js CHANGED
@@ -243,6 +243,10 @@ function verifyTrace(trace, card) {
243
243
  const violations = [];
244
244
  const warnings = [];
245
245
  const checksPerformed = [];
246
+ const tamperEvidence = card.audit?.commitment?.tamper_evidence;
247
+ if (tamperEvidence === "signed" || tamperEvidence === "merkle") {
248
+ console.warn(`[AAP] Warning: tamper_evidence mode "${tamperEvidence}" is declared but NOT cryptographically enforced in this version.`);
249
+ }
246
250
  const traceId = trace.trace_id ?? "";
247
251
  const cardId = card.card_id ?? "";
248
252
  checksPerformed.push("card_reference");
@@ -413,7 +417,7 @@ function checkCoherence(myCard, theirCard, taskValues) {
413
417
  }
414
418
  const totalRequired = requiredValues.size || 1;
415
419
  const matchedCount = taskValues ? matched.filter((v) => requiredValues.has(v)).length : matched.length;
416
- const conflictPenalty = CONFLICT_PENALTY_MULTIPLIER * (conflicts.length / totalRequired);
420
+ const conflictPenalty = Math.min(1, CONFLICT_PENALTY_MULTIPLIER * (conflicts.length / totalRequired));
417
421
  let score = matchedCount / totalRequired * (1 - conflictPenalty);
418
422
  score = Math.max(0, Math.min(1, score));
419
423
  const compatible = conflicts.length === 0 && score >= MIN_COHERENCE_FOR_PROCEED;
@@ -755,6 +759,7 @@ function evaluateCondition(condition, trace) {
755
759
  const ctxValue = trace.context?.[condition];
756
760
  return Boolean(ctxValue ?? trace.context?.metadata?.[condition]);
757
761
  }
762
+ console.warn(`[AAP] Condition could not be parsed: "${condition}". Supported patterns: "field == value", "field > number", "field_name" (boolean). This trigger will not fire.`);
758
763
  return false;
759
764
  }
760
765
  function inferDriftDirection(streak, card, escalationRates, valueUsage) {
package/dist/index.mjs CHANGED
@@ -188,6 +188,10 @@ function verifyTrace(trace, card) {
188
188
  const violations = [];
189
189
  const warnings = [];
190
190
  const checksPerformed = [];
191
+ const tamperEvidence = card.audit?.commitment?.tamper_evidence;
192
+ if (tamperEvidence === "signed" || tamperEvidence === "merkle") {
193
+ console.warn(`[AAP] Warning: tamper_evidence mode "${tamperEvidence}" is declared but NOT cryptographically enforced in this version.`);
194
+ }
191
195
  const traceId = trace.trace_id ?? "";
192
196
  const cardId = card.card_id ?? "";
193
197
  checksPerformed.push("card_reference");
@@ -358,7 +362,7 @@ function checkCoherence(myCard, theirCard, taskValues) {
358
362
  }
359
363
  const totalRequired = requiredValues.size || 1;
360
364
  const matchedCount = taskValues ? matched.filter((v) => requiredValues.has(v)).length : matched.length;
361
- const conflictPenalty = CONFLICT_PENALTY_MULTIPLIER * (conflicts.length / totalRequired);
365
+ const conflictPenalty = Math.min(1, CONFLICT_PENALTY_MULTIPLIER * (conflicts.length / totalRequired));
362
366
  let score = matchedCount / totalRequired * (1 - conflictPenalty);
363
367
  score = Math.max(0, Math.min(1, score));
364
368
  const compatible = conflicts.length === 0 && score >= MIN_COHERENCE_FOR_PROCEED;
@@ -700,6 +704,7 @@ function evaluateCondition(condition, trace) {
700
704
  const ctxValue = trace.context?.[condition];
701
705
  return Boolean(ctxValue ?? trace.context?.metadata?.[condition]);
702
706
  }
707
+ console.warn(`[AAP] Condition could not be parsed: "${condition}". Supported patterns: "field == value", "field > number", "field_name" (boolean). This trigger will not fire.`);
703
708
  return false;
704
709
  }
705
710
  function inferDriftDirection(streak, card, escalationRates, valueUsage) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mnemom/agent-alignment-protocol",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Agent Alignment Protocol (AAP) - Verification and drift detection for AI agents",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -70,6 +70,13 @@ function actionMatchesList(actionName: string, list: string[]): boolean {
70
70
  /**
71
71
  * Verify a single AP-Trace against an Alignment Card.
72
72
  *
73
+ * IMPORTANT: This function provides STRUCTURAL verification only — it checks that
74
+ * a trace conforms to the declarations in an alignment card. It does NOT provide
75
+ * cryptographic integrity verification. Traces are not signed or hash-chained in
76
+ * the current version. A malicious agent can produce structurally valid traces for
77
+ * arbitrary behavior. For integrity guarantees, use AIP (Agent Integrity Protocol)
78
+ * in conjunction with AAP.
79
+ *
73
80
  * Performs the verification algorithm specified in SPEC Section 7.3:
74
81
  * 1. Autonomy compliance - action category matches autonomy envelope
75
82
  * 2. Escalation compliance - required escalations were performed
@@ -89,6 +96,12 @@ export function verifyTrace(
89
96
  const warnings: Warning[] = [];
90
97
  const checksPerformed: string[] = [];
91
98
 
99
+ // Warn if tamper_evidence is declared but not cryptographically enforced
100
+ const tamperEvidence = (card as Record<string, any>).audit?.commitment?.tamper_evidence;
101
+ if (tamperEvidence === 'signed' || tamperEvidence === 'merkle') {
102
+ console.warn(`[AAP] Warning: tamper_evidence mode "${tamperEvidence}" is declared but NOT cryptographically enforced in this version.`);
103
+ }
104
+
92
105
  const traceId = trace.trace_id ?? "";
93
106
  const cardId = card.card_id ?? "";
94
107
 
@@ -315,7 +328,7 @@ export function checkCoherence(
315
328
  const matchedCount = taskValues
316
329
  ? matched.filter((v) => requiredValues.has(v)).length
317
330
  : matched.length;
318
- const conflictPenalty = CONFLICT_PENALTY_MULTIPLIER * (conflicts.length / totalRequired);
331
+ const conflictPenalty = Math.min(1, CONFLICT_PENALTY_MULTIPLIER * (conflicts.length / totalRequired));
319
332
 
320
333
  let score = (matchedCount / totalRequired) * (1 - conflictPenalty);
321
334
  score = Math.max(0, Math.min(1, score)); // Clamp to [0, 1]
@@ -798,6 +811,7 @@ function evaluateCondition(condition: string, trace: APTrace): boolean {
798
811
  return Boolean(ctxValue ?? trace.context?.metadata?.[condition]);
799
812
  }
800
813
 
814
+ console.warn(`[AAP] Condition could not be parsed: "${condition}". Supported patterns: "field == value", "field > number", "field_name" (boolean). This trigger will not fire.`);
801
815
  return false;
802
816
  }
803
817