@paraharness/fs 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +62 -2
- package/dist/builders/create-fs-allow-only-guard-builder.d.ts +13 -0
- package/dist/builders/create-fs-allow-only-guard-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-allow-only-guard-builder.js +22 -0
- package/dist/builders/create-fs-allow-only-guard-builder.js.map +1 -0
- package/dist/builders/create-fs-allow-write-globs-lease-delta.d.ts +13 -0
- package/dist/builders/create-fs-allow-write-globs-lease-delta.d.ts.map +1 -0
- package/dist/builders/create-fs-allow-write-globs-lease-delta.js +20 -0
- package/dist/builders/create-fs-allow-write-globs-lease-delta.js.map +1 -0
- package/dist/builders/create-fs-boundary-guard-builder.d.ts +15 -0
- package/dist/builders/create-fs-boundary-guard-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-boundary-guard-builder.js +20 -0
- package/dist/builders/create-fs-boundary-guard-builder.js.map +1 -0
- package/dist/builders/create-fs-coding-tools.d.ts +21 -0
- package/dist/builders/create-fs-coding-tools.d.ts.map +1 -0
- package/dist/builders/create-fs-coding-tools.js +25 -0
- package/dist/builders/create-fs-coding-tools.js.map +1 -0
- package/dist/builders/create-fs-glob-matcher-builder.d.ts +14 -0
- package/dist/builders/create-fs-glob-matcher-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-glob-matcher-builder.js +24 -0
- package/dist/builders/create-fs-glob-matcher-builder.js.map +1 -0
- package/dist/builders/create-fs-glob-source-builder.d.ts +13 -0
- package/dist/builders/create-fs-glob-source-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-glob-source-builder.js +22 -0
- package/dist/builders/create-fs-glob-source-builder.js.map +1 -0
- package/dist/builders/create-fs-in-partition-predicate.d.ts +16 -0
- package/dist/builders/create-fs-in-partition-predicate.d.ts.map +1 -0
- package/dist/builders/create-fs-in-partition-predicate.js +25 -0
- package/dist/builders/create-fs-in-partition-predicate.js.map +1 -0
- package/dist/builders/create-fs-jsonl-lesson-store-builder.d.ts +29 -0
- package/dist/builders/create-fs-jsonl-lesson-store-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-jsonl-lesson-store-builder.js +30 -0
- package/dist/builders/create-fs-jsonl-lesson-store-builder.js.map +1 -0
- package/dist/builders/create-fs-max-files-mutated-builder.d.ts +13 -0
- package/dist/builders/create-fs-max-files-mutated-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-max-files-mutated-builder.js +21 -0
- package/dist/builders/create-fs-max-files-mutated-builder.js.map +1 -0
- package/dist/builders/create-fs-partition-map.d.ts +16 -0
- package/dist/builders/create-fs-partition-map.d.ts.map +1 -0
- package/dist/builders/create-fs-partition-map.js +34 -0
- package/dist/builders/create-fs-partition-map.js.map +1 -0
- package/dist/builders/create-fs-protect-guard-builder.d.ts +13 -0
- package/dist/builders/create-fs-protect-guard-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-protect-guard-builder.js +22 -0
- package/dist/builders/create-fs-protect-guard-builder.js.map +1 -0
- package/dist/builders/create-fs-read-only-guard-builder.d.ts +11 -0
- package/dist/builders/create-fs-read-only-guard-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-read-only-guard-builder.js +15 -0
- package/dist/builders/create-fs-read-only-guard-builder.js.map +1 -0
- package/dist/builders/create-fs-read-only-tools.d.ts +15 -0
- package/dist/builders/create-fs-read-only-tools.d.ts.map +1 -0
- package/dist/builders/create-fs-read-only-tools.js +23 -0
- package/dist/builders/create-fs-read-only-tools.js.map +1 -0
- package/dist/builders/create-fs-regex-check-builder.d.ts +34 -0
- package/dist/builders/create-fs-regex-check-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-regex-check-builder.js +58 -0
- package/dist/builders/create-fs-regex-check-builder.js.map +1 -0
- package/dist/builders/create-fs-require-read-before-write-guard-builder.d.ts +11 -0
- package/dist/builders/create-fs-require-read-before-write-guard-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-require-read-before-write-guard-builder.js +15 -0
- package/dist/builders/create-fs-require-read-before-write-guard-builder.js.map +1 -0
- package/dist/builders/create-fs-scoped-write-guard-builder.d.ts +15 -0
- package/dist/builders/create-fs-scoped-write-guard-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-scoped-write-guard-builder.js +20 -0
- package/dist/builders/create-fs-scoped-write-guard-builder.js.map +1 -0
- package/dist/builders/create-fs-secret-literals-guard-builder.d.ts +13 -0
- package/dist/builders/create-fs-secret-literals-guard-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-secret-literals-guard-builder.js +21 -0
- package/dist/builders/create-fs-secret-literals-guard-builder.js.map +1 -0
- package/dist/builders/create-fs-telemetry-builder.d.ts +11 -0
- package/dist/builders/create-fs-telemetry-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-telemetry-builder.js +17 -0
- package/dist/builders/create-fs-telemetry-builder.js.map +1 -0
- package/dist/builders/create-fs-text-source-builder.d.ts +14 -0
- package/dist/builders/create-fs-text-source-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-text-source-builder.js +23 -0
- package/dist/builders/create-fs-text-source-builder.js.map +1 -0
- package/dist/builders/create-fs-write-guard-builder.d.ts +29 -0
- package/dist/builders/create-fs-write-guard-builder.d.ts.map +1 -0
- package/dist/builders/create-fs-write-guard-builder.js +29 -0
- package/dist/builders/create-fs-write-guard-builder.js.map +1 -0
- package/dist/builders/fs-namespace-contract.d.ts +187 -0
- package/dist/builders/fs-namespace-contract.d.ts.map +1 -0
- package/dist/builders/fs-namespace-contract.js +2 -0
- package/dist/builders/fs-namespace-contract.js.map +1 -0
- package/dist/builders/fs-namespace.d.ts +10 -0
- package/dist/builders/fs-namespace.d.ts.map +1 -0
- package/dist/builders/fs-namespace.js +50 -0
- package/dist/builders/fs-namespace.js.map +1 -0
- package/dist/builders/internal/build-fs-tool-nodes.d.ts +62 -0
- package/dist/builders/internal/build-fs-tool-nodes.d.ts.map +1 -0
- package/dist/builders/internal/build-fs-tool-nodes.js +107 -0
- package/dist/builders/internal/build-fs-tool-nodes.js.map +1 -0
- package/dist/builders/internal/fs-tool-input.schema.d.ts +80 -0
- package/dist/builders/internal/fs-tool-input.schema.d.ts.map +1 -0
- package/dist/builders/internal/fs-tool-input.schema.js +56 -0
- package/dist/builders/internal/fs-tool-input.schema.js.map +1 -0
- package/dist/executors/create-fs-executors.d.ts +11 -0
- package/dist/executors/create-fs-executors.d.ts.map +1 -0
- package/dist/executors/create-fs-executors.js +57 -0
- package/dist/executors/create-fs-executors.js.map +1 -0
- package/dist/executors/fs-check-tripwire-and-telemetry.d.ts +45 -0
- package/dist/executors/fs-check-tripwire-and-telemetry.d.ts.map +1 -0
- package/dist/executors/fs-check-tripwire-and-telemetry.js +99 -0
- package/dist/executors/fs-check-tripwire-and-telemetry.js.map +1 -0
- package/dist/executors/fs-executors.constants.d.ts +10 -0
- package/dist/executors/fs-executors.constants.d.ts.map +1 -0
- package/dist/executors/fs-executors.constants.js +10 -0
- package/dist/executors/fs-executors.constants.js.map +1 -0
- package/dist/executors/fs-glob-effect-matcher.d.ts +15 -0
- package/dist/executors/fs-glob-effect-matcher.d.ts.map +1 -0
- package/dist/executors/fs-glob-effect-matcher.js +37 -0
- package/dist/executors/fs-glob-effect-matcher.js.map +1 -0
- package/dist/executors/fs-path-guard-executors.d.ts +51 -0
- package/dist/executors/fs-path-guard-executors.d.ts.map +1 -0
- package/dist/executors/fs-path-guard-executors.js +60 -0
- package/dist/executors/fs-path-guard-executors.js.map +1 -0
- package/dist/executors/fs-read-tool-drivers.d.ts +35 -0
- package/dist/executors/fs-read-tool-drivers.d.ts.map +1 -0
- package/dist/executors/fs-read-tool-drivers.js +73 -0
- package/dist/executors/fs-read-tool-drivers.js.map +1 -0
- package/dist/executors/fs-source-executors.d.ts +31 -0
- package/dist/executors/fs-source-executors.d.ts.map +1 -0
- package/dist/executors/fs-source-executors.js +55 -0
- package/dist/executors/fs-source-executors.js.map +1 -0
- package/dist/executors/fs-tool-effect.d.ts +33 -0
- package/dist/executors/fs-tool-effect.d.ts.map +1 -0
- package/dist/executors/fs-tool-effect.js +2 -0
- package/dist/executors/fs-tool-effect.js.map +1 -0
- package/dist/executors/fs-write-guard-executors.d.ts +55 -0
- package/dist/executors/fs-write-guard-executors.d.ts.map +1 -0
- package/dist/executors/fs-write-guard-executors.js +64 -0
- package/dist/executors/fs-write-guard-executors.js.map +1 -0
- package/dist/executors/fs-write-tool-drivers.d.ts +24 -0
- package/dist/executors/fs-write-tool-drivers.d.ts.map +1 -0
- package/dist/executors/fs-write-tool-drivers.js +44 -0
- package/dist/executors/fs-write-tool-drivers.js.map +1 -0
- package/dist/executors/internal/add-mutated-paths-from-effects.d.ts +9 -0
- package/dist/executors/internal/add-mutated-paths-from-effects.d.ts.map +1 -0
- package/dist/executors/internal/add-mutated-paths-from-effects.js +24 -0
- package/dist/executors/internal/add-mutated-paths-from-effects.js.map +1 -0
- package/dist/executors/internal/check-paths-exist-at-base-ref.d.ts +12 -0
- package/dist/executors/internal/check-paths-exist-at-base-ref.d.ts.map +1 -0
- package/dist/executors/internal/check-paths-exist-at-base-ref.js +59 -0
- package/dist/executors/internal/check-paths-exist-at-base-ref.js.map +1 -0
- package/dist/executors/internal/collect-mutated-paths-since-base-ref.d.ts +13 -0
- package/dist/executors/internal/collect-mutated-paths-since-base-ref.d.ts.map +1 -0
- package/dist/executors/internal/collect-mutated-paths-since-base-ref.js +42 -0
- package/dist/executors/internal/collect-mutated-paths-since-base-ref.js.map +1 -0
- package/dist/executors/internal/collect-read-paths-from-effects.d.ts +12 -0
- package/dist/executors/internal/collect-read-paths-from-effects.d.ts.map +1 -0
- package/dist/executors/internal/collect-read-paths-from-effects.js +26 -0
- package/dist/executors/internal/collect-read-paths-from-effects.js.map +1 -0
- package/dist/executors/internal/compile-active-lease-write-matcher.d.ts +14 -0
- package/dist/executors/internal/compile-active-lease-write-matcher.d.ts.map +1 -0
- package/dist/executors/internal/compile-active-lease-write-matcher.js +50 -0
- package/dist/executors/internal/compile-active-lease-write-matcher.js.map +1 -0
- package/dist/executors/internal/compile-glob-or-exact-matcher.d.ts +12 -0
- package/dist/executors/internal/compile-glob-or-exact-matcher.d.ts.map +1 -0
- package/dist/executors/internal/compile-glob-or-exact-matcher.js +63 -0
- package/dist/executors/internal/compile-glob-or-exact-matcher.js.map +1 -0
- package/dist/executors/internal/compile-secret-patterns.d.ts +12 -0
- package/dist/executors/internal/compile-secret-patterns.d.ts.map +1 -0
- package/dist/executors/internal/compile-secret-patterns.js +27 -0
- package/dist/executors/internal/compile-secret-patterns.js.map +1 -0
- package/dist/executors/internal/create-effect-base-ref-path-lookup.d.ts +13 -0
- package/dist/executors/internal/create-effect-base-ref-path-lookup.d.ts.map +1 -0
- package/dist/executors/internal/create-effect-base-ref-path-lookup.js +33 -0
- package/dist/executors/internal/create-effect-base-ref-path-lookup.js.map +1 -0
- package/dist/executors/internal/create-fs-read-effect.d.ts +12 -0
- package/dist/executors/internal/create-fs-read-effect.d.ts.map +1 -0
- package/dist/executors/internal/create-fs-read-effect.js +22 -0
- package/dist/executors/internal/create-fs-read-effect.js.map +1 -0
- package/dist/executors/internal/create-fs-write-effect.d.ts +14 -0
- package/dist/executors/internal/create-fs-write-effect.d.ts.map +1 -0
- package/dist/executors/internal/create-fs-write-effect.js +24 -0
- package/dist/executors/internal/create-fs-write-effect.js.map +1 -0
- package/dist/executors/internal/describe-fs-edit-effects.d.ts +13 -0
- package/dist/executors/internal/describe-fs-edit-effects.d.ts.map +1 -0
- package/dist/executors/internal/describe-fs-edit-effects.js +31 -0
- package/dist/executors/internal/describe-fs-edit-effects.js.map +1 -0
- package/dist/executors/internal/describe-fs-write-effects.d.ts +13 -0
- package/dist/executors/internal/describe-fs-write-effects.d.ts.map +1 -0
- package/dist/executors/internal/describe-fs-write-effects.js +24 -0
- package/dist/executors/internal/describe-fs-write-effects.js.map +1 -0
- package/dist/executors/internal/enumerate-workspace-files-sync.d.ts +12 -0
- package/dist/executors/internal/enumerate-workspace-files-sync.d.ts.map +1 -0
- package/dist/executors/internal/enumerate-workspace-files-sync.js +52 -0
- package/dist/executors/internal/enumerate-workspace-files-sync.js.map +1 -0
- package/dist/executors/internal/enumerate-workspace-files.d.ts +13 -0
- package/dist/executors/internal/enumerate-workspace-files.d.ts.map +1 -0
- package/dist/executors/internal/enumerate-workspace-files.js +44 -0
- package/dist/executors/internal/enumerate-workspace-files.js.map +1 -0
- package/dist/executors/internal/evaluate-fs-allow-and-protect-guards.d.ts +28 -0
- package/dist/executors/internal/evaluate-fs-allow-and-protect-guards.d.ts.map +1 -0
- package/dist/executors/internal/evaluate-fs-allow-and-protect-guards.js +37 -0
- package/dist/executors/internal/evaluate-fs-allow-and-protect-guards.js.map +1 -0
- package/dist/executors/internal/evaluate-fs-content-and-read-guards.d.ts +20 -0
- package/dist/executors/internal/evaluate-fs-content-and-read-guards.d.ts.map +1 -0
- package/dist/executors/internal/evaluate-fs-content-and-read-guards.js +46 -0
- package/dist/executors/internal/evaluate-fs-content-and-read-guards.js.map +1 -0
- package/dist/executors/internal/evaluate-fs-write-and-boundary-guards.d.ts +31 -0
- package/dist/executors/internal/evaluate-fs-write-and-boundary-guards.d.ts.map +1 -0
- package/dist/executors/internal/evaluate-fs-write-and-boundary-guards.js +100 -0
- package/dist/executors/internal/evaluate-fs-write-and-boundary-guards.js.map +1 -0
- package/dist/executors/internal/execute-fs-edit-operation.d.ts +26 -0
- package/dist/executors/internal/execute-fs-edit-operation.d.ts.map +1 -0
- package/dist/executors/internal/execute-fs-edit-operation.js +25 -0
- package/dist/executors/internal/execute-fs-edit-operation.js.map +1 -0
- package/dist/executors/internal/execute-fs-write-operation.d.ts +22 -0
- package/dist/executors/internal/execute-fs-write-operation.d.ts.map +1 -0
- package/dist/executors/internal/execute-fs-write-operation.js +21 -0
- package/dist/executors/internal/execute-fs-write-operation.js.map +1 -0
- package/dist/executors/internal/extract-worktree-root-and-base-ref.d.ts +15 -0
- package/dist/executors/internal/extract-worktree-root-and-base-ref.d.ts.map +1 -0
- package/dist/executors/internal/extract-worktree-root-and-base-ref.js +24 -0
- package/dist/executors/internal/extract-worktree-root-and-base-ref.js.map +1 -0
- package/dist/executors/internal/filter-jailed-dirents.d.ts +25 -0
- package/dist/executors/internal/filter-jailed-dirents.d.ts.map +1 -0
- package/dist/executors/internal/filter-jailed-dirents.js +54 -0
- package/dist/executors/internal/filter-jailed-dirents.js.map +1 -0
- package/dist/executors/internal/fs-coding-tool-drivers.d.ts +38 -0
- package/dist/executors/internal/fs-coding-tool-drivers.d.ts.map +1 -0
- package/dist/executors/internal/fs-coding-tool-drivers.js +52 -0
- package/dist/executors/internal/fs-coding-tool-drivers.js.map +1 -0
- package/dist/executors/internal/fs-search-tool-drivers.d.ts +26 -0
- package/dist/executors/internal/fs-search-tool-drivers.d.ts.map +1 -0
- package/dist/executors/internal/fs-search-tool-drivers.js +37 -0
- package/dist/executors/internal/fs-search-tool-drivers.js.map +1 -0
- package/dist/executors/internal/glob-matcher-cache.constants.d.ts +20 -0
- package/dist/executors/internal/glob-matcher-cache.constants.d.ts.map +1 -0
- package/dist/executors/internal/glob-matcher-cache.constants.js +19 -0
- package/dist/executors/internal/glob-matcher-cache.constants.js.map +1 -0
- package/dist/executors/internal/grep-workspace-files.d.ts +23 -0
- package/dist/executors/internal/grep-workspace-files.d.ts.map +1 -0
- package/dist/executors/internal/grep-workspace-files.js +33 -0
- package/dist/executors/internal/grep-workspace-files.js.map +1 -0
- package/dist/executors/internal/project-violated-write-effects.d.ts +15 -0
- package/dist/executors/internal/project-violated-write-effects.d.ts.map +1 -0
- package/dist/executors/internal/project-violated-write-effects.js +67 -0
- package/dist/executors/internal/project-violated-write-effects.js.map +1 -0
- package/dist/executors/internal/resolve-jailed-worktree-path.d.ts +19 -0
- package/dist/executors/internal/resolve-jailed-worktree-path.d.ts.map +1 -0
- package/dist/executors/internal/resolve-jailed-worktree-path.js +101 -0
- package/dist/executors/internal/resolve-jailed-worktree-path.js.map +1 -0
- package/dist/executors/internal/secret-patterns.constants.d.ts +16 -0
- package/dist/executors/internal/secret-patterns.constants.d.ts.map +1 -0
- package/dist/executors/internal/secret-patterns.constants.js +30 -0
- package/dist/executors/internal/secret-patterns.constants.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/stores/fs-jsonl-lesson-store.d.ts +135 -0
- package/dist/stores/fs-jsonl-lesson-store.d.ts.map +1 -0
- package/dist/stores/fs-jsonl-lesson-store.js +155 -0
- package/dist/stores/fs-jsonl-lesson-store.js.map +1 -0
- package/dist/stores/internal/fs-jsonl-lesson-file-io.d.ts +129 -0
- package/dist/stores/internal/fs-jsonl-lesson-file-io.d.ts.map +1 -0
- package/dist/stores/internal/fs-jsonl-lesson-file-io.js +197 -0
- package/dist/stores/internal/fs-jsonl-lesson-file-io.js.map +1 -0
- package/dist/stores/internal/fs-lesson-definition-record.d.ts +19 -0
- package/dist/stores/internal/fs-lesson-definition-record.d.ts.map +1 -0
- package/dist/stores/internal/fs-lesson-definition-record.js +2 -0
- package/dist/stores/internal/fs-lesson-definition-record.js.map +1 -0
- package/dist/stores/internal/fs-lesson-lock-and-atomic-io.d.ts +51 -0
- package/dist/stores/internal/fs-lesson-lock-and-atomic-io.d.ts.map +1 -0
- package/dist/stores/internal/fs-lesson-lock-and-atomic-io.js +89 -0
- package/dist/stores/internal/fs-lesson-lock-and-atomic-io.js.map +1 -0
- package/dist/stores/internal/fs-lesson-relevance.d.ts +49 -0
- package/dist/stores/internal/fs-lesson-relevance.d.ts.map +1 -0
- package/dist/stores/internal/fs-lesson-relevance.js +113 -0
- package/dist/stores/internal/fs-lesson-relevance.js.map +1 -0
- package/dist/stores/internal/fs-lesson-stats-entry.d.ts +22 -0
- package/dist/stores/internal/fs-lesson-stats-entry.d.ts.map +1 -0
- package/dist/stores/internal/fs-lesson-stats-entry.js +2 -0
- package/dist/stores/internal/fs-lesson-stats-entry.js.map +1 -0
- package/package.json +72 -3
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import type { FsJsonlLessonStoreNode, LessonOutcome, LessonRecord, LessonStore } from '@paraharness/core';
|
|
2
|
+
/**
|
|
3
|
+
* Query parameters for {@link FsJsonlLessonStore.queryCandidates}.
|
|
4
|
+
*/
|
|
5
|
+
export interface FsQueryCandidatesParams {
|
|
6
|
+
/** Search query text extracted from actor input. */
|
|
7
|
+
readonly queryText: string;
|
|
8
|
+
/** Active task partitions. */
|
|
9
|
+
readonly partitions: readonly string[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Admission parameters for {@link FsJsonlLessonStore.admit}.
|
|
13
|
+
*/
|
|
14
|
+
export interface FsAdmitLessonParams {
|
|
15
|
+
/** Optional topology partition identifier. */
|
|
16
|
+
readonly partition?: string;
|
|
17
|
+
/** Preventative or prescriptive directive text. */
|
|
18
|
+
readonly directive: string;
|
|
19
|
+
/** Partition contract epoch at creation. */
|
|
20
|
+
readonly epochAtCreation: number;
|
|
21
|
+
/** Optional run identifier that admitted the lesson. */
|
|
22
|
+
readonly createdByRunId?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Single lesson outcome entry for {@link FsJsonlLessonStore.recordOutcomes}.
|
|
26
|
+
*/
|
|
27
|
+
export interface FsRecordOutcomeParams {
|
|
28
|
+
/** Target lesson identifier. */
|
|
29
|
+
readonly lessonId: string;
|
|
30
|
+
/** Recorded execution outcome (`'clean_pass'` or `'violated'`). */
|
|
31
|
+
readonly outcome: LessonOutcome;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Crash-safe hybrid filesystem `LessonStore` implementation (`fs.jsonlLessonStore`, `SPEC.md` §4.3).
|
|
35
|
+
*
|
|
36
|
+
* Resolves `definitionsDir`, `statsPath`, and `lockFile` against the immutable host repository
|
|
37
|
+
* root (Invariant 5), writes immutable `<definitionsDir>/<lessonId>.json` definition files on
|
|
38
|
+
* `admit()`, and updates mutable telemetry counters in `statsPath` under a `PQueue({ concurrency: 1 })`
|
|
39
|
+
* queue combined with `@paraharness/lockfile` and `write-file-atomic`.
|
|
40
|
+
*/
|
|
41
|
+
export declare class FsJsonlLessonStore implements LessonStore {
|
|
42
|
+
/** Absolute host-root directory path storing immutable `<lessonId>.json` definitions. */
|
|
43
|
+
private readonly definitionsDirPath;
|
|
44
|
+
/** Absolute host-root file path storing mutable lesson telemetry counters. */
|
|
45
|
+
private readonly statsFilePath;
|
|
46
|
+
/** Absolute host-root advisory lockfile path. */
|
|
47
|
+
private readonly lockFilePath;
|
|
48
|
+
/** Serialized in-process async mutex queue (`concurrency: 1`). */
|
|
49
|
+
private readonly mutexQueue;
|
|
50
|
+
/**
|
|
51
|
+
* Initializes an `FsJsonlLessonStore` bound to the host repository root (`SPEC.md` Invariant 5).
|
|
52
|
+
*
|
|
53
|
+
* Resolves all configured store paths relative to `hostRoot` (defaulting to `process.cwd()`).
|
|
54
|
+
*
|
|
55
|
+
* @param {FsJsonlLessonStoreNode} node - Passive lesson store AST node.
|
|
56
|
+
* @param {string} [hostRoot=process.cwd()] - Optional explicit host repository root directory.
|
|
57
|
+
*/
|
|
58
|
+
constructor(node: FsJsonlLessonStoreNode, hostRoot?: string);
|
|
59
|
+
/**
|
|
60
|
+
* Enqueues `operation` onto the in-process `PQueue` (`concurrency: 1`) and acquires the advisory file lock.
|
|
61
|
+
*
|
|
62
|
+
* Guarantees strict serialization across concurrent calls within the process and across processes.
|
|
63
|
+
*
|
|
64
|
+
* @template TResult Result type of the locked operation.
|
|
65
|
+
*
|
|
66
|
+
* @param {() => Promise<TResult>} operation - Critical section callback.
|
|
67
|
+
*
|
|
68
|
+
* @returns {Promise<TResult>} Result returned by `operation`.
|
|
69
|
+
*/
|
|
70
|
+
private enqueueLocked;
|
|
71
|
+
/**
|
|
72
|
+
* Queries non-retired candidate lessons and populates `relevanceScore` in `[0, 1]` via `MiniSearch`.
|
|
73
|
+
*
|
|
74
|
+
* Orders returned candidate lessons deterministically by descending `relevanceScore` and `id`.
|
|
75
|
+
*
|
|
76
|
+
* @param {FsQueryCandidatesParams} req - Query text and active partitions.
|
|
77
|
+
*
|
|
78
|
+
* @returns {Promise<readonly LessonRecord[]>} Frozen array of candidate lesson records.
|
|
79
|
+
*/
|
|
80
|
+
queryCandidates(req: FsQueryCandidatesParams): Promise<readonly LessonRecord[]>;
|
|
81
|
+
/**
|
|
82
|
+
* Admits a distilled lesson by writing an immutable `<definitionsDir>/<lessonId>.json` file.
|
|
83
|
+
*
|
|
84
|
+
* Deduplicates identical `(partition, directive)` pairs and initializes telemetry counters in `statsPath`.
|
|
85
|
+
*
|
|
86
|
+
* @param {FsAdmitLessonParams} lesson - Lesson definition to admit.
|
|
87
|
+
*
|
|
88
|
+
* @returns {Promise<string>} Assigned content-addressed `lessonId`.
|
|
89
|
+
*/
|
|
90
|
+
admit(lesson: FsAdmitLessonParams): Promise<string>;
|
|
91
|
+
/**
|
|
92
|
+
* Appends deduplicated step execution outcomes to `statsPath` and returns the updated lesson records.
|
|
93
|
+
*
|
|
94
|
+
* Increments `totalCleanPasses` and `totalViolated` counters without touching `<definitionsDir>/<lessonId>.json`.
|
|
95
|
+
*
|
|
96
|
+
* @param {readonly FsRecordOutcomeParams[]} outcomes - Batch of lesson outcomes.
|
|
97
|
+
*
|
|
98
|
+
* @returns {Promise<readonly LessonRecord[]>} Updated lesson records for the affected lessons.
|
|
99
|
+
*/
|
|
100
|
+
recordOutcomes(outcomes: readonly FsRecordOutcomeParams[]): Promise<readonly LessonRecord[]>;
|
|
101
|
+
/**
|
|
102
|
+
* Aligns `epochAtCreation` overrides in `statsPath` for lessons created by `runIds`.
|
|
103
|
+
*
|
|
104
|
+
* Keeps `<definitionsDir>/<lessonId>.json` 100% immutable while updating `statsPath` (`SPEC.md` §4.3).
|
|
105
|
+
*
|
|
106
|
+
* @param {readonly string[]} runIds - Run IDs whose topology overlays committed.
|
|
107
|
+
* @param {ReadonlyMap<string, number>} updatedEpochs - Map of `partitionId` to committed base epoch.
|
|
108
|
+
*
|
|
109
|
+
* @returns {Promise<void>} Resolves when `statsPath` is atomically updated.
|
|
110
|
+
*/
|
|
111
|
+
syncCreationEpochsForRuns(runIds: readonly string[], updatedEpochs: ReadonlyMap<string, number>): Promise<void>;
|
|
112
|
+
/**
|
|
113
|
+
* Persists the ISO-8601 emission timestamp for `signalId` on `lessonId` in `statsPath`.
|
|
114
|
+
*
|
|
115
|
+
* Enforces `.emitSignalWhen()` cooldowns across process restarts (`SPEC.md` §3.4.3).
|
|
116
|
+
*
|
|
117
|
+
* @param {string} lessonId - Lesson identifier.
|
|
118
|
+
* @param {string} signalId - Signal identifier.
|
|
119
|
+
* @param {string} emittedAt - ISO-8601 emission timestamp.
|
|
120
|
+
*
|
|
121
|
+
* @returns {Promise<void>} Resolves when `statsPath` is atomically updated.
|
|
122
|
+
*/
|
|
123
|
+
markSignalEmitted(lessonId: string, signalId: string, emittedAt: string): Promise<void>;
|
|
124
|
+
/**
|
|
125
|
+
* Permanently retires `lessonIds` in `statsPath` so subsequent `queryCandidates()` calls exclude them.
|
|
126
|
+
*
|
|
127
|
+
* Preserves historical `<definitionsDir>/<lessonId>.json` audit files while marking `retired: true`.
|
|
128
|
+
*
|
|
129
|
+
* @param {readonly string[]} lessonIds - Lesson identifiers to retire.
|
|
130
|
+
*
|
|
131
|
+
* @returns {Promise<void>} Resolves when `statsPath` is atomically updated.
|
|
132
|
+
*/
|
|
133
|
+
retire(lessonIds: readonly string[]): Promise<void>;
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=fs-jsonl-lesson-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-jsonl-lesson-store.d.ts","sourceRoot":"","sources":["../../src/stores/fs-jsonl-lesson-store.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,sBAAsB,EACtB,aAAa,EACb,YAAY,EACZ,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAY3B;;GA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AQG;IACH,cAAc,CAAC,QAAQ,EAAE,SAAS,qBAAqB,EAAE,GAAG,OAAO,CAAC,SAAS,YAAY,EAAE,CAAC;IAU5F;;;;;;;;;OASG;IACH,yBAAyB,CACvB,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,aAAa,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACzC,OAAO,CAAC,IAAI,CAAC;IAWhB;;;;;;;;;;OAUG;IACH,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAWvF;;;;;;;;OAQG;IACH,MAAM,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAQpD"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import PQueue from 'p-queue';
|
|
3
|
+
import { admitLessonToStore, markLessonSignalEmittedInStore, queryActiveLessonCandidates, recordLessonOutcomesInStore, retireLessonsInStore, syncLessonCreationEpochsInStore, } from './internal/fs-jsonl-lesson-file-io.js';
|
|
4
|
+
import { withLessonFileLock } from './internal/fs-lesson-lock-and-atomic-io.js';
|
|
5
|
+
/**
|
|
6
|
+
* Crash-safe hybrid filesystem `LessonStore` implementation (`fs.jsonlLessonStore`, `SPEC.md` §4.3).
|
|
7
|
+
*
|
|
8
|
+
* Resolves `definitionsDir`, `statsPath`, and `lockFile` against the immutable host repository
|
|
9
|
+
* root (Invariant 5), writes immutable `<definitionsDir>/<lessonId>.json` definition files on
|
|
10
|
+
* `admit()`, and updates mutable telemetry counters in `statsPath` under a `PQueue({ concurrency: 1 })`
|
|
11
|
+
* queue combined with `@paraharness/lockfile` and `write-file-atomic`.
|
|
12
|
+
*/
|
|
13
|
+
export class FsJsonlLessonStore {
|
|
14
|
+
/** Absolute host-root directory path storing immutable `<lessonId>.json` definitions. */
|
|
15
|
+
definitionsDirPath;
|
|
16
|
+
/** Absolute host-root file path storing mutable lesson telemetry counters. */
|
|
17
|
+
statsFilePath;
|
|
18
|
+
/** Absolute host-root advisory lockfile path. */
|
|
19
|
+
lockFilePath;
|
|
20
|
+
/** Serialized in-process async mutex queue (`concurrency: 1`). */
|
|
21
|
+
mutexQueue = new PQueue({ concurrency: 1 });
|
|
22
|
+
/**
|
|
23
|
+
* Initializes an `FsJsonlLessonStore` bound to the host repository root (`SPEC.md` Invariant 5).
|
|
24
|
+
*
|
|
25
|
+
* Resolves all configured store paths relative to `hostRoot` (defaulting to `process.cwd()`).
|
|
26
|
+
*
|
|
27
|
+
* @param {FsJsonlLessonStoreNode} node - Passive lesson store AST node.
|
|
28
|
+
* @param {string} [hostRoot=process.cwd()] - Optional explicit host repository root directory.
|
|
29
|
+
*/
|
|
30
|
+
constructor(node, hostRoot = process.cwd()) {
|
|
31
|
+
const resolvedRoot = path.resolve(hostRoot);
|
|
32
|
+
this.definitionsDirPath = path.resolve(resolvedRoot, node.definitionsDir);
|
|
33
|
+
this.statsFilePath = path.resolve(resolvedRoot, node.statsPath);
|
|
34
|
+
this.lockFilePath = path.resolve(resolvedRoot, node.lockFile);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Enqueues `operation` onto the in-process `PQueue` (`concurrency: 1`) and acquires the advisory file lock.
|
|
38
|
+
*
|
|
39
|
+
* Guarantees strict serialization across concurrent calls within the process and across processes.
|
|
40
|
+
*
|
|
41
|
+
* @template TResult Result type of the locked operation.
|
|
42
|
+
*
|
|
43
|
+
* @param {() => Promise<TResult>} operation - Critical section callback.
|
|
44
|
+
*
|
|
45
|
+
* @returns {Promise<TResult>} Result returned by `operation`.
|
|
46
|
+
*/
|
|
47
|
+
enqueueLocked(operation) {
|
|
48
|
+
return this.mutexQueue.add(() => withLessonFileLock(this.lockFilePath, operation));
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Queries non-retired candidate lessons and populates `relevanceScore` in `[0, 1]` via `MiniSearch`.
|
|
52
|
+
*
|
|
53
|
+
* Orders returned candidate lessons deterministically by descending `relevanceScore` and `id`.
|
|
54
|
+
*
|
|
55
|
+
* @param {FsQueryCandidatesParams} req - Query text and active partitions.
|
|
56
|
+
*
|
|
57
|
+
* @returns {Promise<readonly LessonRecord[]>} Frozen array of candidate lesson records.
|
|
58
|
+
*/
|
|
59
|
+
queryCandidates(req) {
|
|
60
|
+
return this.enqueueLocked(() => queryActiveLessonCandidates({
|
|
61
|
+
definitionsDirPath: this.definitionsDirPath,
|
|
62
|
+
statsFilePath: this.statsFilePath,
|
|
63
|
+
queryText: req.queryText,
|
|
64
|
+
partitions: req.partitions,
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Admits a distilled lesson by writing an immutable `<definitionsDir>/<lessonId>.json` file.
|
|
69
|
+
*
|
|
70
|
+
* Deduplicates identical `(partition, directive)` pairs and initializes telemetry counters in `statsPath`.
|
|
71
|
+
*
|
|
72
|
+
* @param {FsAdmitLessonParams} lesson - Lesson definition to admit.
|
|
73
|
+
*
|
|
74
|
+
* @returns {Promise<string>} Assigned content-addressed `lessonId`.
|
|
75
|
+
*/
|
|
76
|
+
admit(lesson) {
|
|
77
|
+
return this.enqueueLocked(() => admitLessonToStore({
|
|
78
|
+
definitionsDirPath: this.definitionsDirPath,
|
|
79
|
+
statsFilePath: this.statsFilePath,
|
|
80
|
+
partition: lesson.partition,
|
|
81
|
+
directive: lesson.directive,
|
|
82
|
+
epochAtCreation: lesson.epochAtCreation,
|
|
83
|
+
createdByRunId: lesson.createdByRunId,
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Appends deduplicated step execution outcomes to `statsPath` and returns the updated lesson records.
|
|
88
|
+
*
|
|
89
|
+
* Increments `totalCleanPasses` and `totalViolated` counters without touching `<definitionsDir>/<lessonId>.json`.
|
|
90
|
+
*
|
|
91
|
+
* @param {readonly FsRecordOutcomeParams[]} outcomes - Batch of lesson outcomes.
|
|
92
|
+
*
|
|
93
|
+
* @returns {Promise<readonly LessonRecord[]>} Updated lesson records for the affected lessons.
|
|
94
|
+
*/
|
|
95
|
+
recordOutcomes(outcomes) {
|
|
96
|
+
return this.enqueueLocked(() => recordLessonOutcomesInStore({
|
|
97
|
+
definitionsDirPath: this.definitionsDirPath,
|
|
98
|
+
statsFilePath: this.statsFilePath,
|
|
99
|
+
outcomes,
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Aligns `epochAtCreation` overrides in `statsPath` for lessons created by `runIds`.
|
|
104
|
+
*
|
|
105
|
+
* Keeps `<definitionsDir>/<lessonId>.json` 100% immutable while updating `statsPath` (`SPEC.md` §4.3).
|
|
106
|
+
*
|
|
107
|
+
* @param {readonly string[]} runIds - Run IDs whose topology overlays committed.
|
|
108
|
+
* @param {ReadonlyMap<string, number>} updatedEpochs - Map of `partitionId` to committed base epoch.
|
|
109
|
+
*
|
|
110
|
+
* @returns {Promise<void>} Resolves when `statsPath` is atomically updated.
|
|
111
|
+
*/
|
|
112
|
+
syncCreationEpochsForRuns(runIds, updatedEpochs) {
|
|
113
|
+
return this.enqueueLocked(() => syncLessonCreationEpochsInStore({
|
|
114
|
+
definitionsDirPath: this.definitionsDirPath,
|
|
115
|
+
statsFilePath: this.statsFilePath,
|
|
116
|
+
runIds,
|
|
117
|
+
updatedEpochs,
|
|
118
|
+
}));
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Persists the ISO-8601 emission timestamp for `signalId` on `lessonId` in `statsPath`.
|
|
122
|
+
*
|
|
123
|
+
* Enforces `.emitSignalWhen()` cooldowns across process restarts (`SPEC.md` §3.4.3).
|
|
124
|
+
*
|
|
125
|
+
* @param {string} lessonId - Lesson identifier.
|
|
126
|
+
* @param {string} signalId - Signal identifier.
|
|
127
|
+
* @param {string} emittedAt - ISO-8601 emission timestamp.
|
|
128
|
+
*
|
|
129
|
+
* @returns {Promise<void>} Resolves when `statsPath` is atomically updated.
|
|
130
|
+
*/
|
|
131
|
+
markSignalEmitted(lessonId, signalId, emittedAt) {
|
|
132
|
+
return this.enqueueLocked(() => markLessonSignalEmittedInStore({
|
|
133
|
+
statsFilePath: this.statsFilePath,
|
|
134
|
+
lessonId,
|
|
135
|
+
signalId,
|
|
136
|
+
emittedAt,
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Permanently retires `lessonIds` in `statsPath` so subsequent `queryCandidates()` calls exclude them.
|
|
141
|
+
*
|
|
142
|
+
* Preserves historical `<definitionsDir>/<lessonId>.json` audit files while marking `retired: true`.
|
|
143
|
+
*
|
|
144
|
+
* @param {readonly string[]} lessonIds - Lesson identifiers to retire.
|
|
145
|
+
*
|
|
146
|
+
* @returns {Promise<void>} Resolves when `statsPath` is atomically updated.
|
|
147
|
+
*/
|
|
148
|
+
retire(lessonIds) {
|
|
149
|
+
return this.enqueueLocked(() => retireLessonsInStore({
|
|
150
|
+
statsFilePath: this.statsFilePath,
|
|
151
|
+
lessonIds,
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=fs-jsonl-lesson-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-jsonl-lesson-store.js","sourceRoot":"","sources":["../../src/stores/fs-jsonl-lesson-store.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAO7B,OAAO,MAAM,MAAM,SAAS,CAAC;AAC7B,OAAO,EACL,kBAAkB,EAClB,8BAA8B,EAC9B,2BAA2B,EAC3B,2BAA2B,EAC3B,oBAAoB,EACpB,+BAA+B,GAChC,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAyChF;;;;;;;GAOG;AACH,MAAM,OAAO,kBAAkB;IAC7B,yFAAyF;IACxE,kBAAkB,CAAS;IAC5C,8E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{ LessonOutcome, LessonRecord } from '@paraharness/core';
|
|
2
|
+
/**
|
|
3
|
+
* Parameters for {@link queryActiveLessonCandidates}.
|
|
4
|
+
*/
|
|
5
|
+
export interface QueryActiveLessonCandidatesParams {
|
|
6
|
+
/** Absolute path to the definitions directory. */
|
|
7
|
+
readonly definitionsDirPath: string;
|
|
8
|
+
/** Absolute path to the telemetry stats file. */
|
|
9
|
+
readonly statsFilePath: string;
|
|
10
|
+
/** Search query text. */
|
|
11
|
+
readonly queryText: string;
|
|
12
|
+
/** Active task partitions. */
|
|
13
|
+
readonly partitions: readonly string[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Parameters for {@link admitLessonToStore}.
|
|
17
|
+
*/
|
|
18
|
+
export interface AdmitLessonToStoreParams {
|
|
19
|
+
/** Absolute path to the definitions directory. */
|
|
20
|
+
readonly definitionsDirPath: string;
|
|
21
|
+
/** Absolute path to the telemetry stats file. */
|
|
22
|
+
readonly statsFilePath: string;
|
|
23
|
+
/** Optional partition identifier. */
|
|
24
|
+
readonly partition?: string;
|
|
25
|
+
/** Preventative or prescriptive directive text. */
|
|
26
|
+
readonly directive: string;
|
|
27
|
+
/** Partition contract epoch at creation. */
|
|
28
|
+
readonly epochAtCreation: number;
|
|
29
|
+
/** Optional run identifier that admitted the lesson. */
|
|
30
|
+
readonly createdByRunId?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Parameters for {@link recordLessonOutcomesInStore}.
|
|
34
|
+
*/
|
|
35
|
+
export interface RecordLessonOutcomesInStoreParams {
|
|
36
|
+
/** Absolute path to the definitions directory. */
|
|
37
|
+
readonly definitionsDirPath: string;
|
|
38
|
+
/** Absolute path to the telemetry stats file. */
|
|
39
|
+
readonly statsFilePath: string;
|
|
40
|
+
/** Batch of lesson outcomes to record. */
|
|
41
|
+
readonly outcomes: ReadonlyArray<{
|
|
42
|
+
readonly lessonId: string;
|
|
43
|
+
readonly outcome: LessonOutcome;
|
|
44
|
+
}>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Parameters for {@link syncLessonCreationEpochsInStore}.
|
|
48
|
+
*/
|
|
49
|
+
export interface SyncLessonCreationEpochsInStoreParams {
|
|
50
|
+
/** Absolute path to the definitions directory. */
|
|
51
|
+
readonly definitionsDirPath: string;
|
|
52
|
+
/** Absolute path to the telemetry stats file. */
|
|
53
|
+
readonly statsFilePath: string;
|
|
54
|
+
/** Run IDs whose topology overlays committed. */
|
|
55
|
+
readonly runIds: readonly string[];
|
|
56
|
+
/** Map of `partitionId` to committed base epoch. */
|
|
57
|
+
readonly updatedEpochs: ReadonlyMap<string, number>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Parameters for {@link markLessonSignalEmittedInStore}.
|
|
61
|
+
*/
|
|
62
|
+
export interface MarkLessonSignalEmittedInStoreParams {
|
|
63
|
+
/** Absolute path to the telemetry stats file. */
|
|
64
|
+
readonly statsFilePath: string;
|
|
65
|
+
/** Lesson identifier. */
|
|
66
|
+
readonly lessonId: string;
|
|
67
|
+
/** Signal identifier. */
|
|
68
|
+
readonly signalId: string;
|
|
69
|
+
/** ISO-8601 emission timestamp. */
|
|
70
|
+
readonly emittedAt: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Parameters for {@link retireLessonsInStore}.
|
|
74
|
+
*/
|
|
75
|
+
export interface RetireLessonsInStoreParams {
|
|
76
|
+
/** Absolute path to the telemetry stats file. */
|
|
77
|
+
readonly statsFilePath: string;
|
|
78
|
+
/** Lesson identifiers to mark retired. */
|
|
79
|
+
readonly lessonIds: readonly string[];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Queries non-retired lesson definitions, scores them via `MiniSearch`, and returns sorted `LessonRecord` candidates.
|
|
83
|
+
*
|
|
84
|
+
* @param {QueryActiveLessonCandidatesParams} params - Store paths, query text, and active partitions.
|
|
85
|
+
*
|
|
86
|
+
* @returns {Promise<readonly LessonRecord[]>} Frozen sorted array of active candidate lesson records.
|
|
87
|
+
*/
|
|
88
|
+
export declare function queryActiveLessonCandidates(params: QueryActiveLessonCandidatesParams): Promise<readonly LessonRecord[]>;
|
|
89
|
+
/**
|
|
90
|
+
* Writes an immutable `<definitionsDir>/<lessonId>.json` file (if absent) and initializes telemetry counters in `statsPath`.
|
|
91
|
+
*
|
|
92
|
+
* @param {AdmitLessonToStoreParams} params - Store paths and lesson admission metadata.
|
|
93
|
+
*
|
|
94
|
+
* @returns {Promise<string>} Content-addressed `lessonId`.
|
|
95
|
+
*/
|
|
96
|
+
export declare function admitLessonToStore(params: AdmitLessonToStoreParams): Promise<string>;
|
|
97
|
+
/**
|
|
98
|
+
* Appends deduplicated step execution outcomes to `statsPath` and returns updated `LessonRecord` items.
|
|
99
|
+
*
|
|
100
|
+
* @param {RecordLessonOutcomesInStoreParams} params - Store paths and outcome batch.
|
|
101
|
+
*
|
|
102
|
+
* @returns {Promise<readonly LessonRecord[]>} Frozen array of updated lesson records.
|
|
103
|
+
*/
|
|
104
|
+
export declare function recordLessonOutcomesInStore(params: RecordLessonOutcomesInStoreParams): Promise<readonly LessonRecord[]>;
|
|
105
|
+
/**
|
|
106
|
+
* Aligns `epochAtCreation` overrides in `statsPath` for lessons created by `params.runIds`.
|
|
107
|
+
*
|
|
108
|
+
* @param {SyncLessonCreationEpochsInStoreParams} params - Store paths, committed run IDs, and updated partition epochs.
|
|
109
|
+
*
|
|
110
|
+
* @returns {Promise<void>} Resolves when `statsPath` is updated.
|
|
111
|
+
*/
|
|
112
|
+
export declare function syncLessonCreationEpochsInStore(params: SyncLessonCreationEpochsInStoreParams): Promise<void>;
|
|
113
|
+
/**
|
|
114
|
+
* Persists the ISO-8601 emission timestamp for `params.signalId` on `params.lessonId` in `statsPath`.
|
|
115
|
+
*
|
|
116
|
+
* @param {MarkLessonSignalEmittedInStoreParams} params - Stats file path, lesson ID, signal ID, and timestamp.
|
|
117
|
+
*
|
|
118
|
+
* @returns {Promise<void>} Resolves when `statsPath` is atomically updated.
|
|
119
|
+
*/
|
|
120
|
+
export declare function markLessonSignalEmittedInStore(params: MarkLessonSignalEmittedInStoreParams): Promise<void>;
|
|
121
|
+
/**
|
|
122
|
+
* Marks `params.lessonIds` as `retired: true` in `statsPath` while preserving immutable definition files.
|
|
123
|
+
*
|
|
124
|
+
* @param {RetireLessonsInStoreParams} params - Stats file path and lesson IDs to retire.
|
|
125
|
+
*
|
|
126
|
+
* @returns {Promise<void>} Resolves when `statsPath` is atomically updated.
|
|
127
|
+
*/
|
|
128
|
+
export declare function retireLessonsInStore(params: RetireLessonsInStoreParams): Promise<void>;
|
|
129
|
+
//# sourceMappingURL=fs-jsonl-lesson-file-io.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-jsonl-lesson-file-io.d.ts","sourceRoot":"","sources":["../../../src/stores/internal/fs-jsonl-lesson-file-io.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAcrE;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAChD,kDAAkD;IAClD,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IAEpC,iDAAiD;IACjD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAE/B,yBAAyB;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,8BAA8B;IAC9B,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,kDAAkD;IAClD,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IAEpC,iDAAiD;IACjD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAE/B,qCAAqC;IACrC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAE5B,mDAAmD;IACnD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,4CAA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;;;;GAMG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,iCAAiC,GACxC,OAAO,CAAC,SAAS,YAAY,EAAE,CAAC,CAkBlC;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,CA0B1F;AAED;;;;;;GAMG;AACH,wBAAsB,2BAA2B,CAC/C,MAAM,EAAE,iCAAiC,GACxC,OAAO,CAAC,SAAS,YAAY,EAAE,CAAC,CAoClC;AAED;;;;;;GAMG;AACH,wBAAsB,+BAA+B,CACnD,MAAM,EAAE,qCAAqC,GAC5C,OAAO,CAAC,IAAI,CAAC,CA8Bf;AAED;;;;;;GAMG;AACH,wBAAsB,8BAA8B,CAClD,MAAM,EAAE,oCAAoC,GAC3C,OAAO,CAAC,IAAI,CAAC,CAmBf;AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC,CAe5F"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { atomicWriteJsonFile, readAllLessonDefinitions, readLessonStatsFile, } from './fs-lesson-lock-and-atomic-io.js';
|
|
4
|
+
import { compareLessonRecordsByRelevance, computeLessonId, mergeDefinitionAndStats, scoreLessonsWithMiniSearch, } from './fs-lesson-relevance.js';
|
|
5
|
+
/**
|
|
6
|
+
* Queries non-retired lesson definitions, scores them via `MiniSearch`, and returns sorted `LessonRecord` candidates.
|
|
7
|
+
*
|
|
8
|
+
* @param {QueryActiveLessonCandidatesParams} params - Store paths, query text, and active partitions.
|
|
9
|
+
*
|
|
10
|
+
* @returns {Promise<readonly LessonRecord[]>} Frozen sorted array of active candidate lesson records.
|
|
11
|
+
*/
|
|
12
|
+
export async function queryActiveLessonCandidates(params) {
|
|
13
|
+
const definitions = await readAllLessonDefinitions(params.definitionsDirPath);
|
|
14
|
+
const statsMap = await readLessonStatsFile(params.statsFilePath);
|
|
15
|
+
const activeDefinitions = [];
|
|
16
|
+
for (const def of definitions) {
|
|
17
|
+
if (statsMap[def.id]?.retired !== true)
|
|
18
|
+
activeDefinitions.push(def);
|
|
19
|
+
}
|
|
20
|
+
const scoresById = scoreLessonsWithMiniSearch(params.queryText, activeDefinitions, new Set(params.partitions));
|
|
21
|
+
const records = [];
|
|
22
|
+
for (const def of activeDefinitions) {
|
|
23
|
+
records.push(mergeDefinitionAndStats(def, statsMap[def.id], scoresById.get(def.id) ?? 0));
|
|
24
|
+
}
|
|
25
|
+
records.sort(compareLessonRecordsByRelevance);
|
|
26
|
+
return Object.freeze(records);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Writes an immutable `<definitionsDir>/<lessonId>.json` file (if absent) and initializes telemetry counters in `statsPath`.
|
|
30
|
+
*
|
|
31
|
+
* @param {AdmitLessonToStoreParams} params - Store paths and lesson admission metadata.
|
|
32
|
+
*
|
|
33
|
+
* @returns {Promise<string>} Content-addressed `lessonId`.
|
|
34
|
+
*/
|
|
35
|
+
export async function admitLessonToStore(params) {
|
|
36
|
+
const lessonId = computeLessonId(params.partition, params.directive);
|
|
37
|
+
const defPath = path.join(params.definitionsDirPath, `${lessonId}.json`);
|
|
38
|
+
if (!existsSync(defPath)) {
|
|
39
|
+
const defRecord = Object.freeze({
|
|
40
|
+
id: lessonId,
|
|
41
|
+
partition: params.partition,
|
|
42
|
+
directive: params.directive,
|
|
43
|
+
epochAtCreation: params.epochAtCreation,
|
|
44
|
+
createdByRunId: params.createdByRunId,
|
|
45
|
+
});
|
|
46
|
+
await atomicWriteJsonFile(defPath, defRecord);
|
|
47
|
+
}
|
|
48
|
+
const statsMap = await readLessonStatsFile(params.statsFilePath);
|
|
49
|
+
if (statsMap[lessonId] === undefined) {
|
|
50
|
+
statsMap[lessonId] = {
|
|
51
|
+
recentOutcomes: [],
|
|
52
|
+
totalCleanPasses: 0,
|
|
53
|
+
totalViolated: 0,
|
|
54
|
+
epochAtCreation: undefined,
|
|
55
|
+
signalLastEmittedAt: undefined,
|
|
56
|
+
retired: false,
|
|
57
|
+
};
|
|
58
|
+
await atomicWriteJsonFile(params.statsFilePath, statsMap);
|
|
59
|
+
}
|
|
60
|
+
return lessonId;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Appends deduplicated step execution outcomes to `statsPath` and returns updated `LessonRecord` items.
|
|
64
|
+
*
|
|
65
|
+
* @param {RecordLessonOutcomesInStoreParams} params - Store paths and outcome batch.
|
|
66
|
+
*
|
|
67
|
+
* @returns {Promise<readonly LessonRecord[]>} Frozen array of updated lesson records.
|
|
68
|
+
*/
|
|
69
|
+
export async function recordLessonOutcomesInStore(params) {
|
|
70
|
+
const definitions = await readAllLessonDefinitions(params.definitionsDirPath);
|
|
71
|
+
const defById = new Map();
|
|
72
|
+
for (const def of definitions)
|
|
73
|
+
defById.set(def.id, def);
|
|
74
|
+
const statsMap = await readLessonStatsFile(params.statsFilePath);
|
|
75
|
+
const touchedIds = new Set();
|
|
76
|
+
const mutableOutcomesById = new Map();
|
|
77
|
+
for (const outcomeEntry of params.outcomes) {
|
|
78
|
+
const prev = statsMap[outcomeEntry.lessonId] ?? {
|
|
79
|
+
recentOutcomes: [],
|
|
80
|
+
totalCleanPasses: 0,
|
|
81
|
+
totalViolated: 0,
|
|
82
|
+
};
|
|
83
|
+
let outcomeList = mutableOutcomesById.get(outcomeEntry.lessonId);
|
|
84
|
+
if (outcomeList === undefined) {
|
|
85
|
+
outcomeList = Array.from(prev.recentOutcomes);
|
|
86
|
+
mutableOutcomesById.set(outcomeEntry.lessonId, outcomeList);
|
|
87
|
+
}
|
|
88
|
+
outcomeList.push(outcomeEntry.outcome);
|
|
89
|
+
statsMap[outcomeEntry.lessonId] = {
|
|
90
|
+
recentOutcomes: outcomeList,
|
|
91
|
+
totalCleanPasses: prev.totalCleanPasses + (outcomeEntry.outcome === 'clean_pass' ? 1 : 0),
|
|
92
|
+
totalViolated: prev.totalViolated + (outcomeEntry.outcome === 'violated' ? 1 : 0),
|
|
93
|
+
epochAtCreation: prev.epochAtCreation,
|
|
94
|
+
signalLastEmittedAt: prev.signalLastEmittedAt,
|
|
95
|
+
retired: prev.retired,
|
|
96
|
+
};
|
|
97
|
+
touchedIds.add(outcomeEntry.lessonId);
|
|
98
|
+
}
|
|
99
|
+
await atomicWriteJsonFile(params.statsFilePath, statsMap);
|
|
100
|
+
const updated = [];
|
|
101
|
+
for (const id of touchedIds) {
|
|
102
|
+
const def = defById.get(id);
|
|
103
|
+
if (def !== undefined)
|
|
104
|
+
updated.push(mergeDefinitionAndStats(def, statsMap[id]));
|
|
105
|
+
}
|
|
106
|
+
return Object.freeze(updated);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Aligns `epochAtCreation` overrides in `statsPath` for lessons created by `params.runIds`.
|
|
110
|
+
*
|
|
111
|
+
* @param {SyncLessonCreationEpochsInStoreParams} params - Store paths, committed run IDs, and updated partition epochs.
|
|
112
|
+
*
|
|
113
|
+
* @returns {Promise<void>} Resolves when `statsPath` is updated.
|
|
114
|
+
*/
|
|
115
|
+
export async function syncLessonCreationEpochsInStore(params) {
|
|
116
|
+
if (params.runIds.length === 0 || params.updatedEpochs.size === 0)
|
|
117
|
+
return;
|
|
118
|
+
const runIdSet = new Set(params.runIds);
|
|
119
|
+
const definitions = await readAllLessonDefinitions(params.definitionsDirPath);
|
|
120
|
+
const statsMap = await readLessonStatsFile(params.statsFilePath);
|
|
121
|
+
let mutated = false;
|
|
122
|
+
for (const def of definitions) {
|
|
123
|
+
if (def.createdByRunId === undefined ||
|
|
124
|
+
!runIdSet.has(def.createdByRunId) ||
|
|
125
|
+
def.partition === undefined) {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
const newEpoch = params.updatedEpochs.get(def.partition);
|
|
129
|
+
if (newEpoch === undefined)
|
|
130
|
+
continue;
|
|
131
|
+
const prev = statsMap[def.id] ?? { recentOutcomes: [], totalCleanPasses: 0, totalViolated: 0 };
|
|
132
|
+
statsMap[def.id] = {
|
|
133
|
+
recentOutcomes: prev.recentOutcomes,
|
|
134
|
+
totalCleanPasses: prev.totalCleanPasses,
|
|
135
|
+
totalViolated: prev.totalViolated,
|
|
136
|
+
epochAtCreation: newEpoch,
|
|
137
|
+
signalLastEmittedAt: prev.signalLastEmittedAt,
|
|
138
|
+
retired: prev.retired,
|
|
139
|
+
};
|
|
140
|
+
mutated = true;
|
|
141
|
+
}
|
|
142
|
+
if (mutated) {
|
|
143
|
+
await atomicWriteJsonFile(params.statsFilePath, statsMap);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Persists the ISO-8601 emission timestamp for `params.signalId` on `params.lessonId` in `statsPath`.
|
|
148
|
+
*
|
|
149
|
+
* @param {MarkLessonSignalEmittedInStoreParams} params - Stats file path, lesson ID, signal ID, and timestamp.
|
|
150
|
+
*
|
|
151
|
+
* @returns {Promise<void>} Resolves when `statsPath` is atomically updated.
|
|
152
|
+
*/
|
|
153
|
+
export async function markLessonSignalEmittedInStore(params) {
|
|
154
|
+
const statsMap = await readLessonStatsFile(params.statsFilePath);
|
|
155
|
+
const prev = statsMap[params.lessonId] ?? {
|
|
156
|
+
recentOutcomes: [],
|
|
157
|
+
totalCleanPasses: 0,
|
|
158
|
+
totalViolated: 0,
|
|
159
|
+
};
|
|
160
|
+
statsMap[params.lessonId] = {
|
|
161
|
+
recentOutcomes: prev.recentOutcomes,
|
|
162
|
+
totalCleanPasses: prev.totalCleanPasses,
|
|
163
|
+
totalViolated: prev.totalViolated,
|
|
164
|
+
epochAtCreation: prev.epochAtCreation,
|
|
165
|
+
signalLastEmittedAt: {
|
|
166
|
+
...(prev.signalLastEmittedAt ?? {}),
|
|
167
|
+
[params.signalId]: params.emittedAt,
|
|
168
|
+
},
|
|
169
|
+
retired: prev.retired,
|
|
170
|
+
};
|
|
171
|
+
await atomicWriteJsonFile(params.statsFilePath, statsMap);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Marks `params.lessonIds` as `retired: true` in `statsPath` while preserving immutable definition files.
|
|
175
|
+
*
|
|
176
|
+
* @param {RetireLessonsInStoreParams} params - Stats file path and lesson IDs to retire.
|
|
177
|
+
*
|
|
178
|
+
* @returns {Promise<void>} Resolves when `statsPath` is atomically updated.
|
|
179
|
+
*/
|
|
180
|
+
export async function retireLessonsInStore(params) {
|
|
181
|
+
if (params.lessonIds.length === 0)
|
|
182
|
+
return;
|
|
183
|
+
const statsMap = await readLessonStatsFile(params.statsFilePath);
|
|
184
|
+
for (const id of params.lessonIds) {
|
|
185
|
+
const prev = statsMap[id] ?? { recentOutcomes: [], totalCleanPasses: 0, totalViolated: 0 };
|
|
186
|
+
statsMap[id] = {
|
|
187
|
+
recentOutcomes: prev.recentOutcomes,
|
|
188
|
+
totalCleanPasses: prev.totalCleanPasses,
|
|
189
|
+
totalViolated: prev.totalViolated,
|
|
190
|
+
epochAtCreation: prev.epochAtCreation,
|
|
191
|
+
signalLastEmittedAt: prev.signalLastEmittedAt,
|
|
192
|
+
retired: true,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
await atomicWriteJsonFile(params.statsFilePath, statsMap);
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=fs-jsonl-lesson-file-io.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-jsonl-lesson-file-io.js","sourceRoot":"","sources":["../../../src/stores/internal/fs-jsonl-lesson-file-io.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,+BAA+B,EAC/B,eAAe,EACf,uBAAuB,EACvB,0BAA0B,GAC3B,M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E,IAAI,CAAC,OAAO;KACtB,CAAC;IACF,MAAM,mBAAmB,CAAC,MAAM,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;AAC5D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,MAAkC;IAC3E,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IAC1C,MAAM,QAAQ,GAAG,MAAM,mBAAmB,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IACjE,KAAK,MAAM,EAAE,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;QAClC,MAAM,IAAI,GAAG,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,EAAE,EAAE,EAAE,gBAAgB,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC;QAC3F,QAAQ,CAAC,EAAE,CAAC,GAAG;YACb,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;YAC7C,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;IACD,MAAM,mBAAmB,CAAC,MAAM,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;AAC5D,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Immutable JSON record persisted in `<definitionsDir>/<lessonId>.json` (`SPEC.md` §4.3).
|
|
3
|
+
*
|
|
4
|
+
* Written once during `FsJsonlLessonStore.admit()` and never mutated on subsequent
|
|
5
|
+
* outcome recordings or epoch synchronizations.
|
|
6
|
+
*/
|
|
7
|
+
export interface FsLessonDefinitionRecord {
|
|
8
|
+
/** Content-addressed lesson identifier. */
|
|
9
|
+
readonly id: string;
|
|
10
|
+
/** Optional topology partition associated with the lesson. */
|
|
11
|
+
readonly partition?: string;
|
|
12
|
+
/** Preventative or prescriptive directive text. */
|
|
13
|
+
readonly directive: string;
|
|
14
|
+
/** Initial partition contract epoch when the lesson was admitted. */
|
|
15
|
+
readonly epochAtCreation: number;
|
|
16
|
+
/** Optional run identifier that created the lesson or last mutated its partition contract. */
|
|
17
|
+
readonly createdByRunId?: string;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=fs-lesson-definition-record.d.ts.map
|