@lucern/contracts 0.3.0-alpha.17 → 0.3.0-alpha.2
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/CHANGELOG.md +0 -10
- package/dist/api-enums.contract.d.ts +3 -5
- package/dist/api-enums.contract.js +12 -14
- package/dist/api-enums.contract.js.map +1 -1
- package/dist/auth-context.contract.js +2 -14
- package/dist/auth-context.contract.js.map +1 -1
- package/dist/auth-session.contract.js +2 -14
- package/dist/auth-session.contract.js.map +1 -1
- package/dist/auth.contract.d.ts +1 -1
- package/dist/auth.contract.js +2 -14
- package/dist/auth.contract.js.map +1 -1
- package/dist/context-pack.contract.d.ts +3 -5
- package/dist/context-pack.contract.js.map +1 -1
- package/dist/{defineTable-t1wr5wgn.d.ts → defineTable-CBQ03FXl.d.ts} +1 -1
- package/dist/{dsl-DVPthQGY.d.ts → dsl-BgpoVOVQ.d.ts} +2 -2
- package/dist/dsl.d.ts +2 -2
- package/dist/dsl.js +4 -1
- package/dist/dsl.js.map +1 -1
- package/dist/function-registry/beliefs.d.ts +51 -64
- package/dist/function-registry/beliefs.js +57 -817
- package/dist/function-registry/beliefs.js.map +1 -1
- package/dist/function-registry/coding.d.ts +6 -15
- package/dist/function-registry/coding.js +43 -866
- package/dist/function-registry/coding.js.map +1 -1
- package/dist/function-registry/context.d.ts +16 -22
- package/dist/function-registry/context.js +46 -805
- package/dist/function-registry/context.js.map +1 -1
- package/dist/function-registry/contracts.d.ts +3 -9
- package/dist/function-registry/contracts.js +39 -770
- package/dist/function-registry/contracts.js.map +1 -1
- package/dist/function-registry/coordination.d.ts +9 -21
- package/dist/function-registry/coordination.js +39 -770
- package/dist/function-registry/coordination.js.map +1 -1
- package/dist/function-registry/edges.d.ts +2 -167
- package/dist/function-registry/edges.js +71 -978
- package/dist/function-registry/edges.js.map +1 -1
- package/dist/function-registry/evidence.d.ts +41 -52
- package/dist/function-registry/evidence.js +62 -826
- package/dist/function-registry/evidence.js.map +1 -1
- package/dist/function-registry/graph.d.ts +66 -162
- package/dist/function-registry/graph.js +46 -886
- package/dist/function-registry/graph.js.map +1 -1
- package/dist/function-registry/helpers.d.ts +4 -7
- package/dist/function-registry/helpers.js +40 -771
- package/dist/function-registry/helpers.js.map +1 -1
- package/dist/function-registry/identity.d.ts +16 -62
- package/dist/function-registry/identity.js +45 -793
- package/dist/function-registry/identity.js.map +1 -1
- package/dist/function-registry/index.d.ts +3 -5
- package/dist/function-registry/index.js +43 -777
- package/dist/function-registry/index.js.map +1 -1
- package/dist/function-registry/judgments.d.ts +11 -16
- package/dist/function-registry/judgments.js +42 -782
- package/dist/function-registry/judgments.js.map +1 -1
- package/dist/function-registry/legacy.d.ts +1 -5
- package/dist/function-registry/legacy.js +39 -770
- package/dist/function-registry/legacy.js.map +1 -1
- package/dist/function-registry/lenses.d.ts +21 -28
- package/dist/function-registry/lenses.js +42 -793
- package/dist/function-registry/lenses.js.map +1 -1
- package/dist/function-registry/manifest.d.ts +6 -6
- package/dist/function-registry/manifest.js +2 -19
- package/dist/function-registry/manifest.js.map +1 -1
- package/dist/function-registry/ontologies.d.ts +56 -70
- package/dist/function-registry/ontologies.js +45 -788
- package/dist/function-registry/ontologies.js.map +1 -1
- package/dist/function-registry/pipeline.d.ts +16 -22
- package/dist/function-registry/pipeline.js +42 -779
- package/dist/function-registry/pipeline.js.map +1 -1
- package/dist/function-registry/questions.d.ts +61 -76
- package/dist/function-registry/questions.js +52 -869
- package/dist/function-registry/questions.js.map +1 -1
- package/dist/function-registry/tasks.d.ts +21 -28
- package/dist/function-registry/tasks.js +48 -845
- package/dist/function-registry/tasks.js.map +1 -1
- package/dist/function-registry/topics.d.ts +26 -114
- package/dist/function-registry/topics.js +43 -852
- package/dist/function-registry/topics.js.map +1 -1
- package/dist/function-registry/types.d.ts +3 -7
- package/dist/function-registry/worktrees.d.ts +51 -104
- package/dist/function-registry/worktrees.js +51 -925
- package/dist/function-registry/worktrees.js.map +1 -1
- package/dist/gateway.contract.d.ts +0 -6
- package/dist/gateway.contract.js.map +1 -1
- package/dist/generated/convexSchemas.d.ts +3 -3
- package/dist/generated/convexSchemas.js +18 -39
- package/dist/generated/convexSchemas.js.map +1 -1
- package/dist/generated/schema-manifest.json +98 -1244
- package/dist/generated/tableOwnership.d.ts +28 -49
- package/dist/generated/tableOwnership.js +26 -68
- package/dist/generated/tableOwnership.js.map +1 -1
- package/dist/generated/tier-expectations.json +9 -66
- package/dist/graph-types/index.d.ts +1 -5
- package/dist/graph-types/index.js +4 -15
- package/dist/graph-types/index.js.map +1 -1
- package/dist/index-CV-0_VWJ.d.ts +25 -0
- package/dist/index.d.ts +414 -30
- package/dist/index.js +342 -35266
- package/dist/index.js.map +1 -1
- package/dist/lens-filter.contract.js +3 -4
- package/dist/lens-filter.contract.js.map +1 -1
- package/dist/lens-workflow.contract.js +3 -4
- package/dist/lens-workflow.contract.js.map +1 -1
- package/dist/schema-helpers/enumValidation.js +5 -2
- package/dist/schema-helpers/enumValidation.js.map +1 -1
- package/dist/schema-helpers/spine/nodes/decision.js +1 -2
- package/dist/schema-helpers/spine/nodes/decision.js.map +1 -1
- package/dist/schema-helpers/spine/tables/epistemicNodes.js +27 -27
- package/dist/schema-helpers/spine/tables/epistemicNodes.js.map +1 -1
- package/dist/schemas/component-table-manifest.d.ts +6 -6
- package/dist/schemas/component-table-manifest.js +2 -2
- package/dist/schemas/component-table-manifest.js.map +1 -1
- package/dist/schemas/enums.d.ts +2 -5
- package/dist/schemas/enums.js +2 -5
- package/dist/schemas/enums.js.map +1 -1
- package/dist/schemas/index.d.ts +3 -3
- package/dist/schemas/index.js +139 -1165
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/manifest.d.ts +932 -3042
- package/dist/schemas/manifest.js +137 -1163
- package/dist/schemas/manifest.js.map +1 -1
- package/dist/schemas/sl-opinion.d.ts +4 -4
- package/dist/schemas/tables/{controlPlane → identity}/agent.d.ts +1 -1
- package/dist/schemas/tables/{controlPlane → identity}/agent.js +3 -3
- package/dist/schemas/tables/identity/agent.js.map +1 -0
- package/dist/schemas/tables/{controlPlane → identity}/epistemic.d.ts +1 -1
- package/dist/schemas/tables/{controlPlane → identity}/epistemic.js +3 -3
- package/dist/schemas/tables/identity/epistemic.js.map +1 -0
- package/dist/schemas/tables/{controlPlane → identity}/model.d.ts +1 -1
- package/dist/schemas/tables/{controlPlane → identity}/model.js +6 -6
- package/dist/schemas/tables/identity/model.js.map +1 -0
- package/dist/schemas/tables/{controlPlane → identity}/platform.d.ts +11 -11
- package/dist/schemas/tables/{controlPlane → identity}/platform.js +18 -18
- package/dist/schemas/tables/identity/platform.js.map +1 -0
- package/dist/schemas/tables/{controlPlane → identity}/project.d.ts +1 -1
- package/dist/schemas/tables/{controlPlane → identity}/project.js +3 -3
- package/dist/schemas/tables/identity/project.js.map +1 -0
- package/dist/schemas/tables/{controlPlane → identity}/user.d.ts +1 -1
- package/dist/schemas/tables/{controlPlane → identity}/user.js +3 -3
- package/dist/schemas/tables/identity/user.js.map +1 -0
- package/dist/schemas/tables/kernel/config.d.ts +1 -1
- package/dist/schemas/tables/kernel/config.js.map +1 -1
- package/dist/schemas/tables/kernel/coordination.d.ts +1 -1
- package/dist/schemas/tables/kernel/coordination.js.map +1 -1
- package/dist/schemas/tables/kernel/decision.d.ts +1 -1
- package/dist/schemas/tables/kernel/decision.js.map +1 -1
- package/dist/schemas/tables/kernel/embedding.d.ts +1 -1
- package/dist/schemas/tables/kernel/embedding.js.map +1 -1
- package/dist/schemas/tables/kernel/epistemic.d.ts +7 -7
- package/dist/schemas/tables/kernel/epistemic.js.map +1 -1
- package/dist/schemas/tables/kernel/idempotency.d.ts +1 -1
- package/dist/schemas/tables/kernel/idempotency.js.map +1 -1
- package/dist/schemas/tables/kernel/infra.d.ts +5 -5
- package/dist/schemas/tables/kernel/infra.js.map +1 -1
- package/dist/schemas/tables/kernel/intelligence.d.ts +11 -11
- package/dist/schemas/tables/kernel/intelligence.js.map +1 -1
- package/dist/schemas/tables/kernel/lens.d.ts +5 -5
- package/dist/schemas/tables/kernel/lens.js.map +1 -1
- package/dist/schemas/tables/kernel/ontology.d.ts +1 -1
- package/dist/schemas/tables/kernel/ontology.js.map +1 -1
- package/dist/schemas/tables/kernel/platform.d.ts +13 -13
- package/dist/schemas/tables/kernel/platform.js.map +1 -1
- package/dist/schemas/tables/kernel/spine.d.ts +4 -5
- package/dist/schemas/tables/kernel/spine.js +2 -6
- package/dist/schemas/tables/kernel/spine.js.map +1 -1
- package/dist/schemas/tables/kernel/task.d.ts +43 -43
- package/dist/schemas/tables/kernel/task.js.map +1 -1
- package/dist/schemas/tables/kernel/topic.d.ts +1 -1
- package/dist/schemas/tables/kernel/topic.js +1 -5
- package/dist/schemas/tables/kernel/topic.js.map +1 -1
- package/dist/schemas/tables/kernel/workflow.d.ts +1 -1
- package/dist/schemas/tables/kernel/workflow.js.map +1 -1
- package/dist/schemas/tables/kernel/worktree.d.ts +55 -55
- package/dist/schemas/tables/kernel/worktree.js.map +1 -1
- package/dist/schemas/tables/mc/identity.d.ts +4 -44
- package/dist/schemas/tables/mc/identity.js +1 -66
- package/dist/schemas/tables/mc/identity.js.map +1 -1
- package/dist/schemas/tables/mc/methodology.d.ts +1 -1
- package/dist/schemas/tables/mc/methodology.js.map +1 -1
- package/dist/schemas/tables/mc/pack.d.ts +21 -21
- package/dist/schemas/tables/mc/pack.js.map +1 -1
- package/dist/schemas/tables/mc/policy.d.ts +2 -2
- package/dist/schemas/tables/mc/policy.js +1 -1
- package/dist/schemas/tables/mc/policy.js.map +1 -1
- package/dist/schemas/tables/mc/registry.d.ts +5 -5
- package/dist/schemas/tables/mc/registry.js.map +1 -1
- package/dist/schemas/tables/mc/runtime.d.ts +3 -109
- package/dist/schemas/tables/mc/runtime.js +104 -330
- package/dist/schemas/tables/mc/runtime.js.map +1 -1
- package/dist/schemas/tables/mc/tenant.d.ts +2 -4
- package/dist/schemas/tables/mc/tenant.js +1 -3
- package/dist/schemas/tables/mc/tenant.js.map +1 -1
- package/dist/schemas/tables/mc/workspace.d.ts +5 -28
- package/dist/schemas/tables/mc/workspace.js +2 -36
- package/dist/schemas/tables/mc/workspace.js.map +1 -1
- package/dist/sdk-methods.contract.d.ts +2 -2
- package/dist/{sdk-tools.contract-CKmSsrZ2.d.ts → sdk-tools.contract-S4ia0TTo.d.ts} +2 -2
- package/dist/sdk-tools.contract.d.ts +2 -2
- package/dist/sdk-tools.contract.js +27 -719
- package/dist/sdk-tools.contract.js.map +1 -1
- package/dist/{tool-contracts-C_xvM9q2.d.ts → tool-contracts-C92-9ueT.d.ts} +2 -38
- package/dist/tool-contracts.d.ts +1 -1
- package/dist/tool-contracts.js +28 -720
- package/dist/tool-contracts.js.map +1 -1
- package/package.json +1 -30
- package/dist/component-boundary.contract.d.ts +0 -14
- package/dist/component-boundary.contract.js +0 -175
- package/dist/component-boundary.contract.js.map +0 -1
- package/dist/component-host-boundary.contract.d.ts +0 -46
- package/dist/component-host-boundary.contract.js +0 -60
- package/dist/component-host-boundary.contract.js.map +0 -1
- package/dist/edge-policy-manifest-Dw5IhT1L.d.ts +0 -133
- package/dist/function-registry/nodes.d.ts +0 -412
- package/dist/function-registry/nodes.js +0 -5354
- package/dist/function-registry/nodes.js.map +0 -1
- package/dist/function-registry-input-audit.d.ts +0 -13
- package/dist/function-registry-input-audit.js +0 -166
- package/dist/function-registry-input-audit.js.map +0 -1
- package/dist/generated/infisicalRuntimeEnv.d.ts +0 -70
- package/dist/generated/infisicalRuntimeEnv.js +0 -27345
- package/dist/generated/infisicalRuntimeEnv.js.map +0 -1
- package/dist/generated/lucernGatewayEnv.d.ts +0 -17
- package/dist/generated/lucernGatewayEnv.js +0 -38
- package/dist/generated/lucernGatewayEnv.js.map +0 -1
- package/dist/generated/lucernWebPublicEnv.d.ts +0 -26
- package/dist/generated/lucernWebPublicEnv.js +0 -32
- package/dist/generated/lucernWebPublicEnv.js.map +0 -1
- package/dist/generated/lucernWebServerEnv.d.ts +0 -33
- package/dist/generated/lucernWebServerEnv.js +0 -51
- package/dist/generated/lucernWebServerEnv.js.map +0 -1
- package/dist/graph-intelligence.contract.d.ts +0 -506
- package/dist/graph-intelligence.contract.js +0 -595
- package/dist/graph-intelligence.contract.js.map +0 -1
- package/dist/index-CM1Pl_vI.d.ts +0 -28
- package/dist/infisical-runtime.contract.d.ts +0 -1889
- package/dist/infisical-runtime.contract.js +0 -3235
- package/dist/infisical-runtime.contract.js.map +0 -1
- package/dist/manifests/edge-policy-manifest.d.ts +0 -2
- package/dist/manifests/edge-policy-manifest.data.d.ts +0 -13
- package/dist/manifests/edge-policy-manifest.data.js +0 -26
- package/dist/manifests/edge-policy-manifest.data.js.map +0 -1
- package/dist/manifests/edge-policy-manifest.js +0 -92
- package/dist/manifests/edge-policy-manifest.js.map +0 -1
- package/dist/manifests/infisical-runtime-manifest.d.ts +0 -1792
- package/dist/manifests/infisical-runtime-manifest.js +0 -3090
- package/dist/manifests/infisical-runtime-manifest.js.map +0 -1
- package/dist/manifests/invariant-manifest.d.ts +0 -65
- package/dist/manifests/invariant-manifest.js +0 -18
- package/dist/manifests/invariant-manifest.js.map +0 -1
- package/dist/manifests/invariants/ast-utils.d.ts +0 -14
- package/dist/manifests/invariants/ast-utils.js +0 -54
- package/dist/manifests/invariants/ast-utils.js.map +0 -1
- package/dist/manifests/invariants/index.d.ts +0 -15
- package/dist/manifests/invariants/index.js +0 -183
- package/dist/manifests/invariants/index.js.map +0 -1
- package/dist/manifests/invariants/inv-1-beliefs-append-only.d.ts +0 -12
- package/dist/manifests/invariants/inv-1-beliefs-append-only.js +0 -94
- package/dist/manifests/invariants/inv-1-beliefs-append-only.js.map +0 -1
- package/dist/manifests/invariants/inv-14-no-silent-transitions.d.ts +0 -12
- package/dist/manifests/invariants/inv-14-no-silent-transitions.js +0 -99
- package/dist/manifests/invariants/inv-14-no-silent-transitions.js.map +0 -1
- package/dist/manifests/invariants/manifest-1-projections-declare-audit.d.ts +0 -12
- package/dist/manifests/invariants/manifest-1-projections-declare-audit.js +0 -42
- package/dist/manifests/invariants/manifest-1-projections-declare-audit.js.map +0 -1
- package/dist/manifests/tenant-client-manifest.d.ts +0 -327
- package/dist/manifests/tenant-client-manifest.js +0 -449
- package/dist/manifests/tenant-client-manifest.js.map +0 -1
- package/dist/mcp-gateway-boundary.contract.d.ts +0 -201
- package/dist/mcp-gateway-boundary.contract.js +0 -45
- package/dist/mcp-gateway-boundary.contract.js.map +0 -1
- package/dist/permit-principal-projection.contract.d.ts +0 -74
- package/dist/permit-principal-projection.contract.js +0 -167
- package/dist/permit-principal-projection.contract.js.map +0 -1
- package/dist/projections/check-convex-args-shape.d.ts +0 -3
- package/dist/projections/check-convex-args-shape.js +0 -403
- package/dist/projections/check-convex-args-shape.js.map +0 -1
- package/dist/projections/create-evidence.projection.d.ts +0 -176
- package/dist/projections/create-evidence.projection.js +0 -130
- package/dist/projections/create-evidence.projection.js.map +0 -1
- package/dist/projections/index.d.ts +0 -102
- package/dist/projections/index.js +0 -352
- package/dist/projections/index.js.map +0 -1
- package/dist/projections/list-beliefs.projection.d.ts +0 -36
- package/dist/projections/list-beliefs.projection.js +0 -54
- package/dist/projections/list-beliefs.projection.js.map +0 -1
- package/dist/projections/list-tasks.projection.d.ts +0 -44
- package/dist/projections/list-tasks.projection.js +0 -57
- package/dist/projections/list-tasks.projection.js.map +0 -1
- package/dist/projections/modulate-confidence.projection.d.ts +0 -219
- package/dist/projections/modulate-confidence.projection.js +0 -148
- package/dist/projections/modulate-confidence.projection.js.map +0 -1
- package/dist/projections/projection-dsl.d.ts +0 -11
- package/dist/projections/projection-dsl.js +0 -8
- package/dist/projections/projection-dsl.js.map +0 -1
- package/dist/proof-attestation.json +0 -45
- package/dist/schemas/tables/controlPlane/accessControl.d.ts +0 -260
- package/dist/schemas/tables/controlPlane/accessControl.js +0 -658
- package/dist/schemas/tables/controlPlane/accessControl.js.map +0 -1
- package/dist/schemas/tables/controlPlane/agent.js.map +0 -1
- package/dist/schemas/tables/controlPlane/epistemic.js.map +0 -1
- package/dist/schemas/tables/controlPlane/model.js.map +0 -1
- package/dist/schemas/tables/controlPlane/platform.js.map +0 -1
- package/dist/schemas/tables/controlPlane/project.js.map +0 -1
- package/dist/schemas/tables/controlPlane/user.js.map +0 -1
- package/dist/schemas/tables/kernel/events.d.ts +0 -21
- package/dist/schemas/tables/kernel/events.js +0 -43
- package/dist/schemas/tables/kernel/events.js.map +0 -1
- package/dist/tenant-bootstrap-seed.contract.d.ts +0 -1289
- package/dist/tenant-bootstrap-seed.contract.js +0 -764
- package/dist/tenant-bootstrap-seed.contract.js.map +0 -1
- package/dist/tenant-bootstrap-seed.defaults.d.ts +0 -16
- package/dist/tenant-bootstrap-seed.defaults.js +0 -321
- package/dist/tenant-bootstrap-seed.defaults.js.map +0 -1
- package/dist/tenant-client.contract.d.ts +0 -354
- package/dist/tenant-client.contract.js +0 -505
- package/dist/tenant-client.contract.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/manifests/invariant-manifest.ts"],"names":[],"mappings":";;;AA0BO,IAAM,uBAAA,GAA0B,EAAE,MAAA,CAAO;AAAA,EAC9C,eAAA,EAAiB,CAAA,CAAE,OAAA,CAAQ,OAAO,CAAA;AAAA,EAClC,OAAO,CAAA,CAAE,KAAA;AAAA,IACP,EAAE,MAAA,CAAO;AAAA,MACP,SAAA,EAAW,EAAE,MAAA,EAAO;AAAA,MACpB,WAAA,EAAa,EAAE,MAAA,EAAO;AAAA,MACtB,SAAS,CAAA,CAAE,IAAA,CAAK,CAAC,KAAA,EAAO,UAAA,EAAY,SAAS,CAAC,CAAA;AAAA,MAC9C,UAAU,CAAA,CAAE,IAAA,CAAK,CAAC,eAAA,EAAiB,UAAA,EAAY,MAAM,CAAC;AAAA,KACvD;AAAA;AAEL,CAAC","file":"invariant-manifest.js","sourcesContent":["import { z } from \"zod\";\nimport type { ProjectionRegistry } from \"../projections/index.js\";\n\nexport type InvariantId = string;\nexport type CheckerKind = \"ast\" | \"manifest\" | \"runtime\";\nexport type InvariantSeverity = \"block_publish\" | \"block_pr\" | \"warn\";\n\nexport interface CheckContext {\n repoRoot: string;\n projections: ProjectionRegistry;\n}\n\nexport interface InvariantResult {\n status: \"passed\" | \"failed\" | \"skipped\";\n evidenceRefs: string[];\n reason?: string;\n}\n\nexport interface InvariantRule {\n invariant: InvariantId;\n description: string;\n checker: CheckerKind;\n severity: InvariantSeverity;\n evaluate: (ctx: CheckContext) => Promise<InvariantResult>;\n}\n\nexport const InvariantManifestSchema = z.object({\n manifestVersion: z.literal(\"1.0.0\"),\n rules: z.array(\n z.object({\n invariant: z.string(),\n description: z.string(),\n checker: z.enum([\"ast\", \"manifest\", \"runtime\"]),\n severity: z.enum([\"block_publish\", \"block_pr\", \"warn\"]),\n })\n ),\n});\n\nexport type InvariantManifest = z.infer<typeof InvariantManifestSchema>;\n"]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import ts from 'typescript';
|
|
2
|
-
|
|
3
|
-
type SourceUnit = {
|
|
4
|
-
filePath: string;
|
|
5
|
-
text: string;
|
|
6
|
-
sourceFile: ts.SourceFile;
|
|
7
|
-
};
|
|
8
|
-
declare function collectTsFiles(root: string): string[];
|
|
9
|
-
declare function readSource(filePath: string): SourceUnit;
|
|
10
|
-
declare function walk(node: ts.Node, visit: (node: ts.Node) => void): void;
|
|
11
|
-
declare function isDbCall(node: ts.Node, method: string): node is ts.CallExpression;
|
|
12
|
-
declare function lineRef(unit: SourceUnit, node: ts.Node): string;
|
|
13
|
-
|
|
14
|
-
export { type SourceUnit, collectTsFiles, isDbCall, lineRef, readSource, walk };
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { readdirSync, statSync, readFileSync } from 'fs';
|
|
2
|
-
import { join } from 'path';
|
|
3
|
-
import ts from 'typescript';
|
|
4
|
-
|
|
5
|
-
// src/manifests/invariants/ast-utils.ts
|
|
6
|
-
function collectTsFiles(root) {
|
|
7
|
-
const entries = [];
|
|
8
|
-
for (const name of readdirSync(root)) {
|
|
9
|
-
const path = join(root, name);
|
|
10
|
-
const stat = statSync(path);
|
|
11
|
-
if (stat.isDirectory()) {
|
|
12
|
-
if (name === "node_modules" || name === "dist" || name === ".next") {
|
|
13
|
-
continue;
|
|
14
|
-
}
|
|
15
|
-
entries.push(...collectTsFiles(path));
|
|
16
|
-
} else if (name.endsWith(".ts") && !name.endsWith(".d.ts")) {
|
|
17
|
-
entries.push(path);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return entries;
|
|
21
|
-
}
|
|
22
|
-
function readSource(filePath) {
|
|
23
|
-
const text = readFileSync(filePath, "utf8");
|
|
24
|
-
return {
|
|
25
|
-
filePath,
|
|
26
|
-
text,
|
|
27
|
-
sourceFile: ts.createSourceFile(filePath, text, ts.ScriptTarget.Latest, true)
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function walk(node, visit) {
|
|
31
|
-
visit(node);
|
|
32
|
-
node.forEachChild((child) => walk(child, visit));
|
|
33
|
-
}
|
|
34
|
-
function isDbCall(node, method) {
|
|
35
|
-
if (!ts.isCallExpression(node)) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
const expression = node.expression;
|
|
39
|
-
if (!ts.isPropertyAccessExpression(expression)) {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
if (expression.name.text !== method) {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
return expression.expression.getText().endsWith(".db");
|
|
46
|
-
}
|
|
47
|
-
function lineRef(unit, node) {
|
|
48
|
-
const { line } = unit.sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
|
49
|
-
return `${unit.filePath}:${line + 1}`;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export { collectTsFiles, isDbCall, lineRef, readSource, walk };
|
|
53
|
-
//# sourceMappingURL=ast-utils.js.map
|
|
54
|
-
//# sourceMappingURL=ast-utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{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I,CAAC,EAAA,CAAG,gBAAA,CAAiB,IAAI,CAAA,EAAG;AAC9B,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,MAAM,aAAa,IAAA,CAAK,UAAA;AACxB,EAAA,IAAI,CAAC,EAAA,CAAG,0BAAA,CAA2B,UAAU,CAAA,EAAG;AAC9C,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,IAAI,UAAA,CAAW,IAAA,CAAK,IAAA,KAAS,MAAA,EAAQ;AACnC,IAAA,OAAO,KAAA;AAAA,EACT;AACA,EAAA,OAAO,UAAA,CAAW,UAAA,CAAW,OAAA,EAAQ,CAAE,SAAS,KAAK,CAAA;AACvD;AAEO,SAAS,OAAA,CAAQ,MAAkB,IAAA,EAAuB;AAC/D,EAAA,MAAM,EAAE,MAAK,GAAI,IAAA,CAAK,WAAW,6BAAA,CAA8B,IAAA,CAAK,UAAU,CAAA;AAC9E,EAAA,OAAO,CAAA,EAAG,IAAA,CAAK,QAAQ,CAAA,CAAA,EAAI,OAAO,CAAC,CAAA,CAAA;AACrC","file":"ast-utils.js","sourcesContent":["import { readFileSync, readdirSync, statSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport ts from \"typescript\";\n\nexport type SourceUnit = {\n filePath: string;\n text: string;\n sourceFile: ts.SourceFile;\n};\n\nexport function collectTsFiles(root: string): string[] {\n const entries: string[] = [];\n for (const name of readdirSync(root)) {\n const path = join(root, name);\n const stat = statSync(path);\n if (stat.isDirectory()) {\n if (name === \"node_modules\" || name === \"dist\" || name === \".next\") {\n continue;\n }\n entries.push(...collectTsFiles(path));\n } else if (name.endsWith(\".ts\") && !name.endsWith(\".d.ts\")) {\n entries.push(path);\n }\n }\n return entries;\n}\n\nexport function readSource(filePath: string): SourceUnit {\n const text = readFileSync(filePath, \"utf8\");\n return {\n filePath,\n text,\n sourceFile: ts.createSourceFile(filePath, text, ts.ScriptTarget.Latest, true),\n };\n}\n\nexport function walk(node: ts.Node, visit: (node: ts.Node) => void): void {\n visit(node);\n node.forEachChild((child) => walk(child, visit));\n}\n\nexport function isDbCall(node: ts.Node, method: string): node is ts.CallExpression {\n if (!ts.isCallExpression(node)) {\n return false;\n }\n const expression = node.expression;\n if (!ts.isPropertyAccessExpression(expression)) {\n return false;\n }\n if (expression.name.text !== method) {\n return false;\n }\n return expression.expression.getText().endsWith(\".db\");\n}\n\nexport function lineRef(unit: SourceUnit, node: ts.Node): string {\n const { line } = unit.sourceFile.getLineAndCharacterOfPosition(node.getStart());\n return `${unit.filePath}:${line + 1}`;\n}\n"]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { InvariantRule } from '../invariant-manifest.js';
|
|
2
|
-
export { INV_1_BELIEFS_APPEND_ONLY } from './inv-1-beliefs-append-only.js';
|
|
3
|
-
export { INV_14_NO_SILENT_TRANSITIONS } from './inv-14-no-silent-transitions.js';
|
|
4
|
-
export { MANIFEST_1_PROJECTIONS_DECLARE_AUDIT } from './manifest-1-projections-declare-audit.js';
|
|
5
|
-
import 'zod';
|
|
6
|
-
import '../../projections/index.js';
|
|
7
|
-
import '../../projections/projection-dsl.js';
|
|
8
|
-
import '../../projections/create-evidence.projection.js';
|
|
9
|
-
import '../../projections/list-beliefs.projection.js';
|
|
10
|
-
import '../../projections/list-tasks.projection.js';
|
|
11
|
-
import '../../projections/modulate-confidence.projection.js';
|
|
12
|
-
|
|
13
|
-
declare const invariants: readonly [InvariantRule, InvariantRule, InvariantRule];
|
|
14
|
-
|
|
15
|
-
export { invariants };
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
import { join } from 'path';
|
|
2
|
-
import { readdirSync, statSync, readFileSync } from 'fs';
|
|
3
|
-
import ts from 'typescript';
|
|
4
|
-
|
|
5
|
-
// src/manifests/invariants/inv-1-beliefs-append-only.ts
|
|
6
|
-
function collectTsFiles(root) {
|
|
7
|
-
const entries = [];
|
|
8
|
-
for (const name of readdirSync(root)) {
|
|
9
|
-
const path = join(root, name);
|
|
10
|
-
const stat = statSync(path);
|
|
11
|
-
if (stat.isDirectory()) {
|
|
12
|
-
if (name === "node_modules" || name === "dist" || name === ".next") {
|
|
13
|
-
continue;
|
|
14
|
-
}
|
|
15
|
-
entries.push(...collectTsFiles(path));
|
|
16
|
-
} else if (name.endsWith(".ts") && !name.endsWith(".d.ts")) {
|
|
17
|
-
entries.push(path);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return entries;
|
|
21
|
-
}
|
|
22
|
-
function readSource(filePath) {
|
|
23
|
-
const text = readFileSync(filePath, "utf8");
|
|
24
|
-
return {
|
|
25
|
-
filePath,
|
|
26
|
-
text,
|
|
27
|
-
sourceFile: ts.createSourceFile(filePath, text, ts.ScriptTarget.Latest, true)
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function walk(node, visit) {
|
|
31
|
-
visit(node);
|
|
32
|
-
node.forEachChild((child) => walk(child, visit));
|
|
33
|
-
}
|
|
34
|
-
function isDbCall(node, method) {
|
|
35
|
-
if (!ts.isCallExpression(node)) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
const expression = node.expression;
|
|
39
|
-
if (!ts.isPropertyAccessExpression(expression)) {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
if (expression.name.text !== method) {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
return expression.expression.getText().endsWith(".db");
|
|
46
|
-
}
|
|
47
|
-
function lineRef(unit, node) {
|
|
48
|
-
const { line } = unit.sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
|
49
|
-
return `${unit.filePath}:${line + 1}`;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// src/manifests/invariants/inv-1-beliefs-append-only.ts
|
|
53
|
-
function isBeliefWriteCandidate(node) {
|
|
54
|
-
const [target, patch] = node.arguments;
|
|
55
|
-
const targetText = target?.getText() ?? "";
|
|
56
|
-
const patchText = patch?.getText() ?? "";
|
|
57
|
-
if (!/belief/i.test(targetText)) {
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
return /canonicalText|formulation|confidence|beliefStatus/.test(patchText);
|
|
61
|
-
}
|
|
62
|
-
var INV_1_BELIEFS_APPEND_ONLY = {
|
|
63
|
-
invariant: "INV-1: beliefs append-only",
|
|
64
|
-
description: "Scored beliefs cannot be patched or deleted; they must fork.",
|
|
65
|
-
checker: "ast",
|
|
66
|
-
severity: "block_publish",
|
|
67
|
-
evaluate: async (ctx) => {
|
|
68
|
-
const root = join(ctx.repoRoot, "packages/reasoning-kernel/src/adapters");
|
|
69
|
-
const violations = [];
|
|
70
|
-
for (const filePath of collectTsFiles(root)) {
|
|
71
|
-
if (filePath.endsWith(".test.ts")) {
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
const unit = readSource(filePath);
|
|
75
|
-
walk(unit.sourceFile, (node) => {
|
|
76
|
-
if (isDbCall(node, "patch") && isBeliefWriteCandidate(node)) {
|
|
77
|
-
violations.push(lineRef(unit, node));
|
|
78
|
-
}
|
|
79
|
-
if (isDbCall(node, "delete") && /belief/i.test(node.getText())) {
|
|
80
|
-
violations.push(lineRef(unit, node));
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
return violations.length === 0 ? { status: "passed", evidenceRefs: [] } : {
|
|
85
|
-
status: "failed",
|
|
86
|
-
evidenceRefs: violations,
|
|
87
|
-
reason: `${violations.length} unwrapped belief writes found`
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
var EPISTEMIC_TABLES = [
|
|
92
|
-
"epistemicNodes",
|
|
93
|
-
"epistemicEdges",
|
|
94
|
-
"beliefConfidence",
|
|
95
|
-
"questions",
|
|
96
|
-
"answers",
|
|
97
|
-
"contradictions"
|
|
98
|
-
];
|
|
99
|
-
var INV_14_NO_SILENT_TRANSITIONS = {
|
|
100
|
-
invariant: "INV-14: no silent state transitions",
|
|
101
|
-
description: "Epistemic state transitions must co-locate an epistemicAudit insert in the same implementation file.",
|
|
102
|
-
checker: "ast",
|
|
103
|
-
severity: "block_publish",
|
|
104
|
-
evaluate: async (ctx) => {
|
|
105
|
-
const root = join(ctx.repoRoot, "packages/reasoning-kernel/src/adapters");
|
|
106
|
-
const violations = [];
|
|
107
|
-
for (const filePath of collectTsFiles(root)) {
|
|
108
|
-
if (filePath.endsWith(".test.ts")) {
|
|
109
|
-
continue;
|
|
110
|
-
}
|
|
111
|
-
const unit = readSource(filePath);
|
|
112
|
-
if (unit.text.includes("epistemicAudit")) {
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
walk(unit.sourceFile, (node) => {
|
|
116
|
-
if (!isDbCall(node, "patch")) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
const text = node.getText();
|
|
120
|
-
const touchesEpistemicState = EPISTEMIC_TABLES.some((table) => text.includes(`"${table}"`)) || /\b(belief|question|answer|contradiction|edge)\w*Id\b/i.test(text);
|
|
121
|
-
const carriesAuditIntent = /\b(epistemicAudit|rationale|reason|audit)\b/i.test(text);
|
|
122
|
-
if (touchesEpistemicState && !carriesAuditIntent) {
|
|
123
|
-
violations.push(lineRef(unit, node));
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
return violations.length === 0 ? { status: "passed", evidenceRefs: [] } : {
|
|
128
|
-
status: "failed",
|
|
129
|
-
evidenceRefs: violations,
|
|
130
|
-
reason: `${violations.length} epistemic writes lack local audit evidence`
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
// src/manifests/invariants/manifest-1-projections-declare-audit.ts
|
|
136
|
-
function objectShape(schema) {
|
|
137
|
-
let current = schema;
|
|
138
|
-
while (current._def.typeName === "ZodEffects") {
|
|
139
|
-
current = current._def.schema;
|
|
140
|
-
}
|
|
141
|
-
const def = current._def;
|
|
142
|
-
if (typeof def.shape === "function") {
|
|
143
|
-
return def.shape();
|
|
144
|
-
}
|
|
145
|
-
if (def.shape && typeof def.shape === "object") {
|
|
146
|
-
return def.shape;
|
|
147
|
-
}
|
|
148
|
-
return void 0;
|
|
149
|
-
}
|
|
150
|
-
var MANIFEST_1_PROJECTIONS_DECLARE_AUDIT = {
|
|
151
|
-
invariant: "MANIFEST-1: kernel projections declare epistemicAudit",
|
|
152
|
-
description: "Kernel mutation projections must carry a rationale so audit evidence can explain the transition.",
|
|
153
|
-
checker: "manifest",
|
|
154
|
-
severity: "block_publish",
|
|
155
|
-
evaluate: async (ctx) => {
|
|
156
|
-
const violations = [];
|
|
157
|
-
for (const [name, projection] of Object.entries(ctx.projections)) {
|
|
158
|
-
if (!/^(create|modulate|fork|update)_/.test(name)) {
|
|
159
|
-
continue;
|
|
160
|
-
}
|
|
161
|
-
const shape = objectShape(projection.inputSchema);
|
|
162
|
-
if (!shape || !("rationale" in shape)) {
|
|
163
|
-
violations.push(`projection '${name}' missing 'rationale' field`);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return violations.length === 0 ? { status: "passed", evidenceRefs: [] } : {
|
|
167
|
-
status: "failed",
|
|
168
|
-
evidenceRefs: violations,
|
|
169
|
-
reason: `${violations.length} projections missing audit rationale`
|
|
170
|
-
};
|
|
171
|
-
}
|
|
172
|
-
};
|
|
173
|
-
|
|
174
|
-
// src/manifests/invariants/index.ts
|
|
175
|
-
var invariants = [
|
|
176
|
-
INV_1_BELIEFS_APPEND_ONLY,
|
|
177
|
-
INV_14_NO_SILENT_TRANSITIONS,
|
|
178
|
-
MANIFEST_1_PROJECTIONS_DECLARE_AUDIT
|
|
179
|
-
];
|
|
180
|
-
|
|
181
|
-
export { INV_14_NO_SILENT_TRANSITIONS, INV_1_BELIEFS_APPEND_ONLY, MANIFEST_1_PROJECTIONS_DECLARE_AUDIT, invariants };
|
|
182
|
-
//# sourceMappingURL=index.js.map
|
|
183
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/manifests/invariants/ast-utils.ts","../../../src/manifests/invariants/inv-1-beliefs-append-only.ts","../../../src/manifests/invariants/inv-14-no-silent-transitions.ts","../../../src/manifests/invariants/manifest-1-projections-declare-audit.ts","../../../src/manifests/invariants/index.ts"],"names":["join"],"mappings":";;;;;AAUO,SAAS,eAAe,IAAA,EAAwB;AACrD,EAAA,MAAM,UAAoB,EAAC;AAC3B,EAAA,KAAA,MAAW,IAAA,IAAQ,WAAA,CAAY,IAAI,CAAA,EAAG;AACpC,IAAA,MAAM,IAAA,GAAO,IAAA,CAAK,IAAA,EAAM,IAAI,CAAA;AAC5B,IAAA,MAAM,IAAA,GAAO,SAAS,IAAI,CAAA;AAC1B,IAAA,IAAI,IAAA,CAAK,aAAY,EAAG;AACtB,MAAA,IAAI,IAAA,KAAS,cAAA,IAAkB,IAAA,KAAS,MAAA,IAAU,SAAS,OAAA,EAAS;AAClE,QAAA;AAAA,MACF;AACA,MAAA,OAAA,CAAQ,IAAA,CAAK,GAAG,cAAA,CAAe,IAAI,CAAC,CAAA;AAAA,IACtC,CAAA,MAAA,IAAW,KAAK,QAAA,CAAS,KAAK,KAAK,CAAC,IAAA,CAAK,QAAA,CAAS,OAAO,CAAA,EAAG;AAC1D,MAAA,OAAA,CAAQ,KAAK,IAAI,CAAA;AAAA,IACnB;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT;AAEO,SAAS,WAAW,QAAA,EAA8B;AACvD,EAAA,MAAM,IAAA,GAAO,YAAA,CAAa,QAAA,EAAU,MAAM,CAAA;AAC1C,EAAA,OAAO;AAAA,IACL,QAAA;AAAA,IACA,IAAA;AAAA,IACA,UAAA,EAAY,GAAG,gBAAA,CAAiB,QAAA,EAAU,MAAM,EAAA,CAAG,YAAA,CAAa,QAAQ,IAAI;AAAA,GAC9E;AACF;AAEO,SAAS,IAAA,CAAK,MAAe,KAAA,EAAsC;AACxE,EAAA,KAAA,CAAM,IAAI,CAAA;AACV,EAAA,IAAA,CAAK,aAAa,CAAC,KAAA,KAAU,IAAA,CAAK,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CAAA,EAAG;AACjD,QAAA;AAAA,MACF;AACA,MAAA,MAAM,KAAA,GAAQ,WAAA,CAAY,UAAA,CAAW,WAAW,CAAA;AAChD,MAAA,IAAI,CAAC,KAAA,IAAS,EAAE,WAAA,IAAe,KAAA,CAAA,EAAQ;AACrC,QAAA,UAAA,CAAW,IAAA,CAAK,CAAA,YAAA,EAAe,IAAI,CAAA,2BAAA,CAA6B,CAAA;AAAA,MAClE;AAAA,IACF;AAEA,IAAA,OAAO,UAAA,CAAW,WAAW,CAAA,GACzB,EAAE,QAAQ,QAAA,EAAU,YAAA,EAAc,EAAC,EAAE,GACrC;AAAA,MACE,MAAA,EAAQ,QAAA;AAAA,MACR,YAAA,EAAc,UAAA;AAAA,MACd,MAAA,EAAQ,CAAA,EAAG,UAAA,CAAW,MAAM,CAAA,oCAAA;AAAA,KAC9B;AAAA,EACN;AACF;;;AC1CO,IAAM,UAAA,GAAa;AAAA,EACxB,yBAAA;AAAA,EACA,4BAAA;AAAA,EACA;AACF","file":"index.js","sourcesContent":["import { readFileSync, readdirSync, statSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport ts from \"typescript\";\n\nexport type SourceUnit = {\n filePath: string;\n text: string;\n sourceFile: ts.SourceFile;\n};\n\nexport function collectTsFiles(root: string): string[] {\n const entries: string[] = [];\n for (const name of readdirSync(root)) {\n const path = join(root, name);\n const stat = statSync(path);\n if (stat.isDirectory()) {\n if (name === \"node_modules\" || name === \"dist\" || name === \".next\") {\n continue;\n }\n entries.push(...collectTsFiles(path));\n } else if (name.endsWith(\".ts\") && !name.endsWith(\".d.ts\")) {\n entries.push(path);\n }\n }\n return entries;\n}\n\nexport function readSource(filePath: string): SourceUnit {\n const text = readFileSync(filePath, \"utf8\");\n return {\n filePath,\n text,\n sourceFile: ts.createSourceFile(filePath, text, ts.ScriptTarget.Latest, true),\n };\n}\n\nexport function walk(node: ts.Node, visit: (node: ts.Node) => void): void {\n visit(node);\n node.forEachChild((child) => walk(child, visit));\n}\n\nexport function isDbCall(node: ts.Node, method: string): node is ts.CallExpression {\n if (!ts.isCallExpression(node)) {\n return false;\n }\n const expression = node.expression;\n if (!ts.isPropertyAccessExpression(expression)) {\n return false;\n }\n if (expression.name.text !== method) {\n return false;\n }\n return expression.expression.getText().endsWith(\".db\");\n}\n\nexport function lineRef(unit: SourceUnit, node: ts.Node): string {\n const { line } = unit.sourceFile.getLineAndCharacterOfPosition(node.getStart());\n return `${unit.filePath}:${line + 1}`;\n}\n","import { join } from \"node:path\";\nimport ts from \"typescript\";\nimport type { InvariantRule } from \"../invariant-manifest.js\";\nimport { collectTsFiles, isDbCall, lineRef, readSource, walk } from \"./ast-utils.js\";\n\nfunction isBeliefWriteCandidate(node: ts.CallExpression): boolean {\n const [target, patch] = node.arguments;\n const targetText = target?.getText() ?? \"\";\n const patchText = patch?.getText() ?? \"\";\n\n if (!/belief/i.test(targetText)) {\n return false;\n }\n\n return /canonicalText|formulation|confidence|beliefStatus/.test(patchText);\n}\n\nexport const INV_1_BELIEFS_APPEND_ONLY: InvariantRule = {\n invariant: \"INV-1: beliefs append-only\",\n description: \"Scored beliefs cannot be patched or deleted; they must fork.\",\n checker: \"ast\",\n severity: \"block_publish\",\n evaluate: async (ctx) => {\n const root = join(ctx.repoRoot, \"packages/reasoning-kernel/src/adapters\");\n const violations: string[] = [];\n\n for (const filePath of collectTsFiles(root)) {\n if (filePath.endsWith(\".test.ts\")) {\n continue;\n }\n const unit = readSource(filePath);\n walk(unit.sourceFile, (node) => {\n if (isDbCall(node, \"patch\") && isBeliefWriteCandidate(node)) {\n violations.push(lineRef(unit, node));\n }\n if (isDbCall(node, \"delete\") && /belief/i.test(node.getText())) {\n violations.push(lineRef(unit, node));\n }\n });\n }\n\n return violations.length === 0\n ? { status: \"passed\", evidenceRefs: [] }\n : {\n status: \"failed\",\n evidenceRefs: violations,\n reason: `${violations.length} unwrapped belief writes found`,\n };\n },\n};\n","import { join } from \"node:path\";\nimport type { InvariantRule } from \"../invariant-manifest.js\";\nimport { collectTsFiles, isDbCall, lineRef, readSource, walk } from \"./ast-utils.js\";\n\nconst EPISTEMIC_TABLES = [\n \"epistemicNodes\",\n \"epistemicEdges\",\n \"beliefConfidence\",\n \"questions\",\n \"answers\",\n \"contradictions\",\n];\n\nexport const INV_14_NO_SILENT_TRANSITIONS: InvariantRule = {\n invariant: \"INV-14: no silent state transitions\",\n description:\n \"Epistemic state transitions must co-locate an epistemicAudit insert in the same implementation file.\",\n checker: \"ast\",\n severity: \"block_publish\",\n evaluate: async (ctx) => {\n const root = join(ctx.repoRoot, \"packages/reasoning-kernel/src/adapters\");\n const violations: string[] = [];\n\n for (const filePath of collectTsFiles(root)) {\n if (filePath.endsWith(\".test.ts\")) {\n continue;\n }\n const unit = readSource(filePath);\n if (unit.text.includes(\"epistemicAudit\")) {\n continue;\n }\n\n walk(unit.sourceFile, (node) => {\n if (!isDbCall(node, \"patch\")) {\n return;\n }\n const text = node.getText();\n const touchesEpistemicState =\n EPISTEMIC_TABLES.some((table) => text.includes(`\"${table}\"`)) ||\n /\\b(belief|question|answer|contradiction|edge)\\w*Id\\b/i.test(text);\n const carriesAuditIntent =\n /\\b(epistemicAudit|rationale|reason|audit)\\b/i.test(text);\n if (touchesEpistemicState && !carriesAuditIntent) {\n violations.push(lineRef(unit, node));\n }\n });\n }\n\n return violations.length === 0\n ? { status: \"passed\", evidenceRefs: [] }\n : {\n status: \"failed\",\n evidenceRefs: violations,\n reason: `${violations.length} epistemic writes lack local audit evidence`,\n };\n },\n};\n","import type { z } from \"zod\";\nimport type { InvariantRule } from \"../invariant-manifest.js\";\n\nfunction objectShape(schema: z.ZodTypeAny): Record<string, unknown> | undefined {\n let current = schema;\n while (current._def.typeName === \"ZodEffects\") {\n current = (current._def as { schema: z.ZodTypeAny }).schema;\n }\n\n const def = current._def as { shape?: unknown };\n if (typeof def.shape === \"function\") {\n return def.shape() as Record<string, unknown>;\n }\n if (def.shape && typeof def.shape === \"object\") {\n return def.shape as Record<string, unknown>;\n }\n return undefined;\n}\n\nexport const MANIFEST_1_PROJECTIONS_DECLARE_AUDIT: InvariantRule = {\n invariant: \"MANIFEST-1: kernel projections declare epistemicAudit\",\n description:\n \"Kernel mutation projections must carry a rationale so audit evidence can explain the transition.\",\n checker: \"manifest\",\n severity: \"block_publish\",\n evaluate: async (ctx) => {\n const violations: string[] = [];\n\n for (const [name, projection] of Object.entries(ctx.projections)) {\n if (!/^(create|modulate|fork|update)_/.test(name)) {\n continue;\n }\n const shape = objectShape(projection.inputSchema);\n if (!shape || !(\"rationale\" in shape)) {\n violations.push(`projection '${name}' missing 'rationale' field`);\n }\n }\n\n return violations.length === 0\n ? { status: \"passed\", evidenceRefs: [] }\n : {\n status: \"failed\",\n evidenceRefs: violations,\n reason: `${violations.length} projections missing audit rationale`,\n };\n },\n};\n","import { INV_1_BELIEFS_APPEND_ONLY } from \"./inv-1-beliefs-append-only.js\";\nimport { INV_14_NO_SILENT_TRANSITIONS } from \"./inv-14-no-silent-transitions.js\";\nimport { MANIFEST_1_PROJECTIONS_DECLARE_AUDIT } from \"./manifest-1-projections-declare-audit.js\";\n\nexport const invariants = [\n INV_1_BELIEFS_APPEND_ONLY,\n INV_14_NO_SILENT_TRANSITIONS,\n MANIFEST_1_PROJECTIONS_DECLARE_AUDIT,\n] as const;\n\nexport { INV_1_BELIEFS_APPEND_ONLY } from \"./inv-1-beliefs-append-only.js\";\nexport { INV_14_NO_SILENT_TRANSITIONS } from \"./inv-14-no-silent-transitions.js\";\nexport { MANIFEST_1_PROJECTIONS_DECLARE_AUDIT } from \"./manifest-1-projections-declare-audit.js\";\n"]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { InvariantRule } from '../invariant-manifest.js';
|
|
2
|
-
import 'zod';
|
|
3
|
-
import '../../projections/index.js';
|
|
4
|
-
import '../../projections/projection-dsl.js';
|
|
5
|
-
import '../../projections/create-evidence.projection.js';
|
|
6
|
-
import '../../projections/list-beliefs.projection.js';
|
|
7
|
-
import '../../projections/list-tasks.projection.js';
|
|
8
|
-
import '../../projections/modulate-confidence.projection.js';
|
|
9
|
-
|
|
10
|
-
declare const INV_1_BELIEFS_APPEND_ONLY: InvariantRule;
|
|
11
|
-
|
|
12
|
-
export { INV_1_BELIEFS_APPEND_ONLY };
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { join } from 'path';
|
|
2
|
-
import { readdirSync, statSync, readFileSync } from 'fs';
|
|
3
|
-
import ts from 'typescript';
|
|
4
|
-
|
|
5
|
-
// src/manifests/invariants/inv-1-beliefs-append-only.ts
|
|
6
|
-
function collectTsFiles(root) {
|
|
7
|
-
const entries = [];
|
|
8
|
-
for (const name of readdirSync(root)) {
|
|
9
|
-
const path = join(root, name);
|
|
10
|
-
const stat = statSync(path);
|
|
11
|
-
if (stat.isDirectory()) {
|
|
12
|
-
if (name === "node_modules" || name === "dist" || name === ".next") {
|
|
13
|
-
continue;
|
|
14
|
-
}
|
|
15
|
-
entries.push(...collectTsFiles(path));
|
|
16
|
-
} else if (name.endsWith(".ts") && !name.endsWith(".d.ts")) {
|
|
17
|
-
entries.push(path);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return entries;
|
|
21
|
-
}
|
|
22
|
-
function readSource(filePath) {
|
|
23
|
-
const text = readFileSync(filePath, "utf8");
|
|
24
|
-
return {
|
|
25
|
-
filePath,
|
|
26
|
-
text,
|
|
27
|
-
sourceFile: ts.createSourceFile(filePath, text, ts.ScriptTarget.Latest, true)
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function walk(node, visit) {
|
|
31
|
-
visit(node);
|
|
32
|
-
node.forEachChild((child) => walk(child, visit));
|
|
33
|
-
}
|
|
34
|
-
function isDbCall(node, method) {
|
|
35
|
-
if (!ts.isCallExpression(node)) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
const expression = node.expression;
|
|
39
|
-
if (!ts.isPropertyAccessExpression(expression)) {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
if (expression.name.text !== method) {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
return expression.expression.getText().endsWith(".db");
|
|
46
|
-
}
|
|
47
|
-
function lineRef(unit, node) {
|
|
48
|
-
const { line } = unit.sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
|
49
|
-
return `${unit.filePath}:${line + 1}`;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// src/manifests/invariants/inv-1-beliefs-append-only.ts
|
|
53
|
-
function isBeliefWriteCandidate(node) {
|
|
54
|
-
const [target, patch] = node.arguments;
|
|
55
|
-
const targetText = target?.getText() ?? "";
|
|
56
|
-
const patchText = patch?.getText() ?? "";
|
|
57
|
-
if (!/belief/i.test(targetText)) {
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
return /canonicalText|formulation|confidence|beliefStatus/.test(patchText);
|
|
61
|
-
}
|
|
62
|
-
var INV_1_BELIEFS_APPEND_ONLY = {
|
|
63
|
-
invariant: "INV-1: beliefs append-only",
|
|
64
|
-
description: "Scored beliefs cannot be patched or deleted; they must fork.",
|
|
65
|
-
checker: "ast",
|
|
66
|
-
severity: "block_publish",
|
|
67
|
-
evaluate: async (ctx) => {
|
|
68
|
-
const root = join(ctx.repoRoot, "packages/reasoning-kernel/src/adapters");
|
|
69
|
-
const violations = [];
|
|
70
|
-
for (const filePath of collectTsFiles(root)) {
|
|
71
|
-
if (filePath.endsWith(".test.ts")) {
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
const unit = readSource(filePath);
|
|
75
|
-
walk(unit.sourceFile, (node) => {
|
|
76
|
-
if (isDbCall(node, "patch") && isBeliefWriteCandidate(node)) {
|
|
77
|
-
violations.push(lineRef(unit, node));
|
|
78
|
-
}
|
|
79
|
-
if (isDbCall(node, "delete") && /belief/i.test(node.getText())) {
|
|
80
|
-
violations.push(lineRef(unit, node));
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
return violations.length === 0 ? { status: "passed", evidenceRefs: [] } : {
|
|
85
|
-
status: "failed",
|
|
86
|
-
evidenceRefs: violations,
|
|
87
|
-
reason: `${violations.length} unwrapped belief writes found`
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export { INV_1_BELIEFS_APPEND_ONLY };
|
|
93
|
-
//# sourceMappingURL=inv-1-beliefs-append-only.js.map
|
|
94
|
-
//# sourceMappingURL=inv-1-beliefs-append-only.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/manifests/invariants/ast-utils.ts","../../../src/manifests/invariants/inv-1-beliefs-append-only.ts"],"names":["join"],"mappings":";;;;;AAUO,SAAS,eAAe,IAAA,EAAwB;AACrD,EAAA,MAAM,UAAoB,EAAC;AAC3B,EAAA,KAAA,MAAW,IAAA,IAAQ,WAAA,CAAY,IAAI,CAAA,EAAG;AACpC,IAAA,MAAM,IAAA,GAAO,IAAA,CAAK,IAAA,EAAM,IAAI,CAAA;AAC5B,IAAA,MAAM,IAAA,GAAO,SAAS,IAAI,CAAA;AAC1B,IAAA,IAAI,IAAA,CAAK,aAAY,EAAG;AACtB,MAAA,IAAI,IAAA,KAAS,cAAA,IAAkB,IAAA,KAAS,MAAA,IAAU,SAAS,OAAA,EAAS;AAClE,QAAA;AAAA,MACF;AACA,MAAA,OAAA,CAAQ,IAAA,CAAK,GAAG,cAAA,CAAe,IAAI,CAAC,CAAA;AAAA,IACtC,CAAA,MAAA,IAAW,KAAK,QAAA,CAAS,KAAK,KAAK,CAAC,IAAA,CAAK,QAAA,CAAS,OAAO,CAAA,EAAG;AAC1D,MAAA,OAAA,CAAQ,KAAK,IAAI,CAAA;AAAA,IACnB;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT;AAEO,SAAS,WAAW,QAAA,EAA8B;AACvD,EAAA,MAAM,IAAA,GAAO,YAAA,CAAa,QAAA,EAAU,MAAM,CAAA;AAC1C,EAAA,OAAO;A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AAW,CAAA,GACzB,EAAE,QAAQ,QAAA,EAAU,YAAA,EAAc,EAAC,EAAE,GACrC;AAAA,MACE,MAAA,EAAQ,QAAA;AAAA,MACR,YAAA,EAAc,UAAA;AAAA,MACd,MAAA,EAAQ,CAAA,EAAG,UAAA,CAAW,MAAM,CAAA,8BAAA;AAAA,KAC9B;AAAA,EACN;AACF","file":"inv-1-beliefs-append-only.js","sourcesContent":["import { readFileSync, readdirSync, statSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport ts from \"typescript\";\n\nexport type SourceUnit = {\n filePath: string;\n text: string;\n sourceFile: ts.SourceFile;\n};\n\nexport function collectTsFiles(root: string): string[] {\n const entries: string[] = [];\n for (const name of readdirSync(root)) {\n const path = join(root, name);\n const stat = statSync(path);\n if (stat.isDirectory()) {\n if (name === \"node_modules\" || name === \"dist\" || name === \".next\") {\n continue;\n }\n entries.push(...collectTsFiles(path));\n } else if (name.endsWith(\".ts\") && !name.endsWith(\".d.ts\")) {\n entries.push(path);\n }\n }\n return entries;\n}\n\nexport function readSource(filePath: string): SourceUnit {\n const text = readFileSync(filePath, \"utf8\");\n return {\n filePath,\n text,\n sourceFile: ts.createSourceFile(filePath, text, ts.ScriptTarget.Latest, true),\n };\n}\n\nexport function walk(node: ts.Node, visit: (node: ts.Node) => void): void {\n visit(node);\n node.forEachChild((child) => walk(child, visit));\n}\n\nexport function isDbCall(node: ts.Node, method: string): node is ts.CallExpression {\n if (!ts.isCallExpression(node)) {\n return false;\n }\n const expression = node.expression;\n if (!ts.isPropertyAccessExpression(expression)) {\n return false;\n }\n if (expression.name.text !== method) {\n return false;\n }\n return expression.expression.getText().endsWith(\".db\");\n}\n\nexport function lineRef(unit: SourceUnit, node: ts.Node): string {\n const { line } = unit.sourceFile.getLineAndCharacterOfPosition(node.getStart());\n return `${unit.filePath}:${line + 1}`;\n}\n","import { join } from \"node:path\";\nimport ts from \"typescript\";\nimport type { InvariantRule } from \"../invariant-manifest.js\";\nimport { collectTsFiles, isDbCall, lineRef, readSource, walk } from \"./ast-utils.js\";\n\nfunction isBeliefWriteCandidate(node: ts.CallExpression): boolean {\n const [target, patch] = node.arguments;\n const targetText = target?.getText() ?? \"\";\n const patchText = patch?.getText() ?? \"\";\n\n if (!/belief/i.test(targetText)) {\n return false;\n }\n\n return /canonicalText|formulation|confidence|beliefStatus/.test(patchText);\n}\n\nexport const INV_1_BELIEFS_APPEND_ONLY: InvariantRule = {\n invariant: \"INV-1: beliefs append-only\",\n description: \"Scored beliefs cannot be patched or deleted; they must fork.\",\n checker: \"ast\",\n severity: \"block_publish\",\n evaluate: async (ctx) => {\n const root = join(ctx.repoRoot, \"packages/reasoning-kernel/src/adapters\");\n const violations: string[] = [];\n\n for (const filePath of collectTsFiles(root)) {\n if (filePath.endsWith(\".test.ts\")) {\n continue;\n }\n const unit = readSource(filePath);\n walk(unit.sourceFile, (node) => {\n if (isDbCall(node, \"patch\") && isBeliefWriteCandidate(node)) {\n violations.push(lineRef(unit, node));\n }\n if (isDbCall(node, \"delete\") && /belief/i.test(node.getText())) {\n violations.push(lineRef(unit, node));\n }\n });\n }\n\n return violations.length === 0\n ? { status: \"passed\", evidenceRefs: [] }\n : {\n status: \"failed\",\n evidenceRefs: violations,\n reason: `${violations.length} unwrapped belief writes found`,\n };\n },\n};\n"]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { InvariantRule } from '../invariant-manifest.js';
|
|
2
|
-
import 'zod';
|
|
3
|
-
import '../../projections/index.js';
|
|
4
|
-
import '../../projections/projection-dsl.js';
|
|
5
|
-
import '../../projections/create-evidence.projection.js';
|
|
6
|
-
import '../../projections/list-beliefs.projection.js';
|
|
7
|
-
import '../../projections/list-tasks.projection.js';
|
|
8
|
-
import '../../projections/modulate-confidence.projection.js';
|
|
9
|
-
|
|
10
|
-
declare const INV_14_NO_SILENT_TRANSITIONS: InvariantRule;
|
|
11
|
-
|
|
12
|
-
export { INV_14_NO_SILENT_TRANSITIONS };
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { join } from 'path';
|
|
2
|
-
import { readdirSync, statSync, readFileSync } from 'fs';
|
|
3
|
-
import ts from 'typescript';
|
|
4
|
-
|
|
5
|
-
// src/manifests/invariants/inv-14-no-silent-transitions.ts
|
|
6
|
-
function collectTsFiles(root) {
|
|
7
|
-
const entries = [];
|
|
8
|
-
for (const name of readdirSync(root)) {
|
|
9
|
-
const path = join(root, name);
|
|
10
|
-
const stat = statSync(path);
|
|
11
|
-
if (stat.isDirectory()) {
|
|
12
|
-
if (name === "node_modules" || name === "dist" || name === ".next") {
|
|
13
|
-
continue;
|
|
14
|
-
}
|
|
15
|
-
entries.push(...collectTsFiles(path));
|
|
16
|
-
} else if (name.endsWith(".ts") && !name.endsWith(".d.ts")) {
|
|
17
|
-
entries.push(path);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return entries;
|
|
21
|
-
}
|
|
22
|
-
function readSource(filePath) {
|
|
23
|
-
const text = readFileSync(filePath, "utf8");
|
|
24
|
-
return {
|
|
25
|
-
filePath,
|
|
26
|
-
text,
|
|
27
|
-
sourceFile: ts.createSourceFile(filePath, text, ts.ScriptTarget.Latest, true)
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function walk(node, visit) {
|
|
31
|
-
visit(node);
|
|
32
|
-
node.forEachChild((child) => walk(child, visit));
|
|
33
|
-
}
|
|
34
|
-
function isDbCall(node, method) {
|
|
35
|
-
if (!ts.isCallExpression(node)) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
const expression = node.expression;
|
|
39
|
-
if (!ts.isPropertyAccessExpression(expression)) {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
if (expression.name.text !== method) {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
return expression.expression.getText().endsWith(".db");
|
|
46
|
-
}
|
|
47
|
-
function lineRef(unit, node) {
|
|
48
|
-
const { line } = unit.sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
|
49
|
-
return `${unit.filePath}:${line + 1}`;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// src/manifests/invariants/inv-14-no-silent-transitions.ts
|
|
53
|
-
var EPISTEMIC_TABLES = [
|
|
54
|
-
"epistemicNodes",
|
|
55
|
-
"epistemicEdges",
|
|
56
|
-
"beliefConfidence",
|
|
57
|
-
"questions",
|
|
58
|
-
"answers",
|
|
59
|
-
"contradictions"
|
|
60
|
-
];
|
|
61
|
-
var INV_14_NO_SILENT_TRANSITIONS = {
|
|
62
|
-
invariant: "INV-14: no silent state transitions",
|
|
63
|
-
description: "Epistemic state transitions must co-locate an epistemicAudit insert in the same implementation file.",
|
|
64
|
-
checker: "ast",
|
|
65
|
-
severity: "block_publish",
|
|
66
|
-
evaluate: async (ctx) => {
|
|
67
|
-
const root = join(ctx.repoRoot, "packages/reasoning-kernel/src/adapters");
|
|
68
|
-
const violations = [];
|
|
69
|
-
for (const filePath of collectTsFiles(root)) {
|
|
70
|
-
if (filePath.endsWith(".test.ts")) {
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
const unit = readSource(filePath);
|
|
74
|
-
if (unit.text.includes("epistemicAudit")) {
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
walk(unit.sourceFile, (node) => {
|
|
78
|
-
if (!isDbCall(node, "patch")) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
const text = node.getText();
|
|
82
|
-
const touchesEpistemicState = EPISTEMIC_TABLES.some((table) => text.includes(`"${table}"`)) || /\b(belief|question|answer|contradiction|edge)\w*Id\b/i.test(text);
|
|
83
|
-
const carriesAuditIntent = /\b(epistemicAudit|rationale|reason|audit)\b/i.test(text);
|
|
84
|
-
if (touchesEpistemicState && !carriesAuditIntent) {
|
|
85
|
-
violations.push(lineRef(unit, node));
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
return violations.length === 0 ? { status: "passed", evidenceRefs: [] } : {
|
|
90
|
-
status: "failed",
|
|
91
|
-
evidenceRefs: violations,
|
|
92
|
-
reason: `${violations.length} epistemic writes lack local audit evidence`
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
export { INV_14_NO_SILENT_TRANSITIONS };
|
|
98
|
-
//# sourceMappingURL=inv-14-no-silent-transitions.js.map
|
|
99
|
-
//# sourceMappingURL=inv-14-no-silent-transitions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/manifests/invariants/ast-utils.ts","../../../src/manifests/invariants/inv-14-no-silent-transitions.ts"],"names":["join"],"mappings":";;;;;AAUO,SAAS,eAAe,IAAA,EAAwB;AACrD,EAAA,MAAM,UAAoB,EAAC;AAC3B,EAAA,KAAA,MAAW,IAAA,IAAQ,WAAA,CAAY,IAAI,CAAA,EAAG;AACpC,IAAA,MAAM,IAAA,GAAO,IAAA,CAAK,IAAA,EAAM,IAAI,CAAA;AAC5B,IAAA,MAAM,IAAA,GAAO,SAAS,IAAI,CAAA;AAC1B,IAAA,IAAI,IAAA,CAAK,aAAY,EAAG;AACtB,MAAA,IAAI,IAAA,KAAS,cAAA,IAAkB,IAAA,KAAS,MAAA,IAAU,SAAS,OAAA,EAAS;AAClE,QAAA;AAAA,MACF;AACA,MAAA,OAAA,CAAQ,IAAA,CAAK,GAAG,cAAA,CAAe,IAAI,CAAC,CAAA;AAAA,IACtC,CAAA,MAAA,IAAW,KAAK,QAAA,CAAS,KAAK,KAAK,CAAC,IAAA,CAAK,QAAA,CAAS,OAAO,CAAA,EAAG;AAC1D,MAAA,OAAA,CAAQ,KAAK,IAAI,CAAA;AAAA,IACnB;AAAA,EACF;AACA,EAAA,OAAO,OAAA;AACT;AAEO,SAAS,WAAW,QAAA,EAA8B;AACvD,EAAA,MAAM,IAAA,GAAO,YAAA,CAAa,QAAA,EAAU,MAAM,CAAA;AAC1C,EAAA,OAAO;AAAA,IACL,QAAA;AAAA,IACA,IAAA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,YAAA,EAAc,EAAC,EAAE,GACrC;AAAA,MACE,MAAA,EAAQ,QAAA;AAAA,MACR,YAAA,EAAc,UAAA;AAAA,MACd,MAAA,EAAQ,CAAA,EAAG,UAAA,CAAW,MAAM,CAAA,2CAAA;AAAA,KAC9B;AAAA,EACN;AACF","file":"inv-14-no-silent-transitions.js","sourcesContent":["import { readFileSync, readdirSync, statSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport ts from \"typescript\";\n\nexport type SourceUnit = {\n filePath: string;\n text: string;\n sourceFile: ts.SourceFile;\n};\n\nexport function collectTsFiles(root: string): string[] {\n const entries: string[] = [];\n for (const name of readdirSync(root)) {\n const path = join(root, name);\n const stat = statSync(path);\n if (stat.isDirectory()) {\n if (name === \"node_modules\" || name === \"dist\" || name === \".next\") {\n continue;\n }\n entries.push(...collectTsFiles(path));\n } else if (name.endsWith(\".ts\") && !name.endsWith(\".d.ts\")) {\n entries.push(path);\n }\n }\n return entries;\n}\n\nexport function readSource(filePath: string): SourceUnit {\n const text = readFileSync(filePath, \"utf8\");\n return {\n filePath,\n text,\n sourceFile: ts.createSourceFile(filePath, text, ts.ScriptTarget.Latest, true),\n };\n}\n\nexport function walk(node: ts.Node, visit: (node: ts.Node) => void): void {\n visit(node);\n node.forEachChild((child) => walk(child, visit));\n}\n\nexport function isDbCall(node: ts.Node, method: string): node is ts.CallExpression {\n if (!ts.isCallExpression(node)) {\n return false;\n }\n const expression = node.expression;\n if (!ts.isPropertyAccessExpression(expression)) {\n return false;\n }\n if (expression.name.text !== method) {\n return false;\n }\n return expression.expression.getText().endsWith(\".db\");\n}\n\nexport function lineRef(unit: SourceUnit, node: ts.Node): string {\n const { line } = unit.sourceFile.getLineAndCharacterOfPosition(node.getStart());\n return `${unit.filePath}:${line + 1}`;\n}\n","import { join } from \"node:path\";\nimport type { InvariantRule } from \"../invariant-manifest.js\";\nimport { collectTsFiles, isDbCall, lineRef, readSource, walk } from \"./ast-utils.js\";\n\nconst EPISTEMIC_TABLES = [\n \"epistemicNodes\",\n \"epistemicEdges\",\n \"beliefConfidence\",\n \"questions\",\n \"answers\",\n \"contradictions\",\n];\n\nexport const INV_14_NO_SILENT_TRANSITIONS: InvariantRule = {\n invariant: \"INV-14: no silent state transitions\",\n description:\n \"Epistemic state transitions must co-locate an epistemicAudit insert in the same implementation file.\",\n checker: \"ast\",\n severity: \"block_publish\",\n evaluate: async (ctx) => {\n const root = join(ctx.repoRoot, \"packages/reasoning-kernel/src/adapters\");\n const violations: string[] = [];\n\n for (const filePath of collectTsFiles(root)) {\n if (filePath.endsWith(\".test.ts\")) {\n continue;\n }\n const unit = readSource(filePath);\n if (unit.text.includes(\"epistemicAudit\")) {\n continue;\n }\n\n walk(unit.sourceFile, (node) => {\n if (!isDbCall(node, \"patch\")) {\n return;\n }\n const text = node.getText();\n const touchesEpistemicState =\n EPISTEMIC_TABLES.some((table) => text.includes(`\"${table}\"`)) ||\n /\\b(belief|question|answer|contradiction|edge)\\w*Id\\b/i.test(text);\n const carriesAuditIntent =\n /\\b(epistemicAudit|rationale|reason|audit)\\b/i.test(text);\n if (touchesEpistemicState && !carriesAuditIntent) {\n violations.push(lineRef(unit, node));\n }\n });\n }\n\n return violations.length === 0\n ? { status: \"passed\", evidenceRefs: [] }\n : {\n status: \"failed\",\n evidenceRefs: violations,\n reason: `${violations.length} epistemic writes lack local audit evidence`,\n };\n },\n};\n"]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { InvariantRule } from '../invariant-manifest.js';
|
|
2
|
-
import 'zod';
|
|
3
|
-
import '../../projections/index.js';
|
|
4
|
-
import '../../projections/projection-dsl.js';
|
|
5
|
-
import '../../projections/create-evidence.projection.js';
|
|
6
|
-
import '../../projections/list-beliefs.projection.js';
|
|
7
|
-
import '../../projections/list-tasks.projection.js';
|
|
8
|
-
import '../../projections/modulate-confidence.projection.js';
|
|
9
|
-
|
|
10
|
-
declare const MANIFEST_1_PROJECTIONS_DECLARE_AUDIT: InvariantRule;
|
|
11
|
-
|
|
12
|
-
export { MANIFEST_1_PROJECTIONS_DECLARE_AUDIT };
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// src/manifests/invariants/manifest-1-projections-declare-audit.ts
|
|
2
|
-
function objectShape(schema) {
|
|
3
|
-
let current = schema;
|
|
4
|
-
while (current._def.typeName === "ZodEffects") {
|
|
5
|
-
current = current._def.schema;
|
|
6
|
-
}
|
|
7
|
-
const def = current._def;
|
|
8
|
-
if (typeof def.shape === "function") {
|
|
9
|
-
return def.shape();
|
|
10
|
-
}
|
|
11
|
-
if (def.shape && typeof def.shape === "object") {
|
|
12
|
-
return def.shape;
|
|
13
|
-
}
|
|
14
|
-
return void 0;
|
|
15
|
-
}
|
|
16
|
-
var MANIFEST_1_PROJECTIONS_DECLARE_AUDIT = {
|
|
17
|
-
invariant: "MANIFEST-1: kernel projections declare epistemicAudit",
|
|
18
|
-
description: "Kernel mutation projections must carry a rationale so audit evidence can explain the transition.",
|
|
19
|
-
checker: "manifest",
|
|
20
|
-
severity: "block_publish",
|
|
21
|
-
evaluate: async (ctx) => {
|
|
22
|
-
const violations = [];
|
|
23
|
-
for (const [name, projection] of Object.entries(ctx.projections)) {
|
|
24
|
-
if (!/^(create|modulate|fork|update)_/.test(name)) {
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
const shape = objectShape(projection.inputSchema);
|
|
28
|
-
if (!shape || !("rationale" in shape)) {
|
|
29
|
-
violations.push(`projection '${name}' missing 'rationale' field`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return violations.length === 0 ? { status: "passed", evidenceRefs: [] } : {
|
|
33
|
-
status: "failed",
|
|
34
|
-
evidenceRefs: violations,
|
|
35
|
-
reason: `${violations.length} projections missing audit rationale`
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export { MANIFEST_1_PROJECTIONS_DECLARE_AUDIT };
|
|
41
|
-
//# sourceMappingURL=manifest-1-projections-declare-audit.js.map
|
|
42
|
-
//# sourceMappingURL=manifest-1-projections-declare-audit.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/manifests/invariants/manifest-1-projections-declare-audit.ts"],"names":[],"mappings":";AAGA,SAAS,YAAY,MAAA,EAA2D;AAC9E,EAAA,IAAI,OAAA,GAAU,MAAA;AACd,EAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,QAAA,KAAa,YAAA,EAAc;AAC7C,IAAA,OAAA,GAAW,QAAQ,IAAA,CAAkC,MAAA;AAAA,EACvD;AAEA,EAAA,MAAM,MAAM,OAAA,CAAQ,IAAA;AACpB,EAAA,IAAI,OAAO,GAAA,CAAI,KAAA,KAAU,UAAA,EAAY;AACnC,IAAA,OAAO,IAAI,KAAA,EAAM;AAAA,EACnB;AACA,EAAA,IAAI,GAAA,CAAI,KAAA,IAAS,OAAO,GAAA,CAAI,UAAU,QAAA,EAAU;AAC9C,IAAA,OAAO,GAAA,CAAI,KAAA;AAAA,EACb;AACA,EAAA,OAAO,MAAA;AACT;AAEO,IAAM,oCAAA,GAAsD;AAAA,EACjE,SAAA,EAAW,uDAAA;AAAA,EACX,WAAA,EACE,kGAAA;AAAA,EACF,OAAA,EAAS,UAAA;AAAA,EACT,QAAA,EAAU,eAAA;AAAA,EACV,QAAA,EAAU,OAAO,GAAA,KAAQ;AACvB,IAAA,MAAM,aAAuB,EAAC;AAE9B,IAAA,KAAA,MAAW,CAAC,MAAM,UAAU,CAAA,IAAK,OAAO,OAAA,CAAQ,GAAA,CAAI,WAAW,CAAA,EAAG;AAChE,MAAA,IAAI,CAAC,iCAAA,CAAkC,IAAA,CAAK,IAAI,CAAA,EAAG;AACjD,QAAA;AAAA,MACF;AACA,MAAA,MAAM,KAAA,GAAQ,WAAA,CAAY,UAAA,CAAW,WAAW,CAAA;AAChD,MAAA,IAAI,CAAC,KAAA,IAAS,EAAE,WAAA,IAAe,KAAA,CAAA,EAAQ;AACrC,QAAA,UAAA,CAAW,IAAA,CAAK,CAAA,YAAA,EAAe,IAAI,CAAA,2BAAA,CAA6B,CAAA;AAAA,MAClE;AAAA,IACF;AAEA,IAAA,OAAO,UAAA,CAAW,WAAW,CAAA,GACzB,EAAE,QAAQ,QAAA,EAAU,YAAA,EAAc,EAAC,EAAE,GACrC;AAAA,MACE,MAAA,EAAQ,QAAA;AAAA,MACR,YAAA,EAAc,UAAA;AAAA,MACd,MAAA,EAAQ,CAAA,EAAG,UAAA,CAAW,MAAM,CAAA,oCAAA;AAAA,KAC9B;AAAA,EACN;AACF","file":"manifest-1-projections-declare-audit.js","sourcesContent":["import type { z } from \"zod\";\nimport type { InvariantRule } from \"../invariant-manifest.js\";\n\nfunction objectShape(schema: z.ZodTypeAny): Record<string, unknown> | undefined {\n let current = schema;\n while (current._def.typeName === \"ZodEffects\") {\n current = (current._def as { schema: z.ZodTypeAny }).schema;\n }\n\n const def = current._def as { shape?: unknown };\n if (typeof def.shape === \"function\") {\n return def.shape() as Record<string, unknown>;\n }\n if (def.shape && typeof def.shape === \"object\") {\n return def.shape as Record<string, unknown>;\n }\n return undefined;\n}\n\nexport const MANIFEST_1_PROJECTIONS_DECLARE_AUDIT: InvariantRule = {\n invariant: \"MANIFEST-1: kernel projections declare epistemicAudit\",\n description:\n \"Kernel mutation projections must carry a rationale so audit evidence can explain the transition.\",\n checker: \"manifest\",\n severity: \"block_publish\",\n evaluate: async (ctx) => {\n const violations: string[] = [];\n\n for (const [name, projection] of Object.entries(ctx.projections)) {\n if (!/^(create|modulate|fork|update)_/.test(name)) {\n continue;\n }\n const shape = objectShape(projection.inputSchema);\n if (!shape || !(\"rationale\" in shape)) {\n violations.push(`projection '${name}' missing 'rationale' field`);\n }\n }\n\n return violations.length === 0\n ? { status: \"passed\", evidenceRefs: [] }\n : {\n status: \"failed\",\n evidenceRefs: violations,\n reason: `${violations.length} projections missing audit rationale`,\n };\n },\n};\n"]}
|