knodin 0.8.4 → 0.8.6

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.
Files changed (34) hide show
  1. package/dist/bin/cli.js +272 -24
  2. package/dist/src/cli-model.js +26 -0
  3. package/dist/src/engine/candidate-database.js +167 -0
  4. package/dist/src/engine/embeddings.js +8 -5
  5. package/dist/src/engine/index.js +1244 -305
  6. package/dist/src/engine/prune.js +8 -0
  7. package/dist/src/file-metrics.js +153 -0
  8. package/dist/src/repair-lease.js +8 -5
  9. package/dist/src/response-budget.js +2 -1
  10. package/dist/src/shared-index/artifact.js +65 -0
  11. package/dist/src/shared-index/cache.js +267 -0
  12. package/dist/src/shared-index/compatibility.js +70 -0
  13. package/dist/src/shared-index/config.js +224 -0
  14. package/dist/src/shared-index/contract.js +117 -0
  15. package/dist/src/shared-index/manifest.js +71 -0
  16. package/dist/src/shared-index/opportunistic.js +37 -0
  17. package/dist/src/shared-index/overlay.js +98 -0
  18. package/dist/src/shared-index/provenance.js +149 -0
  19. package/dist/src/shared-index/publisher.js +198 -0
  20. package/dist/src/shared-index/restore.js +209 -0
  21. package/dist/src/shared-index/s3-client.js +124 -0
  22. package/dist/src/shared-index/schemas.js +86 -0
  23. package/dist/src/shared-index/selection.js +111 -0
  24. package/dist/src/tools/knodin-tools.js +70 -3
  25. package/docs/CLI.md +39 -0
  26. package/docs/MCP.md +12 -0
  27. package/docs/SHARED-INDEX-CONTRACT.md +132 -0
  28. package/docs/releases/0.8.5.md +25 -0
  29. package/docs/releases/0.8.6.md +10 -0
  30. package/package.json +12 -3
  31. package/schemas/shared-index-branch-pointer-v1.schema.json +66 -0
  32. package/schemas/shared-index-config-v1.schema.json +97 -0
  33. package/schemas/shared-index-manifest-v1.schema.json +104 -0
  34. package/schemas/shared-index-provenance-v1.schema.json +100 -0
@@ -0,0 +1,66 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://knodin.dev/schemas/shared-index-branch-pointer-v1.schema.json",
4
+ "title": "Knodin shared-index branch discovery pointer v1",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "schemaVersion",
9
+ "registrationId",
10
+ "repository",
11
+ "branch",
12
+ "commit",
13
+ "inputFingerprint",
14
+ "manifestKey",
15
+ "manifestSha256",
16
+ "updatedAt"
17
+ ],
18
+ "properties": {
19
+ "schemaVersion": { "const": 1 },
20
+ "registrationId": { "$ref": "#/$defs/registrationId" },
21
+ "repository": { "$ref": "#/$defs/repository" },
22
+ "branch": { "type": "string", "minLength": 1, "maxLength": 1024 },
23
+ "commit": { "$ref": "#/$defs/gitObject" },
24
+ "inputFingerprint": { "$ref": "#/$defs/sha256" },
25
+ "manifestKey": {
26
+ "type": "string",
27
+ "minLength": 1,
28
+ "maxLength": 2048,
29
+ "pattern": "^v1/[^/]+/[^/]+/[^/]+/snapshots/[a-f0-9]{40,64}/[a-f0-9]{64}/manifest\\.json$"
30
+ },
31
+ "manifestSha256": { "$ref": "#/$defs/sha256" },
32
+ "updatedAt": {
33
+ "type": "string",
34
+ "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,9})?Z$"
35
+ }
36
+ },
37
+ "$defs": {
38
+ "registrationId": { "type": "string", "pattern": "^[a-z0-9][a-z0-9._-]{0,127}$" },
39
+ "sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
40
+ "gitObject": { "type": "string", "pattern": "^[a-f0-9]{40,64}$" },
41
+ "repository": {
42
+ "type": "object",
43
+ "additionalProperties": false,
44
+ "required": ["host", "owner", "name"],
45
+ "properties": {
46
+ "host": {
47
+ "type": "string",
48
+ "pattern": "^(?!.*\\.\\.)(?!.*(?:^|\\.)-)(?!.*-(?:\\.|$))[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?$",
49
+ "maxLength": 253
50
+ },
51
+ "owner": {
52
+ "type": "string",
53
+ "minLength": 1,
54
+ "maxLength": 255,
55
+ "pattern": "^[a-z0-9](?:[a-z0-9-]{0,253}[a-z0-9])?$"
56
+ },
57
+ "name": {
58
+ "type": "string",
59
+ "minLength": 1,
60
+ "maxLength": 255,
61
+ "pattern": "^[a-z0-9](?:[a-z0-9._-]{0,253}[a-z0-9])?$"
62
+ }
63
+ }
64
+ }
65
+ }
66
+ }
@@ -0,0 +1,97 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://knodin.dev/schemas/shared-index-config-v1.schema.json",
4
+ "title": "Knodin shared-index repository configuration v1",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "schemaVersion",
9
+ "enabled",
10
+ "registrationId",
11
+ "aws",
12
+ "repository",
13
+ "branches",
14
+ "signing"
15
+ ],
16
+ "properties": {
17
+ "schemaVersion": { "const": 1 },
18
+ "enabled": { "type": "boolean" },
19
+ "registrationId": { "$ref": "#/$defs/registrationId" },
20
+ "aws": {
21
+ "type": "object",
22
+ "additionalProperties": false,
23
+ "required": ["region", "bucket"],
24
+ "properties": {
25
+ "region": {
26
+ "type": "string",
27
+ "pattern": "^[a-z]{2}(?:-gov)?-[a-z]+-\\d$",
28
+ "maxLength": 32
29
+ },
30
+ "bucket": {
31
+ "type": "string",
32
+ "pattern": "^(?!xn--)(?!.*\\.\\.)(?!.*\\.-)(?!.*-\\.)(?!\\d{1,3}(?:\\.\\d{1,3}){3}$)[a-z0-9][a-z0-9.-]{1,61}[a-z0-9]$"
33
+ }
34
+ }
35
+ },
36
+ "repository": { "$ref": "#/$defs/repository" },
37
+ "branches": {
38
+ "type": "array",
39
+ "minItems": 1,
40
+ "maxItems": 64,
41
+ "uniqueItems": true,
42
+ "items": {
43
+ "type": "string",
44
+ "minLength": 1,
45
+ "maxLength": 255,
46
+ "pattern": "^(?!/)(?!.*//)(?!.*\\.\\.)(?!.*@\\{)(?!.*[~^:?\\[\\\\])[^*]+(?:/\\*)?$"
47
+ }
48
+ },
49
+ "signing": {
50
+ "type": "object",
51
+ "additionalProperties": false,
52
+ "required": ["algorithm", "keyId", "publicKeySha256", "publicKeyPem"],
53
+ "properties": {
54
+ "algorithm": { "const": "RSASSA_PSS_SHA_256" },
55
+ "keyId": {
56
+ "type": "string",
57
+ "maxLength": 2048,
58
+ "pattern": "^(?:arn:(?:aws|aws-us-gov|aws-cn):kms:[a-z0-9-]+:\\d{12}:(?:key/[A-Za-z0-9-]+|alias/[A-Za-z0-9/_+=,.@-]+)|alias/[A-Za-z0-9/_+=,.@-]+)$"
59
+ },
60
+ "publicKeySha256": { "$ref": "#/$defs/sha256" },
61
+ "publicKeyPem": {
62
+ "type": "string",
63
+ "pattern": "^-----BEGIN PUBLIC KEY-----\\n(?:[A-Za-z0-9+/=]+\\n)+-----END PUBLIC KEY-----\\n?$",
64
+ "maxLength": 16384
65
+ }
66
+ }
67
+ }
68
+ },
69
+ "$defs": {
70
+ "registrationId": { "type": "string", "pattern": "^[a-z0-9][a-z0-9._-]{0,127}$" },
71
+ "sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
72
+ "repository": {
73
+ "type": "object",
74
+ "additionalProperties": false,
75
+ "required": ["host", "owner", "name"],
76
+ "properties": {
77
+ "host": {
78
+ "type": "string",
79
+ "pattern": "^(?!.*\\.\\.)(?!.*(?:^|\\.)-)(?!.*-(?:\\.|$))[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?$",
80
+ "maxLength": 253
81
+ },
82
+ "owner": {
83
+ "type": "string",
84
+ "minLength": 1,
85
+ "maxLength": 255,
86
+ "pattern": "^[a-z0-9](?:[a-z0-9-]{0,253}[a-z0-9])?$"
87
+ },
88
+ "name": {
89
+ "type": "string",
90
+ "minLength": 1,
91
+ "maxLength": 255,
92
+ "pattern": "^[a-z0-9](?:[a-z0-9._-]{0,253}[a-z0-9])?$"
93
+ }
94
+ }
95
+ }
96
+ }
97
+ }
@@ -0,0 +1,104 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://knodin.dev/schemas/shared-index-manifest-v1.schema.json",
4
+ "title": "Knodin immutable shared-index manifest v1",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "schemaVersion",
9
+ "registrationId",
10
+ "repository",
11
+ "commit",
12
+ "generatedAt",
13
+ "compatibility",
14
+ "graph"
15
+ ],
16
+ "properties": {
17
+ "schemaVersion": { "const": 1 },
18
+ "registrationId": { "$ref": "#/$defs/registrationId" },
19
+ "repository": { "$ref": "#/$defs/repository" },
20
+ "commit": { "$ref": "#/$defs/gitObject" },
21
+ "generatedAt": {
22
+ "type": "string",
23
+ "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,9})?Z$"
24
+ },
25
+ "compatibility": {
26
+ "type": "object",
27
+ "additionalProperties": false,
28
+ "required": [
29
+ "knodinVersion",
30
+ "databaseSchemaVersion",
31
+ "modelId",
32
+ "modelDigest",
33
+ "parserBundleDigest",
34
+ "indexConfigDigest",
35
+ "prunePolicyDigest"
36
+ ],
37
+ "properties": {
38
+ "knodinVersion": {
39
+ "type": "string",
40
+ "pattern": "^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?$",
41
+ "maxLength": 128
42
+ },
43
+ "databaseSchemaVersion": { "type": "integer", "minimum": 1, "maximum": 2147483647 },
44
+ "modelId": { "type": "string", "minLength": 1, "maxLength": 512 },
45
+ "modelDigest": { "$ref": "#/$defs/sha256" },
46
+ "parserBundleDigest": { "$ref": "#/$defs/sha256" },
47
+ "indexConfigDigest": { "$ref": "#/$defs/sha256" },
48
+ "prunePolicyDigest": { "$ref": "#/$defs/sha256" }
49
+ }
50
+ },
51
+ "graph": {
52
+ "type": "object",
53
+ "additionalProperties": false,
54
+ "required": [
55
+ "key",
56
+ "compressedSha256",
57
+ "compressedBytes",
58
+ "uncompressedSha256",
59
+ "uncompressedBytes"
60
+ ],
61
+ "properties": {
62
+ "key": {
63
+ "type": "string",
64
+ "minLength": 1,
65
+ "maxLength": 2048,
66
+ "pattern": "^v1/[^/]+/[^/]+/[^/]+/snapshots/[a-f0-9]{40,64}/[a-f0-9]{64}/graph\\.sqlite\\.zst$"
67
+ },
68
+ "compressedSha256": { "$ref": "#/$defs/sha256" },
69
+ "compressedBytes": { "type": "integer", "minimum": 1, "maximum": 8589934592 },
70
+ "uncompressedSha256": { "$ref": "#/$defs/sha256" },
71
+ "uncompressedBytes": { "type": "integer", "minimum": 1, "maximum": 34359738368 }
72
+ }
73
+ }
74
+ },
75
+ "$defs": {
76
+ "registrationId": { "type": "string", "pattern": "^[a-z0-9][a-z0-9._-]{0,127}$" },
77
+ "sha256": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
78
+ "gitObject": { "type": "string", "pattern": "^[a-f0-9]{40,64}$" },
79
+ "repository": {
80
+ "type": "object",
81
+ "additionalProperties": false,
82
+ "required": ["host", "owner", "name"],
83
+ "properties": {
84
+ "host": {
85
+ "type": "string",
86
+ "pattern": "^(?!.*\\.\\.)(?!.*(?:^|\\.)-)(?!.*-(?:\\.|$))[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?$",
87
+ "maxLength": 253
88
+ },
89
+ "owner": {
90
+ "type": "string",
91
+ "minLength": 1,
92
+ "maxLength": 255,
93
+ "pattern": "^[a-z0-9](?:[a-z0-9-]{0,253}[a-z0-9])?$"
94
+ },
95
+ "name": {
96
+ "type": "string",
97
+ "minLength": 1,
98
+ "maxLength": 255,
99
+ "pattern": "^[a-z0-9](?:[a-z0-9._-]{0,253}[a-z0-9])?$"
100
+ }
101
+ }
102
+ }
103
+ }
104
+ }
@@ -0,0 +1,100 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://knodin.dev/schemas/shared-index-provenance-v1.schema.json",
4
+ "title": "Knodin shared-index CLI and MCP provenance v1",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": ["schemaVersion", "enabled", "state", "source"],
8
+ "properties": {
9
+ "schemaVersion": { "const": 1 },
10
+ "enabled": { "type": "boolean" },
11
+ "state": {
12
+ "enum": [
13
+ "disabled",
14
+ "not-configured",
15
+ "configuration-invalid",
16
+ "local-only",
17
+ "restore-pending",
18
+ "restored-and-verified",
19
+ "restore-failed"
20
+ ]
21
+ },
22
+ "registrationId": { "type": "string", "pattern": "^[a-z0-9][a-z0-9._-]{0,127}$" },
23
+ "baseCommit": { "type": "string", "pattern": "^[a-f0-9]{40,64}$" },
24
+ "manifestDigest": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
25
+ "source": { "enum": ["local-index", "shared-snapshot"] },
26
+ "cache": { "enum": ["not-used", "downloaded", "hit", "unavailable", "corrupt-refetched"] },
27
+ "overlay": {
28
+ "type": "object",
29
+ "additionalProperties": false,
30
+ "required": [
31
+ "committedPaths",
32
+ "stagedPaths",
33
+ "workingTreePaths",
34
+ "deletedPaths",
35
+ "untrackedPaths"
36
+ ],
37
+ "properties": {
38
+ "committedPaths": { "$ref": "#/$defs/count" },
39
+ "stagedPaths": { "$ref": "#/$defs/count" },
40
+ "workingTreePaths": { "$ref": "#/$defs/count" },
41
+ "deletedPaths": { "$ref": "#/$defs/count" },
42
+ "untrackedPaths": { "$ref": "#/$defs/count" }
43
+ }
44
+ },
45
+ "failureCategory": {
46
+ "enum": [
47
+ "authentication",
48
+ "authorization",
49
+ "not-found",
50
+ "timeout",
51
+ "integrity",
52
+ "compatibility",
53
+ "configuration",
54
+ "unavailable"
55
+ ]
56
+ },
57
+ "effectiveTreeFingerprint": {
58
+ "type": "string",
59
+ "pattern": "^[a-f0-9]{64}$"
60
+ },
61
+ "restoredAt": {
62
+ "type": "string",
63
+ "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d{1,9})?Z$"
64
+ }
65
+ },
66
+ "$defs": { "count": { "type": "integer", "minimum": 0, "maximum": 2147483647 } },
67
+ "allOf": [
68
+ {
69
+ "if": {
70
+ "properties": { "state": { "const": "restored-and-verified" } },
71
+ "required": ["state"]
72
+ },
73
+ "then": {
74
+ "required": [
75
+ "registrationId",
76
+ "baseCommit",
77
+ "manifestDigest",
78
+ "cache",
79
+ "overlay",
80
+ "effectiveTreeFingerprint",
81
+ "restoredAt"
82
+ ],
83
+ "properties": {
84
+ "registrationId": {},
85
+ "baseCommit": {},
86
+ "manifestDigest": {},
87
+ "cache": {},
88
+ "overlay": {},
89
+ "effectiveTreeFingerprint": {},
90
+ "restoredAt": {},
91
+ "source": { "const": "shared-snapshot" }
92
+ }
93
+ }
94
+ },
95
+ {
96
+ "if": { "properties": { "state": { "const": "restore-failed" } }, "required": ["state"] },
97
+ "then": { "required": ["failureCategory"], "properties": { "failureCategory": {} } }
98
+ }
99
+ ]
100
+ }