@rengler33/prov 0.1.1
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 +314 -0
- package/dist/cli.d.ts +26 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +381 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/agent.d.ts +107 -0
- package/dist/commands/agent.d.ts.map +1 -0
- package/dist/commands/agent.js +197 -0
- package/dist/commands/agent.js.map +1 -0
- package/dist/commands/agent.test.d.ts +5 -0
- package/dist/commands/agent.test.d.ts.map +1 -0
- package/dist/commands/agent.test.js +199 -0
- package/dist/commands/agent.test.js.map +1 -0
- package/dist/commands/constraint.d.ts +100 -0
- package/dist/commands/constraint.d.ts.map +1 -0
- package/dist/commands/constraint.js +763 -0
- package/dist/commands/constraint.js.map +1 -0
- package/dist/commands/constraint.test.d.ts +9 -0
- package/dist/commands/constraint.test.d.ts.map +1 -0
- package/dist/commands/constraint.test.js +470 -0
- package/dist/commands/constraint.test.js.map +1 -0
- package/dist/commands/graph.d.ts +99 -0
- package/dist/commands/graph.d.ts.map +1 -0
- package/dist/commands/graph.js +552 -0
- package/dist/commands/graph.js.map +1 -0
- package/dist/commands/graph.test.d.ts +2 -0
- package/dist/commands/graph.test.d.ts.map +1 -0
- package/dist/commands/graph.test.js +258 -0
- package/dist/commands/graph.test.js.map +1 -0
- package/dist/commands/impact.d.ts +83 -0
- package/dist/commands/impact.d.ts.map +1 -0
- package/dist/commands/impact.js +319 -0
- package/dist/commands/impact.js.map +1 -0
- package/dist/commands/impact.test.d.ts +2 -0
- package/dist/commands/impact.test.d.ts.map +1 -0
- package/dist/commands/impact.test.js +234 -0
- package/dist/commands/impact.test.js.map +1 -0
- package/dist/commands/init.d.ts +45 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +94 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/init.test.d.ts +7 -0
- package/dist/commands/init.test.d.ts.map +1 -0
- package/dist/commands/init.test.js +174 -0
- package/dist/commands/init.test.js.map +1 -0
- package/dist/commands/integration.test.d.ts +10 -0
- package/dist/commands/integration.test.d.ts.map +1 -0
- package/dist/commands/integration.test.js +456 -0
- package/dist/commands/integration.test.js.map +1 -0
- package/dist/commands/mcp.d.ts +21 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +616 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/mcp.test.d.ts +7 -0
- package/dist/commands/mcp.test.d.ts.map +1 -0
- package/dist/commands/mcp.test.js +132 -0
- package/dist/commands/mcp.test.js.map +1 -0
- package/dist/commands/plan.d.ts +218 -0
- package/dist/commands/plan.d.ts.map +1 -0
- package/dist/commands/plan.js +1307 -0
- package/dist/commands/plan.js.map +1 -0
- package/dist/commands/plan.test.d.ts +9 -0
- package/dist/commands/plan.test.d.ts.map +1 -0
- package/dist/commands/plan.test.js +569 -0
- package/dist/commands/plan.test.js.map +1 -0
- package/dist/commands/spec.d.ts +94 -0
- package/dist/commands/spec.d.ts.map +1 -0
- package/dist/commands/spec.js +635 -0
- package/dist/commands/spec.js.map +1 -0
- package/dist/commands/spec.test.d.ts +9 -0
- package/dist/commands/spec.test.d.ts.map +1 -0
- package/dist/commands/spec.test.js +407 -0
- package/dist/commands/spec.test.js.map +1 -0
- package/dist/commands/trace.d.ts +157 -0
- package/dist/commands/trace.d.ts.map +1 -0
- package/dist/commands/trace.js +847 -0
- package/dist/commands/trace.js.map +1 -0
- package/dist/commands/trace.test.d.ts +9 -0
- package/dist/commands/trace.test.d.ts.map +1 -0
- package/dist/commands/trace.test.js +524 -0
- package/dist/commands/trace.test.js.map +1 -0
- package/dist/graph.d.ts +204 -0
- package/dist/graph.d.ts.map +1 -0
- package/dist/graph.js +496 -0
- package/dist/graph.js.map +1 -0
- package/dist/graph.test.d.ts +2 -0
- package/dist/graph.test.d.ts.map +1 -0
- package/dist/graph.test.js +382 -0
- package/dist/graph.test.js.map +1 -0
- package/dist/hash.d.ts +72 -0
- package/dist/hash.d.ts.map +1 -0
- package/dist/hash.js +137 -0
- package/dist/hash.js.map +1 -0
- package/dist/hash.test.d.ts +2 -0
- package/dist/hash.test.d.ts.map +1 -0
- package/dist/hash.test.js +227 -0
- package/dist/hash.test.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +64 -0
- package/dist/index.js.map +1 -0
- package/dist/index.test.d.ts +2 -0
- package/dist/index.test.d.ts.map +1 -0
- package/dist/index.test.js +11 -0
- package/dist/index.test.js.map +1 -0
- package/dist/output.d.ts +84 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +175 -0
- package/dist/output.js.map +1 -0
- package/dist/output.test.d.ts +7 -0
- package/dist/output.test.d.ts.map +1 -0
- package/dist/output.test.js +146 -0
- package/dist/output.test.js.map +1 -0
- package/dist/staleness.d.ts +162 -0
- package/dist/staleness.d.ts.map +1 -0
- package/dist/staleness.js +309 -0
- package/dist/staleness.js.map +1 -0
- package/dist/staleness.test.d.ts +2 -0
- package/dist/staleness.test.d.ts.map +1 -0
- package/dist/staleness.test.js +448 -0
- package/dist/staleness.test.js.map +1 -0
- package/dist/storage.d.ts +267 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +623 -0
- package/dist/storage.js.map +1 -0
- package/dist/storage.test.d.ts +5 -0
- package/dist/storage.test.d.ts.map +1 -0
- package/dist/storage.test.js +434 -0
- package/dist/storage.test.js.map +1 -0
- package/dist/types.d.ts +270 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +12 -0
- package/dist/types.js.map +1 -0
- package/dist/types.test.d.ts +2 -0
- package/dist/types.test.d.ts.map +1 -0
- package/dist/types.test.js +232 -0
- package/dist/types.test.js.map +1 -0
- package/dist/watcher.d.ts +139 -0
- package/dist/watcher.d.ts.map +1 -0
- package/dist/watcher.js +406 -0
- package/dist/watcher.js.map +1 -0
- package/dist/watcher.test.d.ts +5 -0
- package/dist/watcher.test.d.ts.map +1 -0
- package/dist/watcher.test.js +327 -0
- package/dist/watcher.test.js.map +1 -0
- package/package.json +53 -0
package/dist/hash.js
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical YAML serialization and SHA-256 content hashing.
|
|
3
|
+
*
|
|
4
|
+
* All entities in prov are content-addressable via their hash.
|
|
5
|
+
* This module provides deterministic serialization and hashing.
|
|
6
|
+
*
|
|
7
|
+
* @see req:hashing
|
|
8
|
+
*/
|
|
9
|
+
import { createHash } from 'node:crypto';
|
|
10
|
+
import YAML from 'yaml';
|
|
11
|
+
/**
|
|
12
|
+
* Default fields to exclude from hash computation.
|
|
13
|
+
* These are computed/derived fields that shouldn't affect identity.
|
|
14
|
+
*/
|
|
15
|
+
const DEFAULT_EXCLUDE_FIELDS = ['hash', 'stale', 'status'];
|
|
16
|
+
/**
|
|
17
|
+
* Recursively sort object keys for deterministic serialization.
|
|
18
|
+
*/
|
|
19
|
+
function sortKeys(value) {
|
|
20
|
+
if (value === null || value === undefined) {
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
if (Array.isArray(value)) {
|
|
24
|
+
return value.map(sortKeys);
|
|
25
|
+
}
|
|
26
|
+
if (typeof value === 'object') {
|
|
27
|
+
const sorted = {};
|
|
28
|
+
const keys = Object.keys(value).sort();
|
|
29
|
+
for (const key of keys) {
|
|
30
|
+
sorted[key] = sortKeys(value[key]);
|
|
31
|
+
}
|
|
32
|
+
return sorted;
|
|
33
|
+
}
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Remove specified fields from an object (shallow copy).
|
|
38
|
+
*/
|
|
39
|
+
function excludeFields(obj, fields) {
|
|
40
|
+
const result = {};
|
|
41
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
42
|
+
if (!fields.includes(key)) {
|
|
43
|
+
result[key] = value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Serialize an object to canonical YAML format.
|
|
50
|
+
*
|
|
51
|
+
* Canonical format guarantees:
|
|
52
|
+
* - Keys are sorted alphabetically at all levels
|
|
53
|
+
* - Consistent whitespace (2-space indent, no trailing spaces)
|
|
54
|
+
* - No document markers (---)
|
|
55
|
+
* - Strings are quoted only when necessary
|
|
56
|
+
*
|
|
57
|
+
* @param value - The value to serialize
|
|
58
|
+
* @param options - Serialization options
|
|
59
|
+
* @returns Canonical YAML string
|
|
60
|
+
*/
|
|
61
|
+
export function serializeCanonical(value, options = {}) {
|
|
62
|
+
const { excludeFields: exclude = [] } = options;
|
|
63
|
+
// Remove excluded fields if value is an object
|
|
64
|
+
let processedValue = value;
|
|
65
|
+
if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
|
|
66
|
+
processedValue = excludeFields(value, [...DEFAULT_EXCLUDE_FIELDS, ...exclude]);
|
|
67
|
+
}
|
|
68
|
+
// Sort keys recursively for deterministic output
|
|
69
|
+
const sorted = sortKeys(processedValue);
|
|
70
|
+
// Serialize to YAML with consistent formatting
|
|
71
|
+
return YAML.stringify(sorted, {
|
|
72
|
+
indent: 2,
|
|
73
|
+
lineWidth: 0, // Don't wrap lines
|
|
74
|
+
minContentWidth: 0,
|
|
75
|
+
singleQuote: false,
|
|
76
|
+
}).trim();
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Compute SHA-256 hash of content.
|
|
80
|
+
*
|
|
81
|
+
* @param content - String content to hash
|
|
82
|
+
* @returns Full SHA-256 hash as hex string
|
|
83
|
+
*/
|
|
84
|
+
export function sha256(content) {
|
|
85
|
+
return createHash('sha256').update(content, 'utf8').digest('hex');
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Compute content hash for an entity.
|
|
89
|
+
*
|
|
90
|
+
* The hash is computed from the canonical YAML representation,
|
|
91
|
+
* excluding computed fields (hash, stale, status).
|
|
92
|
+
*
|
|
93
|
+
* @param entity - The entity to hash
|
|
94
|
+
* @param options - Serialization options
|
|
95
|
+
* @returns Hash in format `sha256:{first-12-hex-chars}`
|
|
96
|
+
*/
|
|
97
|
+
export function computeHash(entity, options = {}) {
|
|
98
|
+
const canonical = serializeCanonical(entity, options);
|
|
99
|
+
const fullHash = sha256(canonical);
|
|
100
|
+
// Use first 12 hex characters (48 bits) - enough for practical uniqueness
|
|
101
|
+
return `sha256:${fullHash.slice(0, 12)}`;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Verify that an entity's stored hash matches its computed hash.
|
|
105
|
+
*
|
|
106
|
+
* @param entity - The entity with a hash field
|
|
107
|
+
* @returns true if hash matches or no hash is stored, false if mismatch
|
|
108
|
+
*/
|
|
109
|
+
export function verifyHash(entity) {
|
|
110
|
+
if (entity.hash === undefined || entity.hash === null) {
|
|
111
|
+
return true; // No hash to verify
|
|
112
|
+
}
|
|
113
|
+
const computed = computeHash(entity);
|
|
114
|
+
return computed === entity.hash;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Parse YAML content to an object.
|
|
118
|
+
*
|
|
119
|
+
* @param content - YAML string to parse
|
|
120
|
+
* @returns Parsed object
|
|
121
|
+
*/
|
|
122
|
+
export function parseYaml(content) {
|
|
123
|
+
return YAML.parse(content);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Serialize an object to YAML (non-canonical, for human readability).
|
|
127
|
+
*
|
|
128
|
+
* @param value - The value to serialize
|
|
129
|
+
* @returns YAML string
|
|
130
|
+
*/
|
|
131
|
+
export function toYaml(value) {
|
|
132
|
+
return YAML.stringify(value, {
|
|
133
|
+
indent: 2,
|
|
134
|
+
lineWidth: 80,
|
|
135
|
+
}).trim();
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=hash.js.map
|
package/dist/hash.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.js","sourceRoot":"","sources":["../src/hash.ts"],"names":[],"mappings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G;AACH,MAAM,UAAU,UAAU,CAAC,MAAuB;IAChD,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;QACtD,OAAO,IAAI,CAAC,CAAC,oBAAoB;IACnC,CAAC;IAED,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;IACrC,OAAO,QAAQ,KAAK,MAAM,CAAC,IAAI,CAAC;AAClC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,SAAS,CAAc,OAAe;IACpD,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAM,CAAC;AAClC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,MAAM,CAAC,KAAc;IACnC,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE;QAC3B,MAAM,EAAE,CAAC;QACT,SAAS,EAAE,EAAE;KACd,CAAC,CAAC,IAAI,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.test.d.ts","sourceRoot":"","sources":["../src/hash.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { serializeCanonical, sha256, computeHash, verifyHash, parseYaml, toYaml, } from './hash.js';
|
|
3
|
+
describe('hash module', () => {
|
|
4
|
+
describe('serializeCanonical', () => {
|
|
5
|
+
it('sorts object keys alphabetically', () => {
|
|
6
|
+
const yaml = serializeCanonical({ zebra: 1, apple: 2, mango: 3 });
|
|
7
|
+
const lines = yaml.split('\n');
|
|
8
|
+
expect(lines[0]).toBe('apple: 2');
|
|
9
|
+
expect(lines[1]).toBe('mango: 3');
|
|
10
|
+
expect(lines[2]).toBe('zebra: 1');
|
|
11
|
+
});
|
|
12
|
+
it('sorts nested object keys', () => {
|
|
13
|
+
const yaml = serializeCanonical({
|
|
14
|
+
outer: { zebra: 1, apple: 2 },
|
|
15
|
+
});
|
|
16
|
+
expect(yaml).toContain('apple: 2');
|
|
17
|
+
expect(yaml.indexOf('apple')).toBeLessThan(yaml.indexOf('zebra'));
|
|
18
|
+
});
|
|
19
|
+
it('handles arrays preserving order', () => {
|
|
20
|
+
const yaml = serializeCanonical({ items: ['c', 'a', 'b'] });
|
|
21
|
+
// Arrays should maintain their order
|
|
22
|
+
expect(yaml).toBe('items:\n - c\n - a\n - b');
|
|
23
|
+
});
|
|
24
|
+
it('sorts keys within array objects', () => {
|
|
25
|
+
const yaml = serializeCanonical({
|
|
26
|
+
items: [{ z: 1, a: 2 }],
|
|
27
|
+
});
|
|
28
|
+
// Object keys within arrays should still be sorted
|
|
29
|
+
expect(yaml.indexOf('a: 2')).toBeLessThan(yaml.indexOf('z: 1'));
|
|
30
|
+
});
|
|
31
|
+
it('excludes default computed fields', () => {
|
|
32
|
+
const yaml = serializeCanonical({
|
|
33
|
+
id: 'test',
|
|
34
|
+
hash: 'sha256:should-be-excluded',
|
|
35
|
+
stale: true,
|
|
36
|
+
status: 'draft',
|
|
37
|
+
});
|
|
38
|
+
expect(yaml).not.toContain('hash');
|
|
39
|
+
expect(yaml).not.toContain('stale');
|
|
40
|
+
expect(yaml).not.toContain('status');
|
|
41
|
+
expect(yaml).toContain('id: test');
|
|
42
|
+
});
|
|
43
|
+
it('excludes custom fields when specified', () => {
|
|
44
|
+
const yaml = serializeCanonical({ id: 'test', custom: 'value', keep: 'this' }, { excludeFields: ['custom'] });
|
|
45
|
+
expect(yaml).not.toContain('custom');
|
|
46
|
+
expect(yaml).toContain('id: test');
|
|
47
|
+
expect(yaml).toContain('keep: this');
|
|
48
|
+
});
|
|
49
|
+
it('handles null and undefined values', () => {
|
|
50
|
+
const yaml = serializeCanonical({ a: null, b: undefined });
|
|
51
|
+
expect(yaml).toContain('a: null');
|
|
52
|
+
// undefined values are typically omitted in YAML
|
|
53
|
+
});
|
|
54
|
+
it('produces consistent output for same input', () => {
|
|
55
|
+
const obj = { b: 2, a: 1, c: { z: 26, y: 25 } };
|
|
56
|
+
const yaml1 = serializeCanonical(obj);
|
|
57
|
+
const yaml2 = serializeCanonical(obj);
|
|
58
|
+
expect(yaml1).toBe(yaml2);
|
|
59
|
+
});
|
|
60
|
+
it('produces same output regardless of input key order', () => {
|
|
61
|
+
const obj1 = { a: 1, b: 2, c: 3 };
|
|
62
|
+
const obj2 = { c: 3, a: 1, b: 2 };
|
|
63
|
+
const obj3 = { b: 2, c: 3, a: 1 };
|
|
64
|
+
const yaml1 = serializeCanonical(obj1);
|
|
65
|
+
const yaml2 = serializeCanonical(obj2);
|
|
66
|
+
const yaml3 = serializeCanonical(obj3);
|
|
67
|
+
expect(yaml1).toBe(yaml2);
|
|
68
|
+
expect(yaml2).toBe(yaml3);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
describe('sha256', () => {
|
|
72
|
+
it('computes correct SHA-256 hash', () => {
|
|
73
|
+
// Known test vector
|
|
74
|
+
const hash = sha256('hello');
|
|
75
|
+
expect(hash).toBe('2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824');
|
|
76
|
+
});
|
|
77
|
+
it('produces different hashes for different inputs', () => {
|
|
78
|
+
const hash1 = sha256('hello');
|
|
79
|
+
const hash2 = sha256('world');
|
|
80
|
+
expect(hash1).not.toBe(hash2);
|
|
81
|
+
});
|
|
82
|
+
it('produces same hash for same input', () => {
|
|
83
|
+
const hash1 = sha256('test input');
|
|
84
|
+
const hash2 = sha256('test input');
|
|
85
|
+
expect(hash1).toBe(hash2);
|
|
86
|
+
});
|
|
87
|
+
it('is sensitive to whitespace', () => {
|
|
88
|
+
const hash1 = sha256('hello');
|
|
89
|
+
const hash2 = sha256('hello ');
|
|
90
|
+
const hash3 = sha256(' hello');
|
|
91
|
+
expect(hash1).not.toBe(hash2);
|
|
92
|
+
expect(hash1).not.toBe(hash3);
|
|
93
|
+
expect(hash2).not.toBe(hash3);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
describe('computeHash', () => {
|
|
97
|
+
it('returns hash in sha256:{12-chars} format', () => {
|
|
98
|
+
const hash = computeHash({ id: 'test' });
|
|
99
|
+
expect(hash).toMatch(/^sha256:[a-f0-9]{12}$/);
|
|
100
|
+
});
|
|
101
|
+
it('produces consistent hash for same entity', () => {
|
|
102
|
+
const entity = { id: 'spec:test:v1', title: 'Test' };
|
|
103
|
+
const hash1 = computeHash(entity);
|
|
104
|
+
const hash2 = computeHash(entity);
|
|
105
|
+
expect(hash1).toBe(hash2);
|
|
106
|
+
});
|
|
107
|
+
it('produces same hash regardless of property order', () => {
|
|
108
|
+
const entity1 = { id: 'test', title: 'Test', version: '1.0' };
|
|
109
|
+
const entity2 = { version: '1.0', id: 'test', title: 'Test' };
|
|
110
|
+
expect(computeHash(entity1)).toBe(computeHash(entity2));
|
|
111
|
+
});
|
|
112
|
+
it('produces different hash for different content', () => {
|
|
113
|
+
const entity1 = { id: 'test', value: 1 };
|
|
114
|
+
const entity2 = { id: 'test', value: 2 };
|
|
115
|
+
expect(computeHash(entity1)).not.toBe(computeHash(entity2));
|
|
116
|
+
});
|
|
117
|
+
it('ignores hash field in computation', () => {
|
|
118
|
+
const entity = { id: 'test', hash: 'sha256:old-hash-val' };
|
|
119
|
+
const entityWithoutHash = { id: 'test' };
|
|
120
|
+
expect(computeHash(entity)).toBe(computeHash(entityWithoutHash));
|
|
121
|
+
});
|
|
122
|
+
it('ignores status field in computation', () => {
|
|
123
|
+
const entity1 = { id: 'test', title: 'Test' };
|
|
124
|
+
const entity2 = { id: 'test', title: 'Test', status: 'draft' };
|
|
125
|
+
const entity3 = { id: 'test', title: 'Test', status: 'active' };
|
|
126
|
+
expect(computeHash(entity1)).toBe(computeHash(entity2));
|
|
127
|
+
expect(computeHash(entity2)).toBe(computeHash(entity3));
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
describe('verifyHash', () => {
|
|
131
|
+
it('returns true when hash matches', () => {
|
|
132
|
+
const entity = { id: 'test', title: 'Test' };
|
|
133
|
+
const hash = computeHash(entity);
|
|
134
|
+
const entityWithHash = { ...entity, hash };
|
|
135
|
+
expect(verifyHash(entityWithHash)).toBe(true);
|
|
136
|
+
});
|
|
137
|
+
it('returns false when hash does not match', () => {
|
|
138
|
+
const entity = {
|
|
139
|
+
id: 'test',
|
|
140
|
+
title: 'Test',
|
|
141
|
+
hash: 'sha256:wrong-hash00',
|
|
142
|
+
};
|
|
143
|
+
expect(verifyHash(entity)).toBe(false);
|
|
144
|
+
});
|
|
145
|
+
it('returns true when no hash is present', () => {
|
|
146
|
+
const entity = {
|
|
147
|
+
id: 'test',
|
|
148
|
+
title: 'Test',
|
|
149
|
+
};
|
|
150
|
+
expect(verifyHash(entity)).toBe(true);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
describe('parseYaml and toYaml', () => {
|
|
154
|
+
it('round-trips objects correctly', () => {
|
|
155
|
+
const original = {
|
|
156
|
+
id: 'spec:test:v1',
|
|
157
|
+
title: 'Test Spec',
|
|
158
|
+
requirements: [{ id: 'req:test:1', description: 'First' }],
|
|
159
|
+
};
|
|
160
|
+
const yaml = toYaml(original);
|
|
161
|
+
const parsed = parseYaml(yaml);
|
|
162
|
+
expect(parsed).toEqual(original);
|
|
163
|
+
});
|
|
164
|
+
it('parses YAML strings', () => {
|
|
165
|
+
const yaml = `
|
|
166
|
+
id: spec:test:v1
|
|
167
|
+
title: Test
|
|
168
|
+
`.trim();
|
|
169
|
+
const parsed = parseYaml(yaml);
|
|
170
|
+
expect(parsed.id).toBe('spec:test:v1');
|
|
171
|
+
expect(parsed.title).toBe('Test');
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
describe('real-world entity hashing', () => {
|
|
175
|
+
it('computes stable hash for Spec entity', () => {
|
|
176
|
+
const spec = {
|
|
177
|
+
id: 'spec:core-model:v1',
|
|
178
|
+
version: '1.0.0',
|
|
179
|
+
title: 'Core Data Model',
|
|
180
|
+
status: 'draft',
|
|
181
|
+
intent: 'Define the fundamental entities',
|
|
182
|
+
requirements: [
|
|
183
|
+
{
|
|
184
|
+
id: 'req:core-model:entity-spec',
|
|
185
|
+
description: 'Specification entity represents declarative intent',
|
|
186
|
+
acceptance: ['Specs have a unique id'],
|
|
187
|
+
},
|
|
188
|
+
],
|
|
189
|
+
};
|
|
190
|
+
const hash1 = computeHash(spec);
|
|
191
|
+
const hash2 = computeHash(spec);
|
|
192
|
+
expect(hash1).toBe(hash2);
|
|
193
|
+
expect(hash1).toMatch(/^sha256:[a-f0-9]{12}$/);
|
|
194
|
+
});
|
|
195
|
+
it('detects changes in Spec content', () => {
|
|
196
|
+
const spec1 = {
|
|
197
|
+
id: 'spec:test:v1',
|
|
198
|
+
version: '1.0.0',
|
|
199
|
+
title: 'Original',
|
|
200
|
+
status: 'draft',
|
|
201
|
+
intent: 'Original intent',
|
|
202
|
+
requirements: [],
|
|
203
|
+
};
|
|
204
|
+
const spec2 = {
|
|
205
|
+
...spec1,
|
|
206
|
+
title: 'Modified',
|
|
207
|
+
};
|
|
208
|
+
expect(computeHash(spec1)).not.toBe(computeHash(spec2));
|
|
209
|
+
});
|
|
210
|
+
it('ignores status changes for hash computation', () => {
|
|
211
|
+
const specDraft = {
|
|
212
|
+
id: 'spec:test:v1',
|
|
213
|
+
version: '1.0.0',
|
|
214
|
+
title: 'Test',
|
|
215
|
+
status: 'draft',
|
|
216
|
+
intent: 'Test intent',
|
|
217
|
+
requirements: [],
|
|
218
|
+
};
|
|
219
|
+
const specActive = {
|
|
220
|
+
...specDraft,
|
|
221
|
+
status: 'active',
|
|
222
|
+
};
|
|
223
|
+
expect(computeHash(specDraft)).toBe(computeHash(specActive));
|
|
224
|
+
});
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
//# sourceMappingURL=hash.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash.test.js","sourceRoot":"","sources":["../src/hash.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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|
|
|
1
|
+
/**
|
|
2
|
+
* prov - Provenance-first planning CLI for AI agent workflows
|
|
3
|
+
*
|
|
4
|
+
* This module exports the core prov API for programmatic usage.
|
|
5
|
+
*/
|
|
6
|
+
export declare const VERSION = "0.1.0";
|
|
7
|
+
export type { Hash, Timestamp, EntityId, EntityStatus, SpecId, RequirementId, ConstraintId, InvariantId, PlanId, DecisionId, StepId, TraceId, AcceptanceCriterion, Requirement, Spec, VerificationMethod, Invariant, Constraint, Decision, Step, SourceReference, Plan, FileLocation, Trace, NodeType, EdgeType, GraphNode, GraphEdge, } from './types.js';
|
|
8
|
+
export { serializeCanonical, sha256, computeHash, verifyHash, parseYaml, toYaml, type SerializeOptions, } from './hash.js';
|
|
9
|
+
export { IntentGraph, addSpecToGraph, addConstraintToGraph, addPlanToGraph, addTraceToGraph, type EntityData, type TraversalOptions, type ValidationResult, } from './graph.js';
|
|
10
|
+
export { PROV_DIR, GRAPH_FILE, MAPPINGS_DIR, CACHE_DIR, SCHEMA_VERSION, getProvDir, getGraphPath, getMappingsDir, getCacheDir, getMappingPath, isInitialized, initialize, acquireLock, releaseLock, withLock, atomicWrite, saveGraph, loadGraph, saveMapping, loadMapping, deleteMapping, listMappings, getCachedHash, setCachedHash, clearCache, Storage, type GraphFile, type SerializedNode, type SerializedEdge, type LineMapping, type FileMapping, type StorageOptions, type StorageResult, } from './storage.js';
|
|
11
|
+
export { getFileType, extractEntityId, computeFileHash, hasFileChanged, getTrackedFiles, scanForChanges, updateHashes, getStaleEntities, FileWatcher, type TrackedFileType, type TrackedFile, type ChangeResult, type WatcherEvents, type WatcherOptions, } from './watcher.js';
|
|
12
|
+
export { computeArtifactHash, checkPlanStaleness, checkTraceStaleness, findTransitivelyStale, detectStaleness, isNodeStale, getStaleNodes, getStalePlans, getStaleTraces, formatStalenessReason, type StalenessReason, type StalenessInfo, type StalenessResult, type StalenessOptions, } from './staleness.js';
|
|
13
|
+
/**
|
|
14
|
+
* Placeholder for core prov functionality.
|
|
15
|
+
* Will be implemented in subsequent steps.
|
|
16
|
+
*/
|
|
17
|
+
export declare function getVersion(): string;
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,OAAO,UAAU,CAAC;AAG/B,YAAY,EAEV,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,YAAY,EAEZ,MAAM,EACN,aAAa,EACb,YAAY,EACZ,WAAW,EACX,MAAM,EACN,UAAU,EACV,MAAM,EACN,OAAO,EAEP,mBAAmB,EACnB,WAAW,EACX,IAAI,EAEJ,kBAAkB,EAClB,SAAS,EACT,UAAU,EAEV,QAAQ,EACR,IAAI,EACJ,eAAe,EACf,IAAI,EAEJ,YAAY,EACZ,KAAK,EAEL,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,SAAS,GACV,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,WAAW,EACX,UAAU,EACV,SAAS,EACT,MAAM,EACN,KAAK,gBAAgB,GACtB,MAAM,WAAW,CAAC;AAGnB,OAAO,EACL,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,GACtB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAEL,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,SAAS,EACT,cAAc,EAEd,UAAU,EACV,YAAY,EACZ,cAAc,EACd,WAAW,EACX,cAAc,EAEd,aAAa,EACb,UAAU,EAEV,WAAW,EACX,WAAW,EACX,QAAQ,EAER,WAAW,EAEX,SAAS,EACT,SAAS,EAET,WAAW,EACX,WAAW,EACX,aAAa,EACb,YAAY,EAEZ,aAAa,EACb,aAAa,EACb,UAAU,EAEV,OAAO,EAEP,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,cAAc,EACnB,KAAK,aAAa,GACnB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAEL,WAAW,EACX,eAAe,EAEf,eAAe,EACf,cAAc,EAEd,eAAe,EACf,cAAc,EACd,YAAY,EAEZ,gBAAgB,EAEhB,WAAW,EAEX,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,cAAc,GACpB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAEL,mBAAmB,EAEnB,kBAAkB,EAClB,mBAAmB,EAEnB,qBAAqB,EAErB,eAAe,EAEf,WAAW,EACX,aAAa,EACb,aAAa,EACb,cAAc,EAEd,qBAAqB,EAErB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,gBAAgB,CAAC;AAExB;;;GAGG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAEnC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* prov - Provenance-first planning CLI for AI agent workflows
|
|
3
|
+
*
|
|
4
|
+
* This module exports the core prov API for programmatic usage.
|
|
5
|
+
*/
|
|
6
|
+
export const VERSION = '0.1.0';
|
|
7
|
+
// Hash and serialization utilities
|
|
8
|
+
export { serializeCanonical, sha256, computeHash, verifyHash, parseYaml, toYaml, } from './hash.js';
|
|
9
|
+
// Intent graph
|
|
10
|
+
export { IntentGraph, addSpecToGraph, addConstraintToGraph, addPlanToGraph, addTraceToGraph, } from './graph.js';
|
|
11
|
+
// Storage layer
|
|
12
|
+
export {
|
|
13
|
+
// Constants
|
|
14
|
+
PROV_DIR, GRAPH_FILE, MAPPINGS_DIR, CACHE_DIR, SCHEMA_VERSION,
|
|
15
|
+
// Path utilities
|
|
16
|
+
getProvDir, getGraphPath, getMappingsDir, getCacheDir, getMappingPath,
|
|
17
|
+
// Directory management
|
|
18
|
+
isInitialized, initialize,
|
|
19
|
+
// Lock management
|
|
20
|
+
acquireLock, releaseLock, withLock,
|
|
21
|
+
// Atomic write
|
|
22
|
+
atomicWrite,
|
|
23
|
+
// Graph persistence
|
|
24
|
+
saveGraph, loadGraph,
|
|
25
|
+
// Mapping persistence
|
|
26
|
+
saveMapping, loadMapping, deleteMapping, listMappings,
|
|
27
|
+
// Cache management
|
|
28
|
+
getCachedHash, setCachedHash, clearCache,
|
|
29
|
+
// High-level interface
|
|
30
|
+
Storage, } from './storage.js';
|
|
31
|
+
// File watching and change detection
|
|
32
|
+
export {
|
|
33
|
+
// File type detection
|
|
34
|
+
getFileType, extractEntityId,
|
|
35
|
+
// Hash utilities
|
|
36
|
+
computeFileHash, hasFileChanged,
|
|
37
|
+
// File scanning
|
|
38
|
+
getTrackedFiles, scanForChanges, updateHashes,
|
|
39
|
+
// Staleness detection
|
|
40
|
+
getStaleEntities,
|
|
41
|
+
// Watch mode
|
|
42
|
+
FileWatcher, } from './watcher.js';
|
|
43
|
+
// Staleness detection
|
|
44
|
+
export {
|
|
45
|
+
// File hash utilities
|
|
46
|
+
computeArtifactHash,
|
|
47
|
+
// Direct staleness checks
|
|
48
|
+
checkPlanStaleness, checkTraceStaleness,
|
|
49
|
+
// Transitive staleness
|
|
50
|
+
findTransitivelyStale,
|
|
51
|
+
// Full graph detection
|
|
52
|
+
detectStaleness,
|
|
53
|
+
// Convenience functions
|
|
54
|
+
isNodeStale, getStaleNodes, getStalePlans, getStaleTraces,
|
|
55
|
+
// Formatting
|
|
56
|
+
formatStalenessReason, } from './staleness.js';
|
|
57
|
+
/**
|
|
58
|
+
* Placeholder for core prov functionality.
|
|
59
|
+
* Will be implemented in subsequent steps.
|
|
60
|
+
*/
|
|
61
|
+
export function getVersion() {
|
|
62
|
+
return VERSION;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC;AAyC/B,mCAAmC;AACnC,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,WAAW,EACX,UAAU,EACV,SAAS,EACT,MAAM,GAEP,MAAM,WAAW,CAAC;AAEnB,eAAe;AACf,OAAO,EACL,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,cAAc,EACd,eAAe,GAIhB,MAAM,YAAY,CAAC;AAEpB,gBAAgB;AAChB,OAAO;AACL,YAAY;AACZ,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,SAAS,EACT,cAAc;AACd,iBAAiB;AACjB,UAAU,EACV,YAAY,EACZ,cAAc,EACd,WAAW,EACX,cAAc;AACd,uBAAuB;AACvB,aAAa,EACb,UAAU;AACV,kBAAkB;AAClB,WAAW,EACX,WAAW,EACX,QAAQ;AACR,eAAe;AACf,WAAW;AACX,oBAAoB;AACpB,SAAS,EACT,SAAS;AACT,sBAAsB;AACtB,WAAW,EACX,WAAW,EACX,aAAa,EACb,YAAY;AACZ,mBAAmB;AACnB,aAAa,EACb,aAAa,EACb,UAAU;AACV,uBAAuB;AACvB,OAAO,GASR,MAAM,cAAc,CAAC;AAEtB,qCAAqC;AACrC,OAAO;AACL,sBAAsB;AACtB,WAAW,EACX,eAAe;AACf,iBAAiB;AACjB,eAAe,EACf,cAAc;AACd,gBAAgB;AAChB,eAAe,EACf,cAAc,EACd,YAAY;AACZ,sBAAsB;AACtB,gBAAgB;AAChB,aAAa;AACb,WAAW,GAOZ,MAAM,cAAc,CAAC;AAEtB,sBAAsB;AACtB,OAAO;AACL,sBAAsB;AACtB,mBAAmB;AACnB,0BAA0B;AAC1B,kBAAkB,EAClB,mBAAmB;AACnB,uBAAuB;AACvB,qBAAqB;AACrB,uBAAuB;AACvB,eAAe;AACf,wBAAwB;AACxB,WAAW,EACX,aAAa,EACb,aAAa,EACb,cAAc;AACd,aAAa;AACb,qBAAqB,GAMtB,MAAM,gBAAgB,CAAC;AAExB;;;GAGG;AACH,MAAM,UAAU,UAAU;IACxB,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { getVersion, VERSION } from './index.js';
|
|
3
|
+
describe('prov core', () => {
|
|
4
|
+
it('exports VERSION constant', () => {
|
|
5
|
+
expect(VERSION).toBe('0.1.0');
|
|
6
|
+
});
|
|
7
|
+
it('getVersion returns the version string', () => {
|
|
8
|
+
expect(getVersion()).toBe('0.1.0');
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=index.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEjD,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,EAAE,CAAC,0BAA0B,EAAE,GAAG,EAAE;QAClC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC/C,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/output.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output formatting utilities for CLI commands.
|
|
3
|
+
*
|
|
4
|
+
* Supports multiple output formats:
|
|
5
|
+
* - table: Human-readable columnar format (default for TTY)
|
|
6
|
+
* - yaml: YAML format (default for pipes)
|
|
7
|
+
* - json: Machine-parseable JSON format
|
|
8
|
+
*
|
|
9
|
+
* @see req:cli:output-formats
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Supported output format types.
|
|
13
|
+
*/
|
|
14
|
+
export type OutputFormat = 'table' | 'yaml' | 'json';
|
|
15
|
+
/**
|
|
16
|
+
* Column definition for table output.
|
|
17
|
+
*/
|
|
18
|
+
export interface TableColumn {
|
|
19
|
+
/** Column header text */
|
|
20
|
+
header: string;
|
|
21
|
+
/** Key to extract from row data */
|
|
22
|
+
key: string;
|
|
23
|
+
/** Minimum width (defaults to header length) */
|
|
24
|
+
minWidth?: number;
|
|
25
|
+
/** Maximum width (truncates with ellipsis) */
|
|
26
|
+
maxWidth?: number;
|
|
27
|
+
/** Alignment: left, right, center (defaults to left) */
|
|
28
|
+
align?: 'left' | 'right' | 'center';
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Options for output formatting.
|
|
32
|
+
*/
|
|
33
|
+
export interface OutputOptions {
|
|
34
|
+
/** Output format to use */
|
|
35
|
+
format?: OutputFormat | undefined;
|
|
36
|
+
/** Whether output is to a TTY (auto-detected if not specified) */
|
|
37
|
+
isTty?: boolean | undefined;
|
|
38
|
+
/** Custom table columns (for table format) */
|
|
39
|
+
columns?: TableColumn[] | undefined;
|
|
40
|
+
/** Whether to include headers in table output */
|
|
41
|
+
headers?: boolean | undefined;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Detect the default output format based on environment.
|
|
45
|
+
* Returns 'table' for TTY, 'yaml' for pipes/redirects.
|
|
46
|
+
*/
|
|
47
|
+
export declare function detectFormat(isTty?: boolean): OutputFormat;
|
|
48
|
+
/**
|
|
49
|
+
* Resolve the format to use, considering explicit format and TTY detection.
|
|
50
|
+
*/
|
|
51
|
+
export declare function resolveFormat(options?: OutputOptions): OutputFormat;
|
|
52
|
+
/**
|
|
53
|
+
* Format data as a table.
|
|
54
|
+
*/
|
|
55
|
+
export declare function formatTable(data: readonly Record<string, unknown>[], columns: TableColumn[], includeHeaders?: boolean): string;
|
|
56
|
+
/**
|
|
57
|
+
* Format data as YAML.
|
|
58
|
+
*/
|
|
59
|
+
export declare function formatYaml(data: unknown): string;
|
|
60
|
+
/**
|
|
61
|
+
* Format data as JSON.
|
|
62
|
+
*/
|
|
63
|
+
export declare function formatJson(data: unknown): string;
|
|
64
|
+
/**
|
|
65
|
+
* Format data in the specified format.
|
|
66
|
+
*/
|
|
67
|
+
export declare function format(data: unknown, options?: OutputOptions): string;
|
|
68
|
+
/**
|
|
69
|
+
* Output data to stdout in the specified format.
|
|
70
|
+
*/
|
|
71
|
+
export declare function output(data: unknown, options?: OutputOptions): void;
|
|
72
|
+
/**
|
|
73
|
+
* Output an error message to stderr.
|
|
74
|
+
*/
|
|
75
|
+
export declare function error(message: string): void;
|
|
76
|
+
/**
|
|
77
|
+
* Output a success message to stdout.
|
|
78
|
+
*/
|
|
79
|
+
export declare function success(message: string): void;
|
|
80
|
+
/**
|
|
81
|
+
* Output a warning message to stderr.
|
|
82
|
+
*/
|
|
83
|
+
export declare function warn(message: string): void;
|
|
84
|
+
//# sourceMappingURL=output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../src/output.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,yBAAyB;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,gDAAgD;IAChD,QAAQ,CAAC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