agent-alignment-protocol 0.1.4__tar.gz → 0.1.6__tar.gz
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.
- {agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/PKG-INFO +1 -1
- {agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/pyproject.toml +1 -1
- {agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/src/aap/verification/__init__.py +2 -0
- {agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/src/aap/verification/constants.py +1 -1
- {agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/src/aap/verification/divergence.py +34 -10
- {agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/src/aap/verification/features.py +12 -0
- {agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/.gitignore +0 -0
- {agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/LICENSE +0 -0
- {agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/README.md +0 -0
- {agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/schemas/alignment-card.schema.json +0 -0
- {agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/schemas/ap-trace.schema.json +0 -0
- {agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/schemas/value-coherence.schema.json +0 -0
- {agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/src/aap/__init__.py +0 -0
- {agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/src/aap/cli/__init__.py +0 -0
- {agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/src/aap/cli/main.py +0 -0
- {agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/src/aap/py.typed +0 -0
- {agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/src/aap/schemas/__init__.py +0 -0
- {agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/src/aap/schemas/alignment_card.py +0 -0
- {agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/src/aap/schemas/ap_trace.py +0 -0
- {agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/src/aap/schemas/value_coherence.py +0 -0
- {agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/src/aap/tracing.py +0 -0
- {agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/src/aap/verification/api.py +0 -0
- {agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/src/aap/verification/models.py +0 -0
- {agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/src/aap/verification/ssm.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agent-alignment-protocol
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.6
|
|
4
4
|
Summary: Agent Alignment Protocol - The missing alignment layer for the agent protocol stack
|
|
5
5
|
Project-URL: Homepage, https://github.com/mnemom/aap
|
|
6
6
|
Project-URL: Documentation, https://github.com/mnemom/aap#readme
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "agent-alignment-protocol"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.6"
|
|
8
8
|
description = "Agent Alignment Protocol - The missing alignment layer for the agent protocol stack"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "Apache-2.0"
|
{agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/src/aap/verification/__init__.py
RENAMED
|
@@ -52,6 +52,7 @@ from aap.verification.divergence import (
|
|
|
52
52
|
)
|
|
53
53
|
from aap.verification.features import (
|
|
54
54
|
FeatureExtractor,
|
|
55
|
+
compute_centroid,
|
|
55
56
|
compute_similarity_with_tfidf,
|
|
56
57
|
cosine_similarity,
|
|
57
58
|
)
|
|
@@ -87,6 +88,7 @@ __all__ = [
|
|
|
87
88
|
"detect_divergence",
|
|
88
89
|
# Feature extraction
|
|
89
90
|
"FeatureExtractor",
|
|
91
|
+
"compute_centroid",
|
|
90
92
|
"cosine_similarity",
|
|
91
93
|
"compute_similarity_with_tfidf",
|
|
92
94
|
# Result models
|
{agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/src/aap/verification/divergence.py
RENAMED
|
@@ -23,7 +23,7 @@ from aap.verification.constants import (
|
|
|
23
23
|
DEFAULT_SIMILARITY_THRESHOLD,
|
|
24
24
|
DEFAULT_SUSTAINED_TURNS_THRESHOLD,
|
|
25
25
|
)
|
|
26
|
-
from aap.verification.features import FeatureExtractor, cosine_similarity
|
|
26
|
+
from aap.verification.features import FeatureExtractor, compute_centroid, cosine_similarity
|
|
27
27
|
from aap.verification.models import (
|
|
28
28
|
DriftAlert,
|
|
29
29
|
DriftAnalysis,
|
|
@@ -68,23 +68,39 @@ class DivergenceDetector:
|
|
|
68
68
|
"""Detect divergence alerts for a sequence of traces.
|
|
69
69
|
|
|
70
70
|
Analyzes traces chronologically, computing similarity between each
|
|
71
|
-
trace
|
|
72
|
-
sustained divergence (consecutive traces below
|
|
71
|
+
trace and a baseline centroid computed from the first N traces.
|
|
72
|
+
Generates alerts for sustained divergence (consecutive traces below
|
|
73
|
+
threshold).
|
|
73
74
|
|
|
74
75
|
Args:
|
|
75
76
|
card: Alignment Card dict per SPEC Section 4
|
|
76
|
-
traces: List of AP-Trace dicts
|
|
77
|
+
traces: List of AP-Trace dicts (sorted chronologically internally)
|
|
77
78
|
|
|
78
79
|
Returns:
|
|
79
80
|
List of DriftAlert objects for detected divergences
|
|
80
81
|
"""
|
|
81
|
-
if not traces
|
|
82
|
+
if not traces:
|
|
83
|
+
return []
|
|
84
|
+
|
|
85
|
+
# Sort traces chronologically
|
|
86
|
+
sorted_traces = sorted(traces, key=lambda t: t.get("timestamp", ""))
|
|
87
|
+
|
|
88
|
+
# Compute baseline window size
|
|
89
|
+
baseline_size = max(self.sustained_turns_threshold, min(10, len(sorted_traces) // 4))
|
|
90
|
+
|
|
91
|
+
# Need enough traces for baseline + sustained threshold
|
|
92
|
+
if len(sorted_traces) < baseline_size + self.sustained_turns_threshold:
|
|
82
93
|
return []
|
|
83
94
|
|
|
84
|
-
# Extract card features once
|
|
85
|
-
card_features = self._feature_extractor.extract_card_features(card)
|
|
86
95
|
card_id = card.get("card_id", "")
|
|
87
96
|
|
|
97
|
+
# Extract features for baseline traces and compute centroid
|
|
98
|
+
baseline_features = [
|
|
99
|
+
self._feature_extractor.extract_trace_features(t)
|
|
100
|
+
for t in sorted_traces[:baseline_size]
|
|
101
|
+
]
|
|
102
|
+
baseline_centroid = compute_centroid(baseline_features)
|
|
103
|
+
|
|
88
104
|
alerts: list[DriftAlert] = []
|
|
89
105
|
low_similarity_streak: list[tuple[dict, float]] = []
|
|
90
106
|
|
|
@@ -92,10 +108,18 @@ class DivergenceDetector:
|
|
|
92
108
|
escalation_rates: list[float] = []
|
|
93
109
|
value_usage: dict[str, int] = defaultdict(int)
|
|
94
110
|
|
|
95
|
-
|
|
96
|
-
|
|
111
|
+
# Include baseline traces in escalation/value tracking
|
|
112
|
+
for trace in sorted_traces[:baseline_size]:
|
|
113
|
+
escalation = trace.get("escalation", {})
|
|
114
|
+
escalation_rates.append(1.0 if escalation.get("required") else 0.0)
|
|
115
|
+
for value in trace.get("decision", {}).get("values_applied", []):
|
|
116
|
+
value_usage[value] += 1
|
|
117
|
+
|
|
118
|
+
# Iterate from after baseline to end
|
|
119
|
+
for trace in sorted_traces[baseline_size:]:
|
|
120
|
+
# Compute similarity to baseline centroid
|
|
97
121
|
trace_features = self._feature_extractor.extract_trace_features(trace)
|
|
98
|
-
similarity = cosine_similarity(trace_features,
|
|
122
|
+
similarity = cosine_similarity(trace_features, baseline_centroid)
|
|
99
123
|
|
|
100
124
|
# Track escalation rate
|
|
101
125
|
escalation = trace.get("escalation", {})
|
{agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/src/aap/verification/features.py
RENAMED
|
@@ -351,6 +351,18 @@ class FeatureExtractor:
|
|
|
351
351
|
return features
|
|
352
352
|
|
|
353
353
|
|
|
354
|
+
def compute_centroid(vectors: list[dict[str, float]]) -> dict[str, float]:
|
|
355
|
+
"""Compute the centroid (element-wise average) of sparse feature vectors."""
|
|
356
|
+
if not vectors:
|
|
357
|
+
return {}
|
|
358
|
+
centroid: dict[str, float] = {}
|
|
359
|
+
for vec in vectors:
|
|
360
|
+
for key, value in vec.items():
|
|
361
|
+
centroid[key] = centroid.get(key, 0.0) + value
|
|
362
|
+
n = len(vectors)
|
|
363
|
+
return {k: v / n for k, v in centroid.items()}
|
|
364
|
+
|
|
365
|
+
|
|
354
366
|
def cosine_similarity(a: dict[str, float], b: dict[str, float]) -> float:
|
|
355
367
|
"""Compute cosine similarity between two sparse feature vectors.
|
|
356
368
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/schemas/alignment-card.schema.json
RENAMED
|
File without changes
|
{agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/schemas/ap-trace.schema.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/src/aap/schemas/__init__.py
RENAMED
|
File without changes
|
{agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/src/aap/schemas/alignment_card.py
RENAMED
|
File without changes
|
{agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/src/aap/schemas/ap_trace.py
RENAMED
|
File without changes
|
{agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/src/aap/schemas/value_coherence.py
RENAMED
|
File without changes
|
|
File without changes
|
{agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/src/aap/verification/api.py
RENAMED
|
File without changes
|
{agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/src/aap/verification/models.py
RENAMED
|
File without changes
|
{agent_alignment_protocol-0.1.4 → agent_alignment_protocol-0.1.6}/src/aap/verification/ssm.py
RENAMED
|
File without changes
|