@ai-manifests/aap-validate
v1.0.0
Published
Validate AAP acknowledgment events and compute reference reputation weight
Downloads
132
Maintainers
Readme
aap-validate
Validate AAP acknowledgment events, check the anti-abuse semantic rules, and compute the reference reputation weight for an event.
Install
npm install -g @ai-manifests/aap-validateUsage
Validate AAP events
aap-validate ./appreciation-with-settlement.json
aap-validate ./a.json ./b.json ./c.jsonValidate a batch (with replay / duplicate-id detection)
Pass a directory of events to validate them as a set and detect duplicate id
values (replay protection, T4):
aap-validate --batch ./events/Compute the reference weight
Show the AAP §7.2 reference weight breakdown for an event (assumes
issuer_trust = 1 and an unverified settlement, i.e. no economic boost):
aap-validate --weight ./endorsement-witnessed.jsonSemantic Checks
| Check | Type | Threat |
|-------|------|--------|
| value.amount present ⇒ value.settlement_ref present | Error | T2 |
| value.amount is a non-negative decimal string | Error | T2 |
| WITHDRAWAL carries subject.context_ref | Error | T7 |
| Witness DID identical to issuer DID | Error | T9 |
| type is neither core nor x- extension | Error | T1 |
| Unknown x- type (weight-clamped by consumers) | Warning | T1 |
| value present (economic weight needs verified settlement) | Warning | T2 |
| Witnesses present (independence verified out-of-band) | Warning | T9 |
| expires_at not after issued_at (already expired) | Warning | — |
| note longer than the 280-char display recommendation | Warning | T8 |
| subject.context_ref advisory until resolved | Warning | T11 |
| Duplicate event id within a batch | Error | T4 |
Programmatic Use
import {
validateEvent,
validateBatch,
computeWeight,
typeWeight,
DEFAULT_TYPE_WEIGHTS,
} from '@ai-manifests/aap-validate';
const result = validateEvent(event);
const batchResult = validateBatch(events);
// Reference weight (AAP §7.2). value_weight applies only when settlement is verified.
const { weight, components } = computeWeight(event, {
issuerTrust: 0.8,
settlementVerified: true,
usdEquivalent: 0.50,
now: '2027-01-01T00:00:00Z', // enables time decay; omit for no decay
});How It Composes
aap-validate checks events at the source. The durable record layer that stores,
chains, federates, and aggregates these events is AAR;
validate the ledger with aar-validate.
The reference weight computed here is the AAP §7.2 view; the normative
aggregation algorithm — issuer-diversity penalty, recursive-trust bound,
mandatory settlement verification — lives in AAR §9 and is checked by
aar-validate.
aap-validate validates the acknowledgment event
aar-validate validates the ledger that stores and aggregates itStatus
v1.0 — Validates against AAP spec v1.0 (stable). Schemas for both v0 (draft
baseline) and v1.0 ship in schema/.
License
Apache-2.0 — see LICENSE for the full license text and NOTICE for attribution.
