@neurcode-ai/governance-runtime 0.1.3 → 0.1.5
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/dist/admission-provenance.d.ts +111 -0
- package/dist/admission-provenance.d.ts.map +1 -0
- package/dist/admission-provenance.js +735 -0
- package/dist/admission-provenance.js.map +1 -0
- package/dist/agent-guard-posture.d.ts +40 -0
- package/dist/agent-guard-posture.d.ts.map +1 -0
- package/dist/agent-guard-posture.js +117 -0
- package/dist/agent-guard-posture.js.map +1 -0
- package/dist/agent-invocation-observability.d.ts +47 -0
- package/dist/agent-invocation-observability.d.ts.map +1 -0
- package/dist/agent-invocation-observability.js +229 -0
- package/dist/agent-invocation-observability.js.map +1 -0
- package/dist/agent-plan.d.ts +119 -0
- package/dist/agent-plan.d.ts.map +1 -0
- package/dist/agent-plan.js +590 -0
- package/dist/agent-plan.js.map +1 -0
- package/dist/agent-runtime-adapter.d.ts +69 -0
- package/dist/agent-runtime-adapter.d.ts.map +1 -0
- package/dist/agent-runtime-adapter.js +274 -0
- package/dist/agent-runtime-adapter.js.map +1 -0
- package/dist/ai-change-record.d.ts +185 -0
- package/dist/ai-change-record.d.ts.map +1 -0
- package/dist/ai-change-record.js +580 -0
- package/dist/ai-change-record.js.map +1 -0
- package/dist/architecture-graph.d.ts +153 -0
- package/dist/architecture-graph.d.ts.map +1 -0
- package/dist/architecture-graph.js +646 -0
- package/dist/architecture-graph.js.map +1 -0
- package/dist/architecture-obligations.d.ts +161 -0
- package/dist/architecture-obligations.d.ts.map +1 -0
- package/dist/architecture-obligations.js +553 -0
- package/dist/architecture-obligations.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +104 -1
- package/dist/index.js.map +1 -1
- package/dist/profile.d.ts +159 -0
- package/dist/profile.d.ts.map +1 -0
- package/dist/profile.js +611 -0
- package/dist/profile.js.map +1 -0
- package/dist/session.d.ts +428 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +2206 -0
- package/dist/session.js.map +1 -0
- package/package.json +13 -2
- package/src/constraints.ts +0 -828
- package/src/index.test.ts +0 -502
- package/src/index.ts +0 -463
- package/tsconfig.json +0 -19
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime Admission — pure provenance core (Phase A).
|
|
3
|
+
*
|
|
4
|
+
* Deterministic, source-free. No filesystem, no shell, no network. Consumes a
|
|
5
|
+
* raw git tree-delta (captured elsewhere) plus a governance classification map,
|
|
6
|
+
* and produces the normalized delta, the governed coverage manifest, and the
|
|
7
|
+
* two distinct hashes:
|
|
8
|
+
*
|
|
9
|
+
* - deltaHash — exact, base-specific normalized tree-delta fingerprint.
|
|
10
|
+
* - coverageSetHash — squash/rebase-survivable governed-effect SET fingerprint.
|
|
11
|
+
*
|
|
12
|
+
* Coverage matching is per-entry subset membership, never global-hash equality:
|
|
13
|
+
* a squash/rebase that preserves file content preserves coverage identities, so
|
|
14
|
+
* a previously governed PR stays matchable even though its base (and therefore
|
|
15
|
+
* its deltaHash) changed.
|
|
16
|
+
*
|
|
17
|
+
* Eligibility is strict by default (pre-write governance only); see
|
|
18
|
+
* `validateSelfAttestedRecordConsistency`.
|
|
19
|
+
*/
|
|
20
|
+
import { type AdmissionConsistencyDecision, type AdmissionCoverageClassification, type AdmissionCoverageEntry, type AdmissionCoverageManifest, type AdmissionDeltaEntry, type AdmissionEligibilityOptions, type GitObjectFormat, type SelfAttestedAdmissionRecord } from '@neurcode-ai/contracts';
|
|
21
|
+
/** Loose, capture-friendly raw delta entry. Renames/copies may be pre-split or split here. */
|
|
22
|
+
export interface RawDeltaInput {
|
|
23
|
+
path: string;
|
|
24
|
+
oldMode?: string | null;
|
|
25
|
+
newMode?: string | null;
|
|
26
|
+
oldObjectId?: string | null;
|
|
27
|
+
newObjectId?: string | null;
|
|
28
|
+
/** Optional git rawstatus (e.g. 'A','M','D','R100','C75','T'); R/C split into delete+add. */
|
|
29
|
+
status?: string | null;
|
|
30
|
+
/** Rename/copy source path. */
|
|
31
|
+
oldPath?: string | null;
|
|
32
|
+
}
|
|
33
|
+
export interface GovernanceClassificationInput {
|
|
34
|
+
classification: AdmissionCoverageClassification;
|
|
35
|
+
sessions?: string[];
|
|
36
|
+
}
|
|
37
|
+
/** path → governance classification + contributing sessions (from guard posture / session events). */
|
|
38
|
+
export type GovernanceClassificationMap = Record<string, GovernanceClassificationInput>;
|
|
39
|
+
export interface BuildCoverageManifestInput {
|
|
40
|
+
rawDelta: RawDeltaInput[];
|
|
41
|
+
governance?: GovernanceClassificationMap;
|
|
42
|
+
objectFormat: GitObjectFormat;
|
|
43
|
+
}
|
|
44
|
+
export declare const MAX_ADMISSION_JSON_BYTES: number;
|
|
45
|
+
export declare const MAX_ADMISSION_DELTA_ENTRIES = 100000;
|
|
46
|
+
export declare const MAX_ADMISSION_COVERAGE_ENTRIES = 100000;
|
|
47
|
+
export declare const MAX_ADMISSION_SESSION_REFS = 4096;
|
|
48
|
+
export declare const MAX_ADMISSION_SESSIONS_PER_ENTRY = 4096;
|
|
49
|
+
export declare const MAX_ADMISSION_PATH_LENGTH = 4096;
|
|
50
|
+
export declare const MAX_ADMISSION_ID_LENGTH = 256;
|
|
51
|
+
export declare function sortDeltaEntries(entries: AdmissionDeltaEntry[]): AdmissionDeltaEntry[];
|
|
52
|
+
export declare function sortCoverageEntries(entries: AdmissionCoverageEntry[]): AdmissionCoverageEntry[];
|
|
53
|
+
/**
|
|
54
|
+
* Normalize raw capture entries into the canonical delta. Renames become a
|
|
55
|
+
* delete (old path) + add (new path); copies become an add only (the source is
|
|
56
|
+
* unchanged and not part of the tree delta). Deterministically sorted, deduped.
|
|
57
|
+
*/
|
|
58
|
+
export declare function normalizeDeltaEntries(raw: RawDeltaInput[], objectFormat: GitObjectFormat): AdmissionDeltaEntry[];
|
|
59
|
+
/**
|
|
60
|
+
* Derive governed coverage entries from a normalized delta plus a per-path
|
|
61
|
+
* classification map. Paths with no governance evidence are 'ungoverned'.
|
|
62
|
+
*/
|
|
63
|
+
export declare function deriveCoverageEntries(delta: AdmissionDeltaEntry[], governance?: GovernanceClassificationMap): AdmissionCoverageEntry[];
|
|
64
|
+
export declare function computeDeltaHash(delta: AdmissionDeltaEntry[], objectFormat: GitObjectFormat): string;
|
|
65
|
+
/**
|
|
66
|
+
* Hash of the governed-effect identity SET. Deduped by identity (classification
|
|
67
|
+
* and sessions are excluded), sorted, framed. Stable across squash/rebase that
|
|
68
|
+
* preserve file content.
|
|
69
|
+
*/
|
|
70
|
+
export declare function computeCoverageSetHash(coverage: AdmissionCoverageEntry[], objectFormat: GitObjectFormat): string;
|
|
71
|
+
export declare function buildCoverageManifest(input: BuildCoverageManifestInput): AdmissionCoverageManifest;
|
|
72
|
+
/**
|
|
73
|
+
* Deterministically union coverage entries from multiple sessions/manifests.
|
|
74
|
+
* Entries sharing an identity (path + mode + objectId) merge: classification
|
|
75
|
+
* becomes the strongest, sessions union and sort. Distinct identities are kept
|
|
76
|
+
* (e.g. the same path edited to different final objects by different sessions).
|
|
77
|
+
*/
|
|
78
|
+
export declare function unionCoverageEntries(groups: AdmissionCoverageEntry[][]): AdmissionCoverageEntry[];
|
|
79
|
+
export declare function unionCoverageManifests(manifests: AdmissionCoverageManifest[], objectFormat: GitObjectFormat): {
|
|
80
|
+
coverage: AdmissionCoverageEntry[];
|
|
81
|
+
coverageSetHash: string;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Validate a self-attested record against a recomputed ground-truth delta.
|
|
85
|
+
*
|
|
86
|
+
* The coverage verdict is decided by per-entry subset matching of the
|
|
87
|
+
* ground-truth identities against the record's ADMISSIBLE coverage entries —
|
|
88
|
+
* NOT by deltaHash equality (which is base-specific and breaks under
|
|
89
|
+
* squash/rebase). `deltaHashMatches` is a diagnostic only.
|
|
90
|
+
*
|
|
91
|
+
* Eligibility defaults to STRICT (pre-write governance only): `observed_postwrite`
|
|
92
|
+
* and `generated` do not satisfy admission unless `options` opts in
|
|
93
|
+
* (`mode: 'descriptive'` or `allowGenerated: true`).
|
|
94
|
+
*
|
|
95
|
+
* 'self_attested_inconsistent' is reserved for a record whose own claimed hashes
|
|
96
|
+
* do not match its own contents (corrupted/tampered artifact). This function
|
|
97
|
+
* never throws: malformed input yields 'self_attested_inconsistent'.
|
|
98
|
+
*/
|
|
99
|
+
export declare function validateSelfAttestedRecordConsistency(record: SelfAttestedAdmissionRecord | null | undefined, groundTruthDelta: AdmissionDeltaEntry[], objectFormat: GitObjectFormat, options?: AdmissionEligibilityOptions): AdmissionConsistencyDecision;
|
|
100
|
+
/**
|
|
101
|
+
* Strict, bounded structural validation of an untrusted, already-parsed value.
|
|
102
|
+
* Returns a typed record only when every field, enum, hash, mode, array, and
|
|
103
|
+
* limit checks out; otherwise null. Never throws.
|
|
104
|
+
*/
|
|
105
|
+
export declare function readSelfAttestedAdmissionRecord(value: unknown): SelfAttestedAdmissionRecord | null;
|
|
106
|
+
/**
|
|
107
|
+
* Parse + validate untrusted artifact JSON text. Enforces a byte ceiling before
|
|
108
|
+
* JSON.parse, never throws, and returns null on any violation.
|
|
109
|
+
*/
|
|
110
|
+
export declare function readSelfAttestedAdmissionRecordFromText(text: unknown): SelfAttestedAdmissionRecord | null;
|
|
111
|
+
//# sourceMappingURL=admission-provenance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admission-provenance.d.ts","sourceRoot":"","sources":["../src/admission-provenance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAoBL,KAAK,4BAA4B,EAEjC,KAAK,+BAA+B,EACpC,KAAK,sBAAsB,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,mBAAmB,EACxB,KAAK,2BAA2B,EAEhC,KAAK,eAAe,EAEpB,KAAK,2BAA2B,EACjC,MAAM,wBAAwB,CAAC;AAEhC,8FAA8F;AAC9F,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE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