@agenticprimitives/provenance 0.0.0-alpha.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/LICENSE +21 -0
- package/README.md +28 -0
- package/dist/firewall.d.ts +27 -0
- package/dist/firewall.d.ts.map +1 -0
- package/dist/firewall.js +60 -0
- package/dist/firewall.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/project.d.ts +40 -0
- package/dist/project.d.ts.map +1 -0
- package/dist/project.js +43 -0
- package/dist/project.js.map +1 -0
- package/dist/types.d.ts +56 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Agentic Trust Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# @agenticprimitives/provenance
|
|
2
|
+
|
|
3
|
+
The Ring-0 **provenance projector** (spec 316 §6). It maps fabric exchanges + orchestration runs into a
|
|
4
|
+
**private PROV-O / P-Plan A-box**, and enforces the ADR-0040 **public-projection firewall (S1)** on any
|
|
5
|
+
candidate world-readable row.
|
|
6
|
+
|
|
7
|
+
## What it owns
|
|
8
|
+
- **PROV-O A-box types** — `ProvActivity` (`CommunicationDelivery`/`IntentInvocation`/`OrchestratedTask` ⊑
|
|
9
|
+
`prov:Activity`), `ProvEntity`, `ProvAgentRef` (classified per ADR-0046), and **P-Plan** (`PPlanPlan`/
|
|
10
|
+
`PPlanStep`) grounding orchestration plans.
|
|
11
|
+
- **`projectExchangeProvenance`** / **`projectRunProvenance`** — the projectors (one trace: intent → plan →
|
|
12
|
+
executed activities → outcome, §15).
|
|
13
|
+
- **`isPublicProjectionSafe` / `assertPublicProjectionSafe`** — the S1 firewall.
|
|
14
|
+
|
|
15
|
+
## Hard rules
|
|
16
|
+
- **Sole writer of the PRIVATE vault A-box; it NEVER writes the public discovery KB.** The public KB has one
|
|
17
|
+
writer — the indexer — projecting on-chain facts (§6 / B1). There is no `fabric → public-KB` path.
|
|
18
|
+
- **S1 firewall (ADR-0040), fail-closed.** A public row is admissible ONLY if it carries a resolvable on-chain
|
|
19
|
+
anchor (`0x`+64 hex) + `OnchainConfirmed` assurance, AND has ZERO `actedOnBehalfOf` edges, ZERO person
|
|
20
|
+
attribution, ZERO inline plaintext, ZERO off-chain (`hmac-sha256:`) commitment fields.
|
|
21
|
+
- **Leaf, zero deps.** It takes STRUCTURAL input (plain fields) — never fabric's `ExchangeRecordV1` (which
|
|
22
|
+
would cycle: `fabric → provenance`). fabric adapts its record to these shapes.
|
|
23
|
+
|
|
24
|
+
## Validate
|
|
25
|
+
```bash
|
|
26
|
+
pnpm --filter @agenticprimitives/provenance typecheck
|
|
27
|
+
pnpm --filter @agenticprimitives/provenance test
|
|
28
|
+
```
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AgentClass } from './types.js';
|
|
2
|
+
/** A candidate world-readable KB row derived from a privileged outcome. */
|
|
3
|
+
export interface PublicProvenanceRow {
|
|
4
|
+
/** Outcome class (e.g. `DecisionArtifact` / `Artifact` / `PaymentReceipt`). */
|
|
5
|
+
type: string;
|
|
6
|
+
/** REQUIRED: the on-chain attestation UID anchoring this row (`apvr:anchoredBy`) — `0x` + 64 lowercase hex. */
|
|
7
|
+
anchoredBy?: string;
|
|
8
|
+
/** REQUIRED: the assurance floor — must be `OnchainConfirmed`. */
|
|
9
|
+
assurance?: string;
|
|
10
|
+
/** `prov:actedOnBehalfOf` / `apfab:onBehalfOf` edges — MUST be empty for a public row. */
|
|
11
|
+
actedOnBehalfOf?: string[];
|
|
12
|
+
/** `prov:wasAttributedTo` agent classes — MUST NOT include `person`. */
|
|
13
|
+
attributedToClasses?: AgentClass[];
|
|
14
|
+
/** Arbitrary row properties — scanned for forbidden private/off-chain content. */
|
|
15
|
+
properties?: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
export type FirewallResult = {
|
|
18
|
+
ok: true;
|
|
19
|
+
} | {
|
|
20
|
+
ok: false;
|
|
21
|
+
reason: string;
|
|
22
|
+
};
|
|
23
|
+
/** S1 firewall — is this row safe to project into the public discovery KB? Fail-closed. */
|
|
24
|
+
export declare function isPublicProjectionSafe(row: PublicProvenanceRow): FirewallResult;
|
|
25
|
+
/** S1 firewall (throwing variant) — use at the boundary where a row would be handed to the public projector. */
|
|
26
|
+
export declare function assertPublicProjectionSafe(row: PublicProvenanceRow): void;
|
|
27
|
+
//# sourceMappingURL=firewall.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firewall.d.ts","sourceRoot":"","sources":["../src/firewall.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,2EAA2E;AAC3E,MAAM,WAAW,mBAAmB;IAClC,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAC;IACb,+GAA+G;IAC/G,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kEAAkE;IAClE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0FAA0F;IAC1F,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,wEAAwE;IACxE,mBAAmB,CAAC,EAAE,UAAU,EAAE,CAAC;IACnC,kFAAkF;IAClF,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAED,MAAM,MAAM,cAAc,GAAG;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAgC1E,2FAA2F;AAC3F,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,mBAAmB,GAAG,cAAc,CAY/E;AAED,gHAAgH;AAChH,wBAAgB,0BAA0B,CAAC,GAAG,EAAE,mBAAmB,GAAG,IAAI,CAGzE"}
|
package/dist/firewall.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const ANCHOR = /^0x[0-9a-f]{64}$/;
|
|
2
|
+
const OFFCHAIN_HMAC = /^hmac-sha256:/;
|
|
3
|
+
const FORBIDDEN_PLAINTEXT_KEYS = new Set(['body', 'args', 'plaintext']);
|
|
4
|
+
const FORBIDDEN_OFFCHAIN_KEYS = new Set(['principalCommitment']);
|
|
5
|
+
// A forbidden key at ANY nesting depth is a leak (FAB-2: the shallow top-level scan let
|
|
6
|
+
// `properties:{meta:{body:…}}` through). The scan recurses into nested objects/arrays.
|
|
7
|
+
const MAX_SCAN_DEPTH = 8;
|
|
8
|
+
/** Recursively reject any forbidden key or off-chain-HMAC string value at any depth. */
|
|
9
|
+
function scanForbidden(value, keyPath, depth) {
|
|
10
|
+
if (depth > MAX_SCAN_DEPTH)
|
|
11
|
+
return `scan_depth_exceeded:${keyPath}`; // fail-closed on pathological nesting
|
|
12
|
+
if (typeof value === 'string')
|
|
13
|
+
return OFFCHAIN_HMAC.test(value) ? `offchain_hmac_field:${keyPath}` : null;
|
|
14
|
+
if (Array.isArray(value)) {
|
|
15
|
+
for (let i = 0; i < value.length; i++) {
|
|
16
|
+
const r = scanForbidden(value[i], `${keyPath}[${i}]`, depth + 1);
|
|
17
|
+
if (r)
|
|
18
|
+
return r;
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
if (value && typeof value === 'object') {
|
|
23
|
+
for (const [k, v] of Object.entries(value)) {
|
|
24
|
+
if (FORBIDDEN_OFFCHAIN_KEYS.has(k))
|
|
25
|
+
return `offchain_commitment_field:${keyPath}${k}`;
|
|
26
|
+
if (FORBIDDEN_PLAINTEXT_KEYS.has(k) && v != null)
|
|
27
|
+
return `inline_plaintext:${keyPath}${k}`;
|
|
28
|
+
const r = scanForbidden(v, `${keyPath}${k}.`, depth + 1);
|
|
29
|
+
if (r)
|
|
30
|
+
return r;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
/** S1 firewall — is this row safe to project into the public discovery KB? Fail-closed. */
|
|
36
|
+
export function isPublicProjectionSafe(row) {
|
|
37
|
+
// (necessary) — no private / off-chain content
|
|
38
|
+
if ((row.actedOnBehalfOf ?? []).length > 0)
|
|
39
|
+
return { ok: false, reason: 'actedOnBehalfOf_edge_present' };
|
|
40
|
+
if ((row.attributedToClasses ?? []).includes('person'))
|
|
41
|
+
return { ok: false, reason: 'person_attribution' };
|
|
42
|
+
// Recursive denylist scan — nested `body`/`args`/`plaintext`/`principalCommitment` keys or `hmac-sha256:`
|
|
43
|
+
// string values at ANY depth are rejected, not just top-level (FAB-2).
|
|
44
|
+
const forbidden = scanForbidden(row.properties ?? {}, '', 0);
|
|
45
|
+
if (forbidden)
|
|
46
|
+
return { ok: false, reason: forbidden };
|
|
47
|
+
// (sufficient) — on-chain anchor + assurance floor
|
|
48
|
+
if (!row.anchoredBy || !ANCHOR.test(row.anchoredBy))
|
|
49
|
+
return { ok: false, reason: 'missing_or_malformed_anchor' };
|
|
50
|
+
if (row.assurance !== 'OnchainConfirmed')
|
|
51
|
+
return { ok: false, reason: 'assurance_below_floor' };
|
|
52
|
+
return { ok: true };
|
|
53
|
+
}
|
|
54
|
+
/** S1 firewall (throwing variant) — use at the boundary where a row would be handed to the public projector. */
|
|
55
|
+
export function assertPublicProjectionSafe(row) {
|
|
56
|
+
const r = isPublicProjectionSafe(row);
|
|
57
|
+
if (!r.ok)
|
|
58
|
+
throw new Error(`S1 firewall: public provenance row rejected (${r.reason})`);
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=firewall.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"firewall.js","sourceRoot":"","sources":["../src/firewall.ts"],"names":[],"mappings":"AAiCA,MAAM,MAAM,GAAG,kBAAkB,CAAC;AAClC,MAAM,aAAa,GAAG,eAAe,CAAC;AACtC,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;AACxE,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC;AACjE,wFAAwF;AACxF,uFAAuF;AACvF,MAAM,cAAc,GAAG,CAAC,CAAC;AAEzB,wFAAwF;AACxF,SAAS,aAAa,CAAC,KAAc,EAAE,OAAe,EAAE,KAAa;IACnE,IAAI,KAAK,GAAG,cAAc;QAAE,OAAO,uBAAuB,OAAO,EAAE,CAAC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/provenance";
|
|
2
|
+
export declare const PACKAGE_STATUS: "w5-projector";
|
|
3
|
+
export declare const SPEC_REF = "specs/316-agentic-interaction-fabric.md";
|
|
4
|
+
export type { Tier, AgentClass, ProvAgentRef, ProvActivityType, ProvActivity, ProvEntityType, ProvEntity, PPlanStep, PPlanPlan, ProvenanceRecordV1, } from './types.js';
|
|
5
|
+
export { projectExchangeProvenance, projectRunProvenance, type ProvenanceExchangeInput, type ProvenanceRunInput, } from './project.js';
|
|
6
|
+
export { isPublicProjectionSafe, assertPublicProjectionSafe, type PublicProvenanceRow, type FirewallResult, } from './firewall.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,YAAY,kCAAkC,CAAC;AAC5D,eAAO,MAAM,cAAc,EAAG,cAAuB,CAAC;AACtD,eAAO,MAAM,QAAQ,4CAA4C,CAAC;AAElE,YAAY,EACV,IAAI,EACJ,UAAU,EACV,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,cAAc,EACd,UAAU,EACV,SAAS,EACT,SAAS,EACT,kBAAkB,GACnB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,GACxB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,KAAK,mBAAmB,EACxB,KAAK,cAAc,GACpB,MAAM,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// @agenticprimitives/provenance — the Ring-0 provenance projector (spec 316 §6). Sole writer of the PRIVATE
|
|
2
|
+
// PROV-O / P-Plan A-box; NEVER writes the public discovery KB (the indexer does, from on-chain facts). The S1
|
|
3
|
+
// firewall enforces the ADR-0040 rule on any candidate public row.
|
|
4
|
+
export const PACKAGE_NAME = '@agenticprimitives/provenance';
|
|
5
|
+
export const PACKAGE_STATUS = 'w5-projector';
|
|
6
|
+
export const SPEC_REF = 'specs/316-agentic-interaction-fabric.md';
|
|
7
|
+
export { projectExchangeProvenance, projectRunProvenance, } from './project.js';
|
|
8
|
+
export { isPublicProjectionSafe, assertPublicProjectionSafe, } from './firewall.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,8GAA8G;AAC9G,mEAAmE;AACnE,MAAM,CAAC,MAAM,YAAY,GAAG,+BAA+B,CAAC;AAC5D,MAAM,CAAC,MAAM,cAAc,GAAG,cAAuB,CAAC;AACtD,MAAM,CAAC,MAAM,QAAQ,GAAG,yCAAyC,CAAC;AAelE,OAAO,EACL,yBAAyB,EACzB,oBAAoB,GAGrB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,sBAAsB,EACtB,0BAA0B,GAG3B,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ProvenanceRecordV1, PPlanPlan, Tier, AgentClass } from './types.js';
|
|
2
|
+
/** Structural projection of a fabric exchange (never the fabric type — leaf boundary). */
|
|
3
|
+
export interface ProvenanceExchangeInput {
|
|
4
|
+
exchangeId: string;
|
|
5
|
+
tier: Tier;
|
|
6
|
+
/** The acting agent (gateway owner / responder). */
|
|
7
|
+
principal: string;
|
|
8
|
+
principalClass?: AgentClass;
|
|
9
|
+
from: string;
|
|
10
|
+
fromClass?: AgentClass;
|
|
11
|
+
at: string;
|
|
12
|
+
endedAt?: string;
|
|
13
|
+
/** BY-HASH delegation / entitlement / status-evidence refs (`prov:used`) — never inline authority. */
|
|
14
|
+
authorityRefs?: string[];
|
|
15
|
+
/** PRIVATE — the ultimate principal the actor acts for (`prov:actedOnBehalfOf`). Detail-tier only. */
|
|
16
|
+
onBehalfOf?: string;
|
|
17
|
+
/** The message / artifact produced, as a vault ref or hash (never inline plaintext). */
|
|
18
|
+
outputRef?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Project one exchange into the private A-box: one activity (`CommunicationDelivery`/`IntentInvocation`/
|
|
22
|
+
* `OrchestratedTask`), the message/artifact entity it generated (if any, by-ref), and the acting + sender
|
|
23
|
+
* agents. `onBehalfOf` and `used` carry the private authority detail; a public row is derived SEPARATELY and
|
|
24
|
+
* must pass the S1 firewall (`./firewall`).
|
|
25
|
+
*/
|
|
26
|
+
export declare function projectExchangeProvenance(input: ProvenanceExchangeInput): ProvenanceRecordV1;
|
|
27
|
+
/** Structural projection of an orchestration run (never the orchestration `RunResult` type — leaf boundary). */
|
|
28
|
+
export interface ProvenanceRunInput {
|
|
29
|
+
exchangeId: string;
|
|
30
|
+
goal: string;
|
|
31
|
+
steps: Array<{
|
|
32
|
+
toolId: string;
|
|
33
|
+
}>;
|
|
34
|
+
}
|
|
35
|
+
/** Project an orchestration run into a P-Plan (the `Plan` + its `Step`s), bridged to the exchange's
|
|
36
|
+
* `OrchestratedTask` activity by convention (`plan:<exchangeId>` ↔ `act:<exchangeId>`; §6/§15 — one trace). */
|
|
37
|
+
export declare function projectRunProvenance(input: ProvenanceRunInput): {
|
|
38
|
+
plan: PPlanPlan;
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=project.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,kBAAkB,EAKlB,SAAS,EACT,IAAI,EACJ,UAAU,EACX,MAAM,YAAY,CAAC;AAEpB,0FAA0F;AAC1F,MAAM,WAAW,uBAAuB;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,IAAI,CAAC;IACX,oDAAoD;IACpD,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,UAAU,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sGAAsG;IACtG,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,sGAAsG;IACtG,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wFAAwF;IACxF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAKD;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,uBAAuB,GAAG,kBAAkB,CA2B5F;AAED,gHAAgH;AAChH,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAClC;AAED;gHACgH;AAChH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,kBAAkB,GAAG;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAQnF"}
|
package/dist/project.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const activityType = (tier) => tier === 'communication' ? 'CommunicationDelivery' : tier === 'execution-orchestrated' ? 'OrchestratedTask' : 'IntentInvocation';
|
|
2
|
+
/**
|
|
3
|
+
* Project one exchange into the private A-box: one activity (`CommunicationDelivery`/`IntentInvocation`/
|
|
4
|
+
* `OrchestratedTask`), the message/artifact entity it generated (if any, by-ref), and the acting + sender
|
|
5
|
+
* agents. `onBehalfOf` and `used` carry the private authority detail; a public row is derived SEPARATELY and
|
|
6
|
+
* must pass the S1 firewall (`./firewall`).
|
|
7
|
+
*/
|
|
8
|
+
export function projectExchangeProvenance(input) {
|
|
9
|
+
const activityId = `act:${input.exchangeId}`;
|
|
10
|
+
const entityId = `ent:${input.exchangeId}`;
|
|
11
|
+
const type = activityType(input.tier);
|
|
12
|
+
const activity = {
|
|
13
|
+
id: activityId,
|
|
14
|
+
type,
|
|
15
|
+
tier: input.tier,
|
|
16
|
+
startedAt: input.at,
|
|
17
|
+
endedAt: input.endedAt,
|
|
18
|
+
wasAssociatedWith: input.principal,
|
|
19
|
+
used: input.authorityRefs ?? [],
|
|
20
|
+
onBehalfOf: input.onBehalfOf,
|
|
21
|
+
generated: input.outputRef ? [entityId] : [],
|
|
22
|
+
};
|
|
23
|
+
const entities = input.outputRef
|
|
24
|
+
? [{ id: entityId, type: type === 'OrchestratedTask' ? 'Artifact' : 'Message', wasGeneratedBy: activityId, ref: input.outputRef }]
|
|
25
|
+
: [];
|
|
26
|
+
const agents = [{ id: input.principal, agentClass: input.principalClass ?? 'service' }];
|
|
27
|
+
if (input.from.toLowerCase() !== input.principal.toLowerCase()) {
|
|
28
|
+
agents.push({ id: input.from, agentClass: input.fromClass ?? 'service' });
|
|
29
|
+
}
|
|
30
|
+
return { version: 'ap.provenance.v1', agents, activities: [activity], entities, plans: [] };
|
|
31
|
+
}
|
|
32
|
+
/** Project an orchestration run into a P-Plan (the `Plan` + its `Step`s), bridged to the exchange's
|
|
33
|
+
* `OrchestratedTask` activity by convention (`plan:<exchangeId>` ↔ `act:<exchangeId>`; §6/§15 — one trace). */
|
|
34
|
+
export function projectRunProvenance(input) {
|
|
35
|
+
const planId = `plan:${input.exchangeId}`;
|
|
36
|
+
return {
|
|
37
|
+
plan: {
|
|
38
|
+
id: planId,
|
|
39
|
+
steps: input.steps.map((s, i) => ({ id: `${planId}:step:${i}`, toolId: s.toolId, isStepOfPlan: planId })),
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAgCA,MAAM,YAAY,GAAG,CAAC,IAAU,EAAoB,EAAE,CACpD,IAAI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,IAAI,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,SAAS,CAAC,WAAW,EAAE,EAAE,CAAC;QAC/D,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,KAAK,CAAC,SAAS,IAAI,SAAS,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;AAC9F,CAAC;AASD;gHACgH;AAChH,MAAM,UAAU,oBAAoB,CAAC,KAAyB;IAC5D,MAAM,MAAM,GAAG,QAAQ,KAAK,CAAC,UAAU,EAAE,CAAC;IAC1C,OAAO;QACL,IAAI,EAAE;YACJ,EAAE,EAAE,MAAM;YACV,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,MAAM,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC;SAC1G;KACF,CAAC;AACJ,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export type Tier = 'communication' | 'execution-fast' | 'execution-orchestrated';
|
|
2
|
+
export type AgentClass = 'person' | 'org' | 'service';
|
|
3
|
+
/** PROV-O agent (`prov:Agent`), classified per ADR-0046. */
|
|
4
|
+
export interface ProvAgentRef {
|
|
5
|
+
id: string;
|
|
6
|
+
agentClass: AgentClass;
|
|
7
|
+
}
|
|
8
|
+
/** `apfab:CommunicationDelivery` (T0) / `apfab:IntentInvocation` (T1) / `apfab:OrchestratedTask ≡ apful:Task`
|
|
9
|
+
* (T2) — all `⊑ prov:Activity` (§6). */
|
|
10
|
+
export type ProvActivityType = 'CommunicationDelivery' | 'IntentInvocation' | 'OrchestratedTask';
|
|
11
|
+
export interface ProvActivity {
|
|
12
|
+
id: string;
|
|
13
|
+
type: ProvActivityType;
|
|
14
|
+
tier: Tier;
|
|
15
|
+
startedAt: string;
|
|
16
|
+
endedAt?: string;
|
|
17
|
+
/** `prov:wasAssociatedWith` — the acting agent id. */
|
|
18
|
+
wasAssociatedWith: string;
|
|
19
|
+
/** `apfab:usedDelegation`/`usedStatusEvidence ⊑ prov:used` — BY-HASH refs, never inline authority. */
|
|
20
|
+
used: string[];
|
|
21
|
+
/** `apfab:onBehalfOf ⊑ prov:actedOnBehalfOf` — **PRIVATE DETAIL ONLY** (the S1 firewall rejects it from any
|
|
22
|
+
* public row). */
|
|
23
|
+
onBehalfOf?: string;
|
|
24
|
+
/** `prov:generated` — entity ids this activity produced. */
|
|
25
|
+
generated: string[];
|
|
26
|
+
}
|
|
27
|
+
export type ProvEntityType = 'Message' | 'Artifact' | 'DecisionArtifact';
|
|
28
|
+
export interface ProvEntity {
|
|
29
|
+
id: string;
|
|
30
|
+
type: ProvEntityType;
|
|
31
|
+
/** `prov:wasGeneratedBy` — the activity id. */
|
|
32
|
+
wasGeneratedBy?: string;
|
|
33
|
+
/** Vault-resident ref (hash / VaultRef) — NEVER inline plaintext. */
|
|
34
|
+
ref?: string;
|
|
35
|
+
}
|
|
36
|
+
/** P-Plan (`tbox/plan.ttl`) — grounds an orchestration `Plan` (and a service-agent `PrimitivePlan`) as
|
|
37
|
+
* `p-plan:Plan`; steps are `p-plan:Step` via `isStepOfPlan` (§6). */
|
|
38
|
+
export interface PPlanStep {
|
|
39
|
+
id: string;
|
|
40
|
+
toolId: string;
|
|
41
|
+
isStepOfPlan: string;
|
|
42
|
+
}
|
|
43
|
+
export interface PPlanPlan {
|
|
44
|
+
id: string;
|
|
45
|
+
steps: PPlanStep[];
|
|
46
|
+
}
|
|
47
|
+
/** The PRIVATE vault A-box the projector writes — the ONLY surface this package emits. It NEVER writes the
|
|
48
|
+
* public discovery KB (that has exactly one writer, the indexer, projecting on-chain facts; §6 / B1). */
|
|
49
|
+
export interface ProvenanceRecordV1 {
|
|
50
|
+
version: 'ap.provenance.v1';
|
|
51
|
+
agents: ProvAgentRef[];
|
|
52
|
+
activities: ProvActivity[];
|
|
53
|
+
entities: ProvEntity[];
|
|
54
|
+
plans: PPlanPlan[];
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,IAAI,GAAG,eAAe,GAAG,gBAAgB,GAAG,wBAAwB,CAAC;AACjF,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,KAAK,GAAG,SAAS,CAAC;AAEtD,4DAA4D;AAC5D,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,UAAU,CAAC;CACxB;AAED;yCACyC;AACzC,MAAM,MAAM,gBAAgB,GAAG,uBAAuB,GAAG,kBAAkB,GAAG,kBAAkB,CAAC;AAEjG,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,gBAAgB,CAAC;IACvB,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,iBAAiB,EAAE,MAAM,CAAC;IAC1B,sGAAsG;IACtG,IAAI,EAAE,MAAM,EAAE,CAAC;IACf;uBACmB;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,UAAU,GAAG,kBAAkB,CAAC;AAEzE,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,cAAc,CAAC;IACrB,+CAA+C;IAC/C,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,qEAAqE;IACrE,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;sEACsE;AACtE,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;CACtB;AACD,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,SAAS,EAAE,CAAC;CACpB;AAED;0GAC0G;AAC1G,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,kBAAkB,CAAC;IAC5B,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,UAAU,EAAE,YAAY,EAAE,CAAC;IAC3B,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,KAAK,EAAE,SAAS,EAAE,CAAC;CACpB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAC3G,+GAA+G"}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agenticprimitives/provenance",
|
|
3
|
+
"version": "0.0.0-alpha.0",
|
|
4
|
+
"description": "The Ring-0 provenance projector (spec 316 §6): maps fabric exchanges + orchestration runs to a PRIVATE PROV-O / P-Plan A-box, and enforces the ADR-0040 public-projection firewall (S1). Sole writer of the private vault A-box; NEVER writes the public KB.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/agentictrustlabs/agenticprimitives.git",
|
|
9
|
+
"directory": "packages/provenance"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/agentictrustlabs/agenticprimitives/tree/master/packages/provenance",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/agentictrustlabs/agenticprimitives/issues"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"LICENSE",
|
|
26
|
+
"dist",
|
|
27
|
+
"README.md"
|
|
28
|
+
],
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"vitest": "^4.1.8",
|
|
34
|
+
"@types/node": "^22.7.0"
|
|
35
|
+
},
|
|
36
|
+
"keywords": [
|
|
37
|
+
"agentic",
|
|
38
|
+
"primitives",
|
|
39
|
+
"provenance",
|
|
40
|
+
"prov-o",
|
|
41
|
+
"p-plan",
|
|
42
|
+
"privacy"
|
|
43
|
+
],
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsc -p tsconfig.build.json",
|
|
46
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
47
|
+
"test": "vitest run",
|
|
48
|
+
"test:unit": "vitest run test/unit --passWithNoTests",
|
|
49
|
+
"test:watch": "vitest",
|
|
50
|
+
"clean": "rm -rf dist"
|
|
51
|
+
}
|
|
52
|
+
}
|