@evomap/evolver-core 2.0.0-beta.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/dist/algo/antiDistill.d.ts +35 -0
- package/dist/algo/antiDistill.js +167 -0
- package/dist/algo/bans.d.ts +6 -0
- package/dist/algo/bans.js +33 -0
- package/dist/algo/candidateAssembly.d.ts +65 -0
- package/dist/algo/candidateAssembly.js +196 -0
- package/dist/algo/capabilityCandidates.d.ts +38 -0
- package/dist/algo/capabilityCandidates.js +131 -0
- package/dist/algo/confidence.d.ts +106 -0
- package/dist/algo/confidence.js +196 -0
- package/dist/algo/cycleEngine.d.ts +143 -0
- package/dist/algo/cycleEngine.js +417 -0
- package/dist/algo/cycleFailureClassifier.d.ts +52 -0
- package/dist/algo/cycleFailureClassifier.js +104 -0
- package/dist/algo/epigenetics.d.ts +14 -0
- package/dist/algo/epigenetics.js +41 -0
- package/dist/algo/evolutionEvent.d.ts +23 -0
- package/dist/algo/evolutionEvent.js +24 -0
- package/dist/algo/exploration.d.ts +34 -0
- package/dist/algo/exploration.js +55 -0
- package/dist/algo/geneHealth.d.ts +24 -0
- package/dist/algo/geneHealth.js +16 -0
- package/dist/algo/geneIntake.d.ts +37 -0
- package/dist/algo/geneIntake.js +100 -0
- package/dist/algo/genePromotion.d.ts +48 -0
- package/dist/algo/genePromotion.js +53 -0
- package/dist/algo/geneSelection.d.ts +128 -0
- package/dist/algo/geneSelection.js +222 -0
- package/dist/algo/index.d.ts +18 -0
- package/dist/algo/index.js +18 -0
- package/dist/algo/mutation.d.ts +12 -0
- package/dist/algo/mutation.js +22 -0
- package/dist/algo/orchestrator.d.ts +65 -0
- package/dist/algo/orchestrator.js +63 -0
- package/dist/algo/solidify.d.ts +43 -0
- package/dist/algo/solidify.js +63 -0
- package/dist/algo/strategyPresets.d.ts +32 -0
- package/dist/algo/strategyPresets.js +61 -0
- package/dist/assetstore/index.d.ts +8 -0
- package/dist/assetstore/index.js +8 -0
- package/dist/assetstore/learningHistory.d.ts +25 -0
- package/dist/assetstore/learningHistory.js +38 -0
- package/dist/assetstore/localJsonl.d.ts +34 -0
- package/dist/assetstore/localJsonl.js +182 -0
- package/dist/assetstore/pendingSignals.d.ts +22 -0
- package/dist/assetstore/pendingSignals.js +171 -0
- package/dist/assetstore/provenance.d.ts +39 -0
- package/dist/assetstore/provenance.js +109 -0
- package/dist/assetstore/provider.d.ts +48 -0
- package/dist/assetstore/provider.js +36 -0
- package/dist/assetstore/remoteStub.d.ts +32 -0
- package/dist/assetstore/remoteStub.js +36 -0
- package/dist/assetstore/reviewFilter.d.ts +20 -0
- package/dist/assetstore/reviewFilter.js +44 -0
- package/dist/assetstore/reviewLedger.d.ts +55 -0
- package/dist/assetstore/reviewLedger.js +121 -0
- package/dist/benchmark/antiGeneBenchmark.d.ts +79 -0
- package/dist/benchmark/antiGeneBenchmark.js +241 -0
- package/dist/benchmark/antiGeneRollout.d.ts +80 -0
- package/dist/benchmark/antiGeneRollout.js +256 -0
- package/dist/benchmark/benchmark.d.ts +32 -0
- package/dist/benchmark/benchmark.js +26 -0
- package/dist/benchmark/evolutionThesisSolver.d.ts +25 -0
- package/dist/benchmark/evolutionThesisSolver.js +41 -0
- package/dist/benchmark/index.d.ts +5 -0
- package/dist/benchmark/index.js +5 -0
- package/dist/benchmark/thesis.d.ts +85 -0
- package/dist/benchmark/thesis.js +150 -0
- package/dist/bootstrap/envFingerprint.d.ts +45 -0
- package/dist/bootstrap/envFingerprint.js +72 -0
- package/dist/bootstrap/index.d.ts +2 -0
- package/dist/bootstrap/index.js +2 -0
- package/dist/bootstrap/selfEvolve.d.ts +36 -0
- package/dist/bootstrap/selfEvolve.js +26 -0
- package/dist/cycle/cycleTimeline.d.ts +35 -0
- package/dist/cycle/cycleTimeline.js +74 -0
- package/dist/cycle/index.d.ts +2 -0
- package/dist/cycle/index.js +2 -0
- package/dist/cycle/stateMachine.d.ts +6 -0
- package/dist/cycle/stateMachine.js +25 -0
- package/dist/daemon/cycleContext.d.ts +12 -0
- package/dist/daemon/cycleContext.js +13 -0
- package/dist/daemon/drain.d.ts +11 -0
- package/dist/daemon/drain.js +16 -0
- package/dist/daemon/guards.d.ts +87 -0
- package/dist/daemon/guards.js +142 -0
- package/dist/daemon/idempotency.d.ts +11 -0
- package/dist/daemon/idempotency.js +36 -0
- package/dist/daemon/idleScheduler.d.ts +55 -0
- package/dist/daemon/idleScheduler.js +181 -0
- package/dist/daemon/index.d.ts +8 -0
- package/dist/daemon/index.js +8 -0
- package/dist/daemon/stepRunner.d.ts +12 -0
- package/dist/daemon/stepRunner.js +31 -0
- package/dist/daemon/unhandledRejectionWindow.d.ts +21 -0
- package/dist/daemon/unhandledRejectionWindow.js +52 -0
- package/dist/daemon/watchdog.d.ts +11 -0
- package/dist/daemon/watchdog.js +14 -0
- package/dist/events/eventSchema.d.ts +132 -0
- package/dist/events/eventSchema.js +30 -0
- package/dist/events/eventStore.d.ts +32 -0
- package/dist/events/eventStore.js +137 -0
- package/dist/events/ingest.d.ts +34 -0
- package/dist/events/ingest.js +61 -0
- package/dist/events/paths.d.ts +22 -0
- package/dist/events/paths.js +44 -0
- package/dist/events/projectors.d.ts +9 -0
- package/dist/events/projectors.js +11 -0
- package/dist/events/public.d.ts +14 -0
- package/dist/events/public.js +8 -0
- package/dist/events/replayer.d.ts +26 -0
- package/dist/events/replayer.js +67 -0
- package/dist/events/reports.d.ts +90 -0
- package/dist/events/reports.js +244 -0
- package/dist/events/retention.d.ts +70 -0
- package/dist/events/retention.js +177 -0
- package/dist/events/sink.d.ts +5 -0
- package/dist/events/sink.js +1 -0
- package/dist/exec/autoExec.d.ts +137 -0
- package/dist/exec/autoExec.js +221 -0
- package/dist/exec/autonomousCycle.d.ts +48 -0
- package/dist/exec/autonomousCycle.js +78 -0
- package/dist/exec/claudeBridge.d.ts +112 -0
- package/dist/exec/claudeBridge.js +219 -0
- package/dist/exec/index.d.ts +9 -0
- package/dist/exec/index.js +11 -0
- package/dist/exec/openPrRegistry.d.ts +60 -0
- package/dist/exec/openPrRegistry.js +130 -0
- package/dist/exec/policy/blastRadius.d.ts +31 -0
- package/dist/exec/policy/blastRadius.js +67 -0
- package/dist/exec/policy/constraints.d.ts +26 -0
- package/dist/exec/policy/constraints.js +62 -0
- package/dist/exec/policy/destructive.d.ts +45 -0
- package/dist/exec/policy/destructive.js +108 -0
- package/dist/exec/policy/failureMode.d.ts +33 -0
- package/dist/exec/policy/failureMode.js +49 -0
- package/dist/exec/policy/index.d.ts +24 -0
- package/dist/exec/policy/index.js +30 -0
- package/dist/exec/policy/protectedPaths.d.ts +17 -0
- package/dist/exec/policy/protectedPaths.js +65 -0
- package/dist/exec/policyCheck.d.ts +2 -0
- package/dist/exec/policyCheck.js +7 -0
- package/dist/exec/prompt.d.ts +34 -0
- package/dist/exec/prompt.js +108 -0
- package/dist/exec/proofOfWork.d.ts +9 -0
- package/dist/exec/proofOfWork.js +11 -0
- package/dist/exec/runnerRegistry.d.ts +123 -0
- package/dist/exec/runnerRegistry.js +237 -0
- package/dist/exec/selfPr.d.ts +83 -0
- package/dist/exec/selfPr.js +104 -0
- package/dist/exec/selfPrObfuscation.d.ts +21 -0
- package/dist/exec/selfPrObfuscation.js +85 -0
- package/dist/hooks/hooks.d.ts +117 -0
- package/dist/hooks/hooks.js +89 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hub/assetCallLog.d.ts +43 -0
- package/dist/hub/assetCallLog.js +72 -0
- package/dist/hub/bindings.d.ts +28 -0
- package/dist/hub/bindings.js +90 -0
- package/dist/hub/capability.d.ts +278 -0
- package/dist/hub/capability.js +1 -0
- package/dist/hub/conversationDistiller.d.ts +88 -0
- package/dist/hub/conversationDistiller.js +264 -0
- package/dist/hub/fake.d.ts +45 -0
- package/dist/hub/fake.js +69 -0
- package/dist/hub/hubReview.d.ts +91 -0
- package/dist/hub/hubReview.js +106 -0
- package/dist/hub/index.d.ts +10 -0
- package/dist/hub/index.js +10 -0
- package/dist/hub/ingest.d.ts +15 -0
- package/dist/hub/ingest.js +15 -0
- package/dist/hub/questionGenerator.d.ts +59 -0
- package/dist/hub/questionGenerator.js +406 -0
- package/dist/hub/reuseDecision.d.ts +87 -0
- package/dist/hub/reuseDecision.js +127 -0
- package/dist/hub/sanitize.d.ts +52 -0
- package/dist/hub/sanitize.js +321 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +27 -0
- package/dist/mailbox/catalog.d.ts +17 -0
- package/dist/mailbox/catalog.js +53 -0
- package/dist/mailbox/daemon.d.ts +48 -0
- package/dist/mailbox/daemon.js +61 -0
- package/dist/mailbox/dispatch.d.ts +46 -0
- package/dist/mailbox/dispatch.js +62 -0
- package/dist/mailbox/envelope.d.ts +43 -0
- package/dist/mailbox/envelope.js +52 -0
- package/dist/mailbox/index.d.ts +8 -0
- package/dist/mailbox/index.js +8 -0
- package/dist/mailbox/ipcServer.d.ts +46 -0
- package/dist/mailbox/ipcServer.js +168 -0
- package/dist/mailbox/requestReply.d.ts +40 -0
- package/dist/mailbox/requestReply.js +77 -0
- package/dist/mailbox/store.d.ts +74 -0
- package/dist/mailbox/store.js +308 -0
- package/dist/mailbox/wake.d.ts +45 -0
- package/dist/mailbox/wake.js +60 -0
- package/dist/material/boundary.d.ts +7 -0
- package/dist/material/boundary.js +14 -0
- package/dist/material/consumer.d.ts +21 -0
- package/dist/material/consumer.js +52 -0
- package/dist/material/emit.d.ts +55 -0
- package/dist/material/emit.js +52 -0
- package/dist/material/factory.d.ts +27 -0
- package/dist/material/factory.js +25 -0
- package/dist/material/index.d.ts +8 -0
- package/dist/material/index.js +8 -0
- package/dist/material/materialStore.d.ts +24 -0
- package/dist/material/materialStore.js +76 -0
- package/dist/material/sampling.d.ts +21 -0
- package/dist/material/sampling.js +39 -0
- package/dist/material/sources.d.ts +25 -0
- package/dist/material/sources.js +33 -0
- package/dist/material/watermark.d.ts +21 -0
- package/dist/material/watermark.js +76 -0
- package/dist/observers/cursorRewriteObserver.d.ts +46 -0
- package/dist/observers/cursorRewriteObserver.js +103 -0
- package/dist/observers/distillObserver.d.ts +31 -0
- package/dist/observers/distillObserver.js +93 -0
- package/dist/observers/index.d.ts +5 -0
- package/dist/observers/index.js +5 -0
- package/dist/observers/observerBus.d.ts +44 -0
- package/dist/observers/observerBus.js +73 -0
- package/dist/observers/reflectionObserver.d.ts +31 -0
- package/dist/observers/reflectionObserver.js +124 -0
- package/dist/observers/valueDigestObserver.d.ts +50 -0
- package/dist/observers/valueDigestObserver.js +70 -0
- package/dist/ops/cleanup.d.ts +23 -0
- package/dist/ops/cleanup.js +68 -0
- package/dist/ops/health.d.ts +37 -0
- package/dist/ops/health.js +96 -0
- package/dist/ops/index.d.ts +7 -0
- package/dist/ops/index.js +7 -0
- package/dist/ops/recall.d.ts +65 -0
- package/dist/ops/recall.js +152 -0
- package/dist/ops/reuseOutcomes.d.ts +68 -0
- package/dist/ops/reuseOutcomes.js +126 -0
- package/dist/ops/savingsCore.d.ts +47 -0
- package/dist/ops/savingsCore.js +112 -0
- package/dist/ops/selfUpdate.d.ts +106 -0
- package/dist/ops/selfUpdate.js +294 -0
- package/dist/ops/valueLedger.d.ts +205 -0
- package/dist/ops/valueLedger.js +238 -0
- package/dist/ops/valueOutreach.d.ts +70 -0
- package/dist/ops/valueOutreach.js +244 -0
- package/dist/personality/drift.d.ts +45 -0
- package/dist/personality/drift.js +106 -0
- package/dist/personality/events.d.ts +25 -0
- package/dist/personality/events.js +37 -0
- package/dist/personality/evolveOps.d.ts +20 -0
- package/dist/personality/evolveOps.js +93 -0
- package/dist/personality/index.d.ts +11 -0
- package/dist/personality/index.js +11 -0
- package/dist/personality/mutate.d.ts +21 -0
- package/dist/personality/mutate.js +39 -0
- package/dist/personality/pivot.d.ts +23 -0
- package/dist/personality/pivot.js +22 -0
- package/dist/personality/prompt.d.ts +6 -0
- package/dist/personality/prompt.js +62 -0
- package/dist/personality/riskGate.d.ts +42 -0
- package/dist/personality/riskGate.js +80 -0
- package/dist/personality/schema.d.ts +255 -0
- package/dist/personality/schema.js +119 -0
- package/dist/personality/select.d.ts +46 -0
- package/dist/personality/select.js +71 -0
- package/dist/personality/stats.d.ts +46 -0
- package/dist/personality/stats.js +82 -0
- package/dist/personality/store.d.ts +35 -0
- package/dist/personality/store.js +92 -0
- package/dist/schema/common.d.ts +28 -0
- package/dist/schema/common.js +17 -0
- package/dist/schema/index.d.ts +5 -0
- package/dist/schema/index.js +5 -0
- package/dist/schema/material.d.ts +201 -0
- package/dist/schema/material.js +50 -0
- package/dist/schema/problem.d.ts +160 -0
- package/dist/schema/problem.js +45 -0
- package/dist/schema/proofOfWork.d.ts +97 -0
- package/dist/schema/proofOfWork.js +9 -0
- package/dist/schema/signal.d.ts +41 -0
- package/dist/schema/signal.js +19 -0
- package/dist/shadow/index.d.ts +6 -0
- package/dist/shadow/index.js +6 -0
- package/dist/shadow/jsonlSink.d.ts +17 -0
- package/dist/shadow/jsonlSink.js +27 -0
- package/dist/shadow/redact.d.ts +11 -0
- package/dist/shadow/redact.js +18 -0
- package/dist/shadow/shadowHub.d.ts +12 -0
- package/dist/shadow/shadowHub.js +42 -0
- package/dist/shadow/shadowMailbox.d.ts +17 -0
- package/dist/shadow/shadowMailbox.js +25 -0
- package/dist/shadow/shadowStore.d.ts +18 -0
- package/dist/shadow/shadowStore.js +55 -0
- package/dist/shadow/sink.d.ts +37 -0
- package/dist/shadow/sink.js +18 -0
- package/dist/signals/cycleHistoryFromEvents.d.ts +11 -0
- package/dist/signals/cycleHistoryFromEvents.js +96 -0
- package/dist/signals/expand.d.ts +34 -0
- package/dist/signals/expand.js +125 -0
- package/dist/signals/extractor.d.ts +25 -0
- package/dist/signals/extractor.js +57 -0
- package/dist/signals/index.d.ts +6 -0
- package/dist/signals/index.js +6 -0
- package/dist/signals/metaSignals.d.ts +57 -0
- package/dist/signals/metaSignals.js +158 -0
- package/dist/signals/signalGate.d.ts +15 -0
- package/dist/signals/signalGate.js +40 -0
- package/dist/signals/traceSignals.d.ts +44 -0
- package/dist/signals/traceSignals.js +123 -0
- package/dist/signatures/classifier.d.ts +16 -0
- package/dist/signatures/classifier.js +29 -0
- package/dist/signatures/index.d.ts +2 -0
- package/dist/signatures/index.js +2 -0
- package/dist/signatures/signatures.d.ts +22 -0
- package/dist/signatures/signatures.js +42 -0
- package/dist/strategy/experiment.d.ts +48 -0
- package/dist/strategy/experiment.js +63 -0
- package/dist/strategy/index.d.ts +2 -0
- package/dist/strategy/index.js +2 -0
- package/dist/strategy/strategyPoint.d.ts +30 -0
- package/dist/strategy/strategyPoint.js +23 -0
- package/dist/trace/index.d.ts +2 -0
- package/dist/trace/index.js +2 -0
- package/dist/trace/trajectory.d.ts +82 -0
- package/dist/trace/trajectory.js +117 -0
- package/dist/trace/trajectoryExport.d.ts +237 -0
- package/dist/trace/trajectoryExport.js +1818 -0
- package/dist/trigger/budget.d.ts +16 -0
- package/dist/trigger/budget.js +20 -0
- package/dist/trigger/engine.d.ts +12 -0
- package/dist/trigger/engine.js +23 -0
- package/dist/trigger/index.d.ts +6 -0
- package/dist/trigger/index.js +6 -0
- package/dist/trigger/problemBuilder.d.ts +24 -0
- package/dist/trigger/problemBuilder.js +32 -0
- package/dist/trigger/trigger.d.ts +22 -0
- package/dist/trigger/trigger.js +27 -0
- package/dist/trigger/valueModel.d.ts +26 -0
- package/dist/trigger/valueModel.js +25 -0
- package/dist/trigger/wfq.d.ts +13 -0
- package/dist/trigger/wfq.js +25 -0
- package/dist/util/fileLock.d.ts +24 -0
- package/dist/util/fileLock.js +227 -0
- package/dist/util/index.d.ts +2 -0
- package/dist/util/index.js +2 -0
- package/dist/util/version.d.ts +12 -0
- package/dist/util/version.js +51 -0
- package/dist/verify/index.d.ts +4 -0
- package/dist/verify/index.js +4 -0
- package/dist/verify/rollback.d.ts +22 -0
- package/dist/verify/rollback.js +33 -0
- package/dist/verify/sandboxRunner.d.ts +39 -0
- package/dist/verify/sandboxRunner.js +116 -0
- package/dist/verify/sandboxedValidation.d.ts +35 -0
- package/dist/verify/sandboxedValidation.js +56 -0
- package/dist/verify/validation.d.ts +41 -0
- package/dist/verify/validation.js +85 -0
- package/dist/wire/canonicalize.golden.d.ts +23 -0
- package/dist/wire/canonicalize.golden.js +46 -0
- package/dist/wire/geneHints.d.ts +64 -0
- package/dist/wire/geneHints.js +100 -0
- package/dist/wire/index.d.ts +91 -0
- package/dist/wire/index.js +3 -0
- package/dist/wire/schemaGate.d.ts +11 -0
- package/dist/wire/schemaGate.js +49 -0
- package/dist/workflow/dsl.d.ts +54 -0
- package/dist/workflow/dsl.js +15 -0
- package/dist/workflow/engine.d.ts +30 -0
- package/dist/workflow/engine.js +94 -0
- package/dist/workflow/index.d.ts +2 -0
- package/dist/workflow/index.js +2 -0
- package/package.json +29 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const EVENT_SCHEMA_VERSION = "1.0.0";
|
|
3
|
+
export declare const replayability: z.ZodEnum<["deterministic", "stochastic_recorded", "stochastic_unreproducible"]>;
|
|
4
|
+
export type Replayability = z.infer<typeof replayability>;
|
|
5
|
+
/** 每事件自带叙述 (军杰 §9.2). title 必填. */
|
|
6
|
+
export declare const humanNarrative: z.ZodObject<{
|
|
7
|
+
title: z.ZodString;
|
|
8
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
9
|
+
why: z.ZodOptional<z.ZodString>;
|
|
10
|
+
next: z.ZodOptional<z.ZodString>;
|
|
11
|
+
severity: z.ZodDefault<z.ZodEnum<["info", "notice", "warn", "error"]>>;
|
|
12
|
+
iconHint: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
severity: "warn" | "info" | "notice" | "error";
|
|
15
|
+
title: string;
|
|
16
|
+
detail?: string | undefined;
|
|
17
|
+
why?: string | undefined;
|
|
18
|
+
next?: string | undefined;
|
|
19
|
+
iconHint?: string | undefined;
|
|
20
|
+
}, {
|
|
21
|
+
title: string;
|
|
22
|
+
severity?: "warn" | "info" | "notice" | "error" | undefined;
|
|
23
|
+
detail?: string | undefined;
|
|
24
|
+
why?: string | undefined;
|
|
25
|
+
next?: string | undefined;
|
|
26
|
+
iconHint?: string | undefined;
|
|
27
|
+
}>;
|
|
28
|
+
export type HumanNarrative = z.infer<typeof humanNarrative>;
|
|
29
|
+
/** 人/机操作审计 (军杰 §9.7). */
|
|
30
|
+
export declare const actor: z.ZodObject<{
|
|
31
|
+
kind: z.ZodDefault<z.ZodEnum<["machine", "human"]>>;
|
|
32
|
+
id: z.ZodOptional<z.ZodString>;
|
|
33
|
+
}, "strip", z.ZodTypeAny, {
|
|
34
|
+
kind: "machine" | "human";
|
|
35
|
+
id?: string | undefined;
|
|
36
|
+
}, {
|
|
37
|
+
kind?: "machine" | "human" | undefined;
|
|
38
|
+
id?: string | undefined;
|
|
39
|
+
}>;
|
|
40
|
+
export type Actor = z.infer<typeof actor>;
|
|
41
|
+
/** AE 事件信封 (军杰 §3.2). 内部类型 camelCase. */
|
|
42
|
+
export declare const rootEvent: z.ZodObject<{
|
|
43
|
+
seq: z.ZodNumber;
|
|
44
|
+
eventId: z.ZodString;
|
|
45
|
+
ts: z.ZodString;
|
|
46
|
+
type: z.ZodString;
|
|
47
|
+
schemaVersion: z.ZodDefault<z.ZodString>;
|
|
48
|
+
replayability: z.ZodDefault<z.ZodEnum<["deterministic", "stochastic_recorded", "stochastic_unreproducible"]>>;
|
|
49
|
+
payload: z.ZodDefault<z.ZodUnknown>;
|
|
50
|
+
human: z.ZodObject<{
|
|
51
|
+
title: z.ZodString;
|
|
52
|
+
detail: z.ZodOptional<z.ZodString>;
|
|
53
|
+
why: z.ZodOptional<z.ZodString>;
|
|
54
|
+
next: z.ZodOptional<z.ZodString>;
|
|
55
|
+
severity: z.ZodDefault<z.ZodEnum<["info", "notice", "warn", "error"]>>;
|
|
56
|
+
iconHint: z.ZodOptional<z.ZodString>;
|
|
57
|
+
}, "strip", z.ZodTypeAny, {
|
|
58
|
+
severity: "warn" | "info" | "notice" | "error";
|
|
59
|
+
title: string;
|
|
60
|
+
detail?: string | undefined;
|
|
61
|
+
why?: string | undefined;
|
|
62
|
+
next?: string | undefined;
|
|
63
|
+
iconHint?: string | undefined;
|
|
64
|
+
}, {
|
|
65
|
+
title: string;
|
|
66
|
+
severity?: "warn" | "info" | "notice" | "error" | undefined;
|
|
67
|
+
detail?: string | undefined;
|
|
68
|
+
why?: string | undefined;
|
|
69
|
+
next?: string | undefined;
|
|
70
|
+
iconHint?: string | undefined;
|
|
71
|
+
}>;
|
|
72
|
+
actor: z.ZodDefault<z.ZodObject<{
|
|
73
|
+
kind: z.ZodDefault<z.ZodEnum<["machine", "human"]>>;
|
|
74
|
+
id: z.ZodOptional<z.ZodString>;
|
|
75
|
+
}, "strip", z.ZodTypeAny, {
|
|
76
|
+
kind: "machine" | "human";
|
|
77
|
+
id?: string | undefined;
|
|
78
|
+
}, {
|
|
79
|
+
kind?: "machine" | "human" | undefined;
|
|
80
|
+
id?: string | undefined;
|
|
81
|
+
}>>;
|
|
82
|
+
}, "strip", z.ZodTypeAny, {
|
|
83
|
+
type: string;
|
|
84
|
+
ts: string;
|
|
85
|
+
human: {
|
|
86
|
+
severity: "warn" | "info" | "notice" | "error";
|
|
87
|
+
title: string;
|
|
88
|
+
detail?: string | undefined;
|
|
89
|
+
why?: string | undefined;
|
|
90
|
+
next?: string | undefined;
|
|
91
|
+
iconHint?: string | undefined;
|
|
92
|
+
};
|
|
93
|
+
seq: number;
|
|
94
|
+
eventId: string;
|
|
95
|
+
schemaVersion: string;
|
|
96
|
+
replayability: "deterministic" | "stochastic_recorded" | "stochastic_unreproducible";
|
|
97
|
+
actor: {
|
|
98
|
+
kind: "machine" | "human";
|
|
99
|
+
id?: string | undefined;
|
|
100
|
+
};
|
|
101
|
+
payload?: unknown;
|
|
102
|
+
}, {
|
|
103
|
+
type: string;
|
|
104
|
+
ts: string;
|
|
105
|
+
human: {
|
|
106
|
+
title: string;
|
|
107
|
+
severity?: "warn" | "info" | "notice" | "error" | undefined;
|
|
108
|
+
detail?: string | undefined;
|
|
109
|
+
why?: string | undefined;
|
|
110
|
+
next?: string | undefined;
|
|
111
|
+
iconHint?: string | undefined;
|
|
112
|
+
};
|
|
113
|
+
seq: number;
|
|
114
|
+
eventId: string;
|
|
115
|
+
payload?: unknown;
|
|
116
|
+
schemaVersion?: string | undefined;
|
|
117
|
+
replayability?: "deterministic" | "stochastic_recorded" | "stochastic_unreproducible" | undefined;
|
|
118
|
+
actor?: {
|
|
119
|
+
kind?: "machine" | "human" | undefined;
|
|
120
|
+
id?: string | undefined;
|
|
121
|
+
} | undefined;
|
|
122
|
+
}>;
|
|
123
|
+
export type RootEvent = z.infer<typeof rootEvent>;
|
|
124
|
+
/** append 入参: seq/eventId/ts 由 store 生成. */
|
|
125
|
+
export type RawEvent = {
|
|
126
|
+
type: string;
|
|
127
|
+
payload?: unknown;
|
|
128
|
+
human: z.input<typeof humanNarrative>;
|
|
129
|
+
actor?: z.input<typeof actor>;
|
|
130
|
+
replayability?: Replayability;
|
|
131
|
+
schemaVersion?: string;
|
|
132
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { ulid } from '../schema/common.js';
|
|
3
|
+
export const EVENT_SCHEMA_VERSION = '1.0.0';
|
|
4
|
+
export const replayability = z.enum(['deterministic', 'stochastic_recorded', 'stochastic_unreproducible']);
|
|
5
|
+
/** 每事件自带叙述 (军杰 §9.2). title 必填. */
|
|
6
|
+
export const humanNarrative = z.object({
|
|
7
|
+
title: z.string().min(1).max(80),
|
|
8
|
+
detail: z.string().optional(),
|
|
9
|
+
why: z.string().optional(),
|
|
10
|
+
next: z.string().optional(),
|
|
11
|
+
severity: z.enum(['info', 'notice', 'warn', 'error']).default('info'),
|
|
12
|
+
iconHint: z.string().optional(),
|
|
13
|
+
});
|
|
14
|
+
/** 人/机操作审计 (军杰 §9.7). */
|
|
15
|
+
export const actor = z.object({
|
|
16
|
+
kind: z.enum(['machine', 'human']).default('machine'),
|
|
17
|
+
id: z.string().optional(),
|
|
18
|
+
});
|
|
19
|
+
/** AE 事件信封 (军杰 §3.2). 内部类型 camelCase. */
|
|
20
|
+
export const rootEvent = z.object({
|
|
21
|
+
seq: z.number().int().nonnegative(),
|
|
22
|
+
eventId: ulid,
|
|
23
|
+
ts: z.string().datetime(),
|
|
24
|
+
type: z.string().min(1),
|
|
25
|
+
schemaVersion: z.string().default(EVENT_SCHEMA_VERSION),
|
|
26
|
+
replayability: replayability.default('deterministic'),
|
|
27
|
+
payload: z.unknown().default({}),
|
|
28
|
+
human: humanNarrative,
|
|
29
|
+
actor: actor.default({ kind: 'machine' }),
|
|
30
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type RootEvent, type RawEvent } from './eventSchema.js';
|
|
2
|
+
/** 单行字节上限, 保 O_APPEND+write 在 ext4 的原子性 (军杰 §3.2). */
|
|
3
|
+
export declare const MAX_LINE_BYTES = 4096;
|
|
4
|
+
export declare class LineTooLargeError extends Error {
|
|
5
|
+
readonly bytes: number;
|
|
6
|
+
constructor(bytes: number);
|
|
7
|
+
}
|
|
8
|
+
export interface EventStoreOptions {
|
|
9
|
+
path: string;
|
|
10
|
+
/** Injectable clock for the event `ts` (ms epoch). Defaults to the real clock; inject for deterministic tests. */
|
|
11
|
+
now?: () => number;
|
|
12
|
+
}
|
|
13
|
+
/** 唯一权威事件流 (AE). single-writer / append-only / seq 递增 / fsync. */
|
|
14
|
+
export declare class EventStore {
|
|
15
|
+
readonly path: string;
|
|
16
|
+
private readonly lockPath;
|
|
17
|
+
private readonly now;
|
|
18
|
+
private chain;
|
|
19
|
+
constructor(opts: EventStoreOptions);
|
|
20
|
+
/** 唯一写路径: 生成 seq/eventId/ts, 校验, 原子 append + fsync. */
|
|
21
|
+
append(raw: RawEvent): Promise<RootEvent>;
|
|
22
|
+
private appendLocked;
|
|
23
|
+
/** 读全部事件 (跳过尾部半行/损坏行). */
|
|
24
|
+
readAll(): RootEvent[];
|
|
25
|
+
iterate(fromSeq?: number): Generator<RootEvent>;
|
|
26
|
+
tail(n?: number): RootEvent[];
|
|
27
|
+
/** 截断尾部半行 (崩溃恢复). */
|
|
28
|
+
recover(): {
|
|
29
|
+
truncated: boolean;
|
|
30
|
+
};
|
|
31
|
+
private lastSeqFromFile;
|
|
32
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { openSync, writeSync, fsyncSync, closeSync, statSync, readSync, mkdirSync, existsSync, truncateSync, readFileSync, } from 'node:fs';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
3
|
+
import { monotonicFactory } from 'ulid';
|
|
4
|
+
import { acquireLock, releaseLock } from '../util/fileLock.js';
|
|
5
|
+
// Monotonic ULIDs: plain ulid() randomizes the low 80 bits, so two ids minted in the SAME millisecond can sort
|
|
6
|
+
// out of order — the event log wants time-sortable eventIds (and a flaky CI test proved it). The monotonic
|
|
7
|
+
// factory increments within a millisecond, guaranteeing each successive eventId is strictly greater.
|
|
8
|
+
const makeUlid = monotonicFactory();
|
|
9
|
+
import { rootEvent, EVENT_SCHEMA_VERSION } from './eventSchema.js';
|
|
10
|
+
/** 单行字节上限, 保 O_APPEND+write 在 ext4 的原子性 (军杰 §3.2). */
|
|
11
|
+
export const MAX_LINE_BYTES = 4096;
|
|
12
|
+
export class LineTooLargeError extends Error {
|
|
13
|
+
bytes;
|
|
14
|
+
constructor(bytes) {
|
|
15
|
+
super(`root_event line ${bytes}B exceeds ${MAX_LINE_BYTES}B; 大 payload 须走 artifact 引用`);
|
|
16
|
+
this.bytes = bytes;
|
|
17
|
+
this.name = 'LineTooLargeError';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** 唯一权威事件流 (AE). single-writer / append-only / seq 递增 / fsync. */
|
|
21
|
+
export class EventStore {
|
|
22
|
+
path;
|
|
23
|
+
lockPath;
|
|
24
|
+
now;
|
|
25
|
+
chain = Promise.resolve();
|
|
26
|
+
constructor(opts) {
|
|
27
|
+
this.path = opts.path;
|
|
28
|
+
this.lockPath = `${opts.path}.lock`;
|
|
29
|
+
this.now = opts.now ?? Date.now;
|
|
30
|
+
mkdirSync(dirname(this.path), { recursive: true });
|
|
31
|
+
}
|
|
32
|
+
/** 唯一写路径: 生成 seq/eventId/ts, 校验, 原子 append + fsync. */
|
|
33
|
+
async append(raw) {
|
|
34
|
+
const run = this.chain.then(() => this.appendLocked(raw));
|
|
35
|
+
this.chain = run.then(() => undefined, () => undefined);
|
|
36
|
+
return run;
|
|
37
|
+
}
|
|
38
|
+
appendLocked(raw) {
|
|
39
|
+
// Crash-recoverable, pid-aware O_EXCL lock shared with every other persistence path (localJsonl /
|
|
40
|
+
// materialStore / mailbox / pendingSignals): it reclaims a stale lock left by a crashed writer instead of
|
|
41
|
+
// deadlocking every future append until the .lock is deleted by hand.
|
|
42
|
+
acquireLock(this.lockPath);
|
|
43
|
+
try {
|
|
44
|
+
const seq = this.lastSeqFromFile() + 1;
|
|
45
|
+
const evt = rootEvent.parse({
|
|
46
|
+
seq,
|
|
47
|
+
eventId: makeUlid(),
|
|
48
|
+
ts: new Date(this.now()).toISOString(),
|
|
49
|
+
type: raw.type,
|
|
50
|
+
schemaVersion: raw.schemaVersion ?? EVENT_SCHEMA_VERSION,
|
|
51
|
+
replayability: raw.replayability ?? 'deterministic',
|
|
52
|
+
payload: raw.payload ?? {},
|
|
53
|
+
human: raw.human,
|
|
54
|
+
actor: raw.actor ?? { kind: 'machine' },
|
|
55
|
+
});
|
|
56
|
+
const line = `${JSON.stringify(evt)}\n`;
|
|
57
|
+
const bytes = Buffer.byteLength(line, 'utf8');
|
|
58
|
+
if (bytes > MAX_LINE_BYTES)
|
|
59
|
+
throw new LineTooLargeError(bytes);
|
|
60
|
+
const fd = openSync(this.path, 'a');
|
|
61
|
+
try {
|
|
62
|
+
writeSync(fd, line);
|
|
63
|
+
fsyncSync(fd);
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
closeSync(fd);
|
|
67
|
+
}
|
|
68
|
+
return evt;
|
|
69
|
+
}
|
|
70
|
+
finally {
|
|
71
|
+
releaseLock(this.lockPath);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/** 读全部事件 (跳过尾部半行/损坏行). */
|
|
75
|
+
readAll() {
|
|
76
|
+
if (!existsSync(this.path))
|
|
77
|
+
return [];
|
|
78
|
+
const out = [];
|
|
79
|
+
for (const l of readFileSync(this.path, 'utf8').split('\n')) {
|
|
80
|
+
if (!l)
|
|
81
|
+
continue;
|
|
82
|
+
try {
|
|
83
|
+
out.push(rootEvent.parse(JSON.parse(l)));
|
|
84
|
+
}
|
|
85
|
+
catch { /* 崩溃半行: 跳过 */ }
|
|
86
|
+
}
|
|
87
|
+
return out;
|
|
88
|
+
}
|
|
89
|
+
*iterate(fromSeq = 0) {
|
|
90
|
+
for (const e of this.readAll())
|
|
91
|
+
if (e.seq >= fromSeq)
|
|
92
|
+
yield e;
|
|
93
|
+
}
|
|
94
|
+
tail(n = 1) {
|
|
95
|
+
const all = this.readAll();
|
|
96
|
+
return all.slice(Math.max(0, all.length - n));
|
|
97
|
+
}
|
|
98
|
+
/** 截断尾部半行 (崩溃恢复). */
|
|
99
|
+
recover() {
|
|
100
|
+
if (!existsSync(this.path))
|
|
101
|
+
return { truncated: false };
|
|
102
|
+
const buf = readFileSync(this.path);
|
|
103
|
+
if (buf.length === 0)
|
|
104
|
+
return { truncated: false };
|
|
105
|
+
const lastNl = buf.lastIndexOf(0x0a);
|
|
106
|
+
if (lastNl === buf.length - 1)
|
|
107
|
+
return { truncated: false };
|
|
108
|
+
truncateSync(this.path, lastNl + 1);
|
|
109
|
+
return { truncated: true };
|
|
110
|
+
}
|
|
111
|
+
lastSeqFromFile() {
|
|
112
|
+
if (!existsSync(this.path))
|
|
113
|
+
return 0;
|
|
114
|
+
const size = statSync(this.path).size;
|
|
115
|
+
if (size === 0)
|
|
116
|
+
return 0;
|
|
117
|
+
const readBytes = Math.min(8192, size);
|
|
118
|
+
const fd = openSync(this.path, 'r');
|
|
119
|
+
try {
|
|
120
|
+
const buf = Buffer.alloc(readBytes);
|
|
121
|
+
readSync(fd, buf, 0, readBytes, size - readBytes);
|
|
122
|
+
const lines = buf.toString('utf8').split('\n').filter((l) => l.length > 0);
|
|
123
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
124
|
+
try {
|
|
125
|
+
const o = JSON.parse(lines[i]);
|
|
126
|
+
if (typeof o.seq === 'number')
|
|
127
|
+
return o.seq;
|
|
128
|
+
}
|
|
129
|
+
catch { /* skip */ }
|
|
130
|
+
}
|
|
131
|
+
return 0;
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
closeSync(fd);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { EventStore, type EventStoreOptions } from './eventStore.js';
|
|
2
|
+
import type { RawEvent, RootEvent } from './eventSchema.js';
|
|
3
|
+
import type { EventSink } from './sink.js';
|
|
4
|
+
/** 已知事件类型 (军杰 §9; 可 registerEventType 扩展). */
|
|
5
|
+
export declare const EVENT_TYPES: readonly ["cycle.started", "cycle.signals_collected", "cycle.solidified", "cycle.failed", "cycle.aborted", "cycle.heartbeat", "cycle.consumed", "decision.gene_selected", "decision.triggered", "decision.suppressed", "personality.selected", "personality.risk_gated", "personality.mutated", "personality.stats_updated", "personality.pivoted", "signals.extracted", "mutation.built", "capsule.produced", "evolution_event.projected", "observer.quarantined", "observer.dead_letter", "actor.human.nudge", "actor.human.intervene", "actor.human.teach", "actor.human.observe", "actor.human.review.approve", "actor.human.review.reject", "gene.distilled", "gene.distill_shadowed", "anti_gene.distilled", "anti_gene.distill_shadowed", "anti_gene.benchmark_result", "anti_gene.rollout_result", "reflection.recorded", "material.batch_ready", "value.reuse_hit", "value.inject", "value.reuse_outcome", "value.recall"];
|
|
6
|
+
export type EventType = (typeof EVENT_TYPES)[number];
|
|
7
|
+
export declare function registerEventType(t: string): void;
|
|
8
|
+
export declare function isKnownEventType(t: string): boolean;
|
|
9
|
+
export declare class IngestValidationError extends Error {
|
|
10
|
+
constructor(message: string);
|
|
11
|
+
}
|
|
12
|
+
export declare class UnknownEventTypeError extends Error {
|
|
13
|
+
readonly type: string;
|
|
14
|
+
constructor(type: string);
|
|
15
|
+
}
|
|
16
|
+
export type IngestorOptions = (EventStoreOptions | {
|
|
17
|
+
store: EventStore;
|
|
18
|
+
}) & {
|
|
19
|
+
sink?: EventSink;
|
|
20
|
+
};
|
|
21
|
+
/** root_events 的全仓唯一写入口 (军杰 §9.2). EventStore 不对外暴露 (见 public.ts). */
|
|
22
|
+
export declare class Ingestor {
|
|
23
|
+
private readonly store;
|
|
24
|
+
private readonly sink;
|
|
25
|
+
constructor(opts: IngestorOptions);
|
|
26
|
+
ingest(raw: RawEvent): Promise<RootEvent>;
|
|
27
|
+
readAll(): RootEvent[];
|
|
28
|
+
iterate(fromSeq?: number): Generator<RootEvent>;
|
|
29
|
+
tail(n?: number): RootEvent[];
|
|
30
|
+
recover(): {
|
|
31
|
+
truncated: boolean;
|
|
32
|
+
};
|
|
33
|
+
get path(): string;
|
|
34
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { EventStore } from './eventStore.js';
|
|
2
|
+
/** 已知事件类型 (军杰 §9; 可 registerEventType 扩展). */
|
|
3
|
+
export const EVENT_TYPES = [
|
|
4
|
+
'cycle.started', 'cycle.signals_collected', 'cycle.solidified', 'cycle.failed',
|
|
5
|
+
'cycle.aborted', 'cycle.heartbeat', 'cycle.consumed',
|
|
6
|
+
'decision.gene_selected', 'decision.triggered', 'decision.suppressed',
|
|
7
|
+
'personality.selected', 'personality.risk_gated',
|
|
8
|
+
'personality.mutated', 'personality.stats_updated', 'personality.pivoted',
|
|
9
|
+
'signals.extracted', 'mutation.built', 'capsule.produced', 'evolution_event.projected',
|
|
10
|
+
'observer.quarantined', 'observer.dead_letter',
|
|
11
|
+
'actor.human.nudge', 'actor.human.intervene', 'actor.human.teach', 'actor.human.observe',
|
|
12
|
+
'actor.human.review.approve', 'actor.human.review.reject',
|
|
13
|
+
'gene.distilled', 'gene.distill_shadowed',
|
|
14
|
+
'anti_gene.distilled', 'anti_gene.distill_shadowed',
|
|
15
|
+
'anti_gene.benchmark_result', 'anti_gene.rollout_result',
|
|
16
|
+
'reflection.recorded',
|
|
17
|
+
'material.batch_ready',
|
|
18
|
+
'value.reuse_hit', 'value.inject', 'value.reuse_outcome', 'value.recall',
|
|
19
|
+
];
|
|
20
|
+
const knownTypes = new Set(EVENT_TYPES);
|
|
21
|
+
export function registerEventType(t) { knownTypes.add(t); }
|
|
22
|
+
export function isKnownEventType(t) { return knownTypes.has(t); }
|
|
23
|
+
export class IngestValidationError extends Error {
|
|
24
|
+
constructor(message) { super(message); this.name = 'IngestValidationError'; }
|
|
25
|
+
}
|
|
26
|
+
export class UnknownEventTypeError extends Error {
|
|
27
|
+
type;
|
|
28
|
+
constructor(type) {
|
|
29
|
+
super(`未知事件类型: ${type}`);
|
|
30
|
+
this.type = type;
|
|
31
|
+
this.name = 'UnknownEventTypeError';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** root_events 的全仓唯一写入口 (军杰 §9.2). EventStore 不对外暴露 (见 public.ts). */
|
|
35
|
+
export class Ingestor {
|
|
36
|
+
store;
|
|
37
|
+
sink;
|
|
38
|
+
constructor(opts) {
|
|
39
|
+
this.store = 'store' in opts ? opts.store : new EventStore(opts);
|
|
40
|
+
this.sink = opts.sink;
|
|
41
|
+
}
|
|
42
|
+
async ingest(raw) {
|
|
43
|
+
if (!isKnownEventType(raw.type))
|
|
44
|
+
throw new UnknownEventTypeError(raw.type);
|
|
45
|
+
if (!raw.human || typeof raw.human.title !== 'string' || raw.human.title.length === 0)
|
|
46
|
+
throw new IngestValidationError('human.title 必填 (军杰 §9.2)');
|
|
47
|
+
if (raw.type.startsWith('decision.') && !raw.human.why)
|
|
48
|
+
throw new IngestValidationError(`${raw.type}: decision.* 必填 human.why (Why 面板)`);
|
|
49
|
+
if (raw.actor?.kind === 'human' && !raw.actor.id)
|
|
50
|
+
throw new IngestValidationError('actor.kind=human 必带 actor.id (审计, 军杰 §9.7)');
|
|
51
|
+
const evt = await this.store.append(raw);
|
|
52
|
+
this.sink?.dispatch(evt);
|
|
53
|
+
return evt;
|
|
54
|
+
}
|
|
55
|
+
// 读 passthrough (写只能经 ingest)
|
|
56
|
+
readAll() { return this.store.readAll(); }
|
|
57
|
+
iterate(fromSeq = 0) { return this.store.iterate(fromSeq); }
|
|
58
|
+
tail(n = 1) { return this.store.tail(n); }
|
|
59
|
+
recover() { return this.store.recover(); }
|
|
60
|
+
get path() { return this.store.path; }
|
|
61
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** ~/.evomap, 可 EVOLVER_HOME/EVOMAP_HOME 覆盖. */
|
|
2
|
+
export declare function evomapHome(): string;
|
|
3
|
+
export declare function rootEventsPath(): string;
|
|
4
|
+
export declare function mvDir(): string;
|
|
5
|
+
/** 可进化人格模型持久化文件 (五维向量 + 各键统计 + 变更历史). v1 personality_state.json 的 v2 落点. */
|
|
6
|
+
export declare function personalityStatePath(): string;
|
|
7
|
+
export declare function assetsDir(): string;
|
|
8
|
+
/** M1 raw-material substrate (append-only jsonl consumed by the cycle). */
|
|
9
|
+
export declare function materialDir(): string;
|
|
10
|
+
/** MaterialStore backing file. */
|
|
11
|
+
export declare function materialStorePath(): string;
|
|
12
|
+
/** Per-source watermark cursor used to make re-ingest idempotent (file-level dedup). */
|
|
13
|
+
export declare function materialWatermarkPath(): string;
|
|
14
|
+
/** Proxy LLM-trace day-files dir (`llm-trace-YYYYMMDD.jsonl`), the route-savings source for the value ledger.
|
|
15
|
+
* Mirrors the proxy's EVOLVER_LLM_TRACE_DIR default so the outreach layer reads what the proxy wrote. */
|
|
16
|
+
export declare function tracesDir(): string;
|
|
17
|
+
/** Hub-asset audit trail (`asset_call_log.jsonl`): one JSONL line per hub-asset interaction (search hit/miss,
|
|
18
|
+
* reuse/reference, publish, review). Written best-effort by AssetCallLog; the desktop's RecallHistory / 召回历程
|
|
19
|
+
* reads it. Defaults to the evomap home root, beside assets/ + evolution/.
|
|
20
|
+
* NOTE(reuse/#234): confirm this matches where the proxy/RecallHistory reads — best-effort append, so a path
|
|
21
|
+
* mismatch degrades the audit line, never the reuse write itself. */
|
|
22
|
+
export declare function assetCallLogPath(): string;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { homedir } from 'node:os';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
/** ~/.evomap, 可 EVOLVER_HOME/EVOMAP_HOME 覆盖. */
|
|
4
|
+
export function evomapHome() {
|
|
5
|
+
return process.env['EVOLVER_HOME'] ?? process.env['EVOMAP_HOME'] ?? join(homedir(), '.evomap');
|
|
6
|
+
}
|
|
7
|
+
export function rootEventsPath() {
|
|
8
|
+
return join(evomapHome(), 'evolution', 'root_events.jsonl');
|
|
9
|
+
}
|
|
10
|
+
export function mvDir() {
|
|
11
|
+
return join(evomapHome(), 'evolution', 'mv');
|
|
12
|
+
}
|
|
13
|
+
/** 可进化人格模型持久化文件 (五维向量 + 各键统计 + 变更历史). v1 personality_state.json 的 v2 落点. */
|
|
14
|
+
export function personalityStatePath() {
|
|
15
|
+
return join(evomapHome(), 'evolution', 'personality_state.json');
|
|
16
|
+
}
|
|
17
|
+
export function assetsDir() {
|
|
18
|
+
return join(evomapHome(), 'assets');
|
|
19
|
+
}
|
|
20
|
+
/** M1 raw-material substrate (append-only jsonl consumed by the cycle). */
|
|
21
|
+
export function materialDir() {
|
|
22
|
+
return join(evomapHome(), 'evolution', 'material');
|
|
23
|
+
}
|
|
24
|
+
/** MaterialStore backing file. */
|
|
25
|
+
export function materialStorePath() {
|
|
26
|
+
return join(materialDir(), 'material.jsonl');
|
|
27
|
+
}
|
|
28
|
+
/** Per-source watermark cursor used to make re-ingest idempotent (file-level dedup). */
|
|
29
|
+
export function materialWatermarkPath() {
|
|
30
|
+
return join(materialDir(), 'watermark.json');
|
|
31
|
+
}
|
|
32
|
+
/** Proxy LLM-trace day-files dir (`llm-trace-YYYYMMDD.jsonl`), the route-savings source for the value ledger.
|
|
33
|
+
* Mirrors the proxy's EVOLVER_LLM_TRACE_DIR default so the outreach layer reads what the proxy wrote. */
|
|
34
|
+
export function tracesDir() {
|
|
35
|
+
return process.env['EVOLVER_LLM_TRACE_DIR'] ?? join(evomapHome(), 'proxy', 'traces');
|
|
36
|
+
}
|
|
37
|
+
/** Hub-asset audit trail (`asset_call_log.jsonl`): one JSONL line per hub-asset interaction (search hit/miss,
|
|
38
|
+
* reuse/reference, publish, review). Written best-effort by AssetCallLog; the desktop's RecallHistory / 召回历程
|
|
39
|
+
* reads it. Defaults to the evomap home root, beside assets/ + evolution/.
|
|
40
|
+
* NOTE(reuse/#234): confirm this matches where the proxy/RecallHistory reads — best-effort append, so a path
|
|
41
|
+
* mismatch degrades the audit line, never the reuse write itself. */
|
|
42
|
+
export function assetCallLogPath() {
|
|
43
|
+
return join(evomapHome(), 'asset_call_log.jsonl');
|
|
44
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Projector } from './replayer.js';
|
|
2
|
+
/** demo MV: 按 type 计数 + lastSeq (真 cycle timeline 见 M0-9). */
|
|
3
|
+
export interface EventCountsMV {
|
|
4
|
+
total: number;
|
|
5
|
+
byType: Record<string, number>;
|
|
6
|
+
lastSeq: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const eventCountsProjector: Projector<EventCountsMV>;
|
|
9
|
+
export declare const DEFAULT_PROJECTORS: readonly Projector[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { cycleTimelineProjector } from '../cycle/cycleTimeline.js';
|
|
2
|
+
export const eventCountsProjector = {
|
|
3
|
+
name: 'event_counts',
|
|
4
|
+
initial: () => ({ total: 0, byType: {}, lastSeq: 0 }),
|
|
5
|
+
reduce: (s, e) => ({
|
|
6
|
+
total: s.total + 1,
|
|
7
|
+
byType: { ...s.byType, [e.type]: (s.byType[e.type] ?? 0) + 1 },
|
|
8
|
+
lastSeq: Math.max(s.lastSeq, e.seq),
|
|
9
|
+
}),
|
|
10
|
+
};
|
|
11
|
+
export const DEFAULT_PROJECTORS = [eventCountsProjector, cycleTimelineProjector];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { Ingestor, EVENT_TYPES, registerEventType, isKnownEventType, IngestValidationError, UnknownEventTypeError } from './ingest.js';
|
|
2
|
+
export type { EventType, IngestorOptions } from './ingest.js';
|
|
3
|
+
export { Replayer } from './replayer.js';
|
|
4
|
+
export type { Projector } from './replayer.js';
|
|
5
|
+
export { eventCountsProjector, DEFAULT_PROJECTORS } from './projectors.js';
|
|
6
|
+
export type { EventCountsMV } from './projectors.js';
|
|
7
|
+
export { LineTooLargeError, MAX_LINE_BYTES } from './eventStore.js';
|
|
8
|
+
export { rootEventsPath, evomapHome, mvDir, personalityStatePath, assetsDir, materialDir, materialStorePath, materialWatermarkPath, tracesDir, assetCallLogPath } from './paths.js';
|
|
9
|
+
export { EVENT_SCHEMA_VERSION } from './eventSchema.js';
|
|
10
|
+
export type { RootEvent, RawEvent, HumanNarrative, Actor, Replayability } from './eventSchema.js';
|
|
11
|
+
export { readEvents, statusReport, listCycles, showCycle, listTriggers, dailySummary, buildNarrativeSnapshot, NARRATIVE_DEFAULT_LIMIT, NARRATIVE_MAX_LIMIT, } from './reports.js';
|
|
12
|
+
export { buildRetentionReport, defaultMaterialCursorPath, RETENTION_DEFAULT_MAX_MATERIAL_BYTES, RETENTION_DEFAULT_MAX_MATERIAL_RECORDS, RETENTION_DEFAULT_MAX_ROOT_BYTES, RETENTION_DEFAULT_MAX_ROOT_EVENTS, RETENTION_DEFAULT_ROOT_TAIL_EVENTS, RETENTION_DEFAULT_WATCH_RATIO, } from './retention.js';
|
|
13
|
+
export type { ReportEvent, StatusReport, CycleSummary, CycleTimeline, TriggerRow, DailySummary, NarrativeEntry, NarrativeOutcome, NarrativeSnapshot, NarrativeSnapshotOptions, } from './reports.js';
|
|
14
|
+
export type { MaterialRetentionSnapshot, RetentionReport, RetentionReportOptions, RetentionState, RetentionThresholds, RootRetentionSnapshot, } from './retention.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { Ingestor, EVENT_TYPES, registerEventType, isKnownEventType, IngestValidationError, UnknownEventTypeError } from './ingest.js';
|
|
2
|
+
export { Replayer } from './replayer.js';
|
|
3
|
+
export { eventCountsProjector, DEFAULT_PROJECTORS } from './projectors.js';
|
|
4
|
+
export { LineTooLargeError, MAX_LINE_BYTES } from './eventStore.js';
|
|
5
|
+
export { rootEventsPath, evomapHome, mvDir, personalityStatePath, assetsDir, materialDir, materialStorePath, materialWatermarkPath, tracesDir, assetCallLogPath } from './paths.js';
|
|
6
|
+
export { EVENT_SCHEMA_VERSION } from './eventSchema.js';
|
|
7
|
+
export { readEvents, statusReport, listCycles, showCycle, listTriggers, dailySummary, buildNarrativeSnapshot, NARRATIVE_DEFAULT_LIMIT, NARRATIVE_MAX_LIMIT, } from './reports.js';
|
|
8
|
+
export { buildRetentionReport, defaultMaterialCursorPath, RETENTION_DEFAULT_MAX_MATERIAL_BYTES, RETENTION_DEFAULT_MAX_MATERIAL_RECORDS, RETENTION_DEFAULT_MAX_ROOT_BYTES, RETENTION_DEFAULT_MAX_ROOT_EVENTS, RETENTION_DEFAULT_ROOT_TAIL_EVENTS, RETENTION_DEFAULT_WATCH_RATIO, } from './retention.js';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { RootEvent } from './eventSchema.js';
|
|
2
|
+
/** 纯函数视图投影器: 由 root_events 折叠出 MV. */
|
|
3
|
+
export interface Projector<S = unknown> {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
initial(): S;
|
|
6
|
+
reduce(state: S, event: RootEvent): S;
|
|
7
|
+
}
|
|
8
|
+
/** AE→MV 分层 (军杰 §3.6). MV 由 root_events 确定性重建, 写保护(#write 私有 + 读深冻结). */
|
|
9
|
+
export declare class Replayer {
|
|
10
|
+
#private;
|
|
11
|
+
readonly dir: string;
|
|
12
|
+
private readonly projectors;
|
|
13
|
+
constructor(opts: {
|
|
14
|
+
dir: string;
|
|
15
|
+
projectors: readonly Projector[];
|
|
16
|
+
});
|
|
17
|
+
private mvPath;
|
|
18
|
+
/** 全量重放重建全部 MV (rebuild-views). */
|
|
19
|
+
rebuild(events: readonly RootEvent[]): void;
|
|
20
|
+
/** 增量: 单事件更新全部 MV. */
|
|
21
|
+
apply(event: RootEvent): void;
|
|
22
|
+
/** 读 MV (深冻结 → 业务代码 mutate 即抛). */
|
|
23
|
+
read<S>(name: string): Readonly<S>;
|
|
24
|
+
/** 删除全部 MV (rebuild-views 前). */
|
|
25
|
+
clear(): void;
|
|
26
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { mkdirSync, existsSync, readFileSync, writeFileSync, rmSync, readdirSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
function deepFreeze(o) {
|
|
4
|
+
if (o && typeof o === 'object') {
|
|
5
|
+
for (const v of Object.values(o))
|
|
6
|
+
deepFreeze(v);
|
|
7
|
+
Object.freeze(o);
|
|
8
|
+
}
|
|
9
|
+
return o;
|
|
10
|
+
}
|
|
11
|
+
/** AE→MV 分层 (军杰 §3.6). MV 由 root_events 确定性重建, 写保护(#write 私有 + 读深冻结). */
|
|
12
|
+
export class Replayer {
|
|
13
|
+
dir;
|
|
14
|
+
projectors;
|
|
15
|
+
constructor(opts) {
|
|
16
|
+
this.dir = opts.dir;
|
|
17
|
+
this.projectors = new Map(opts.projectors.map((p) => [p.name, p]));
|
|
18
|
+
mkdirSync(this.dir, { recursive: true });
|
|
19
|
+
}
|
|
20
|
+
mvPath(name) { return join(this.dir, `${name}.json`); }
|
|
21
|
+
/** 唯一写 MV 路径 (ES 私有, 业务代码无法调用). */
|
|
22
|
+
#write(name, state) {
|
|
23
|
+
writeFileSync(this.mvPath(name), `${JSON.stringify({ _mv: true, _projector: name, state }, null, 2)}\n`);
|
|
24
|
+
}
|
|
25
|
+
/** 全量重放重建全部 MV (rebuild-views). */
|
|
26
|
+
rebuild(events) {
|
|
27
|
+
for (const p of this.projectors.values()) {
|
|
28
|
+
let s = p.initial();
|
|
29
|
+
for (const e of events)
|
|
30
|
+
s = p.reduce(s, e);
|
|
31
|
+
this.#write(p.name, s);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** 增量: 单事件更新全部 MV. */
|
|
35
|
+
apply(event) {
|
|
36
|
+
for (const p of this.projectors.values()) {
|
|
37
|
+
const cur = this.#readRaw(p.name);
|
|
38
|
+
this.#write(p.name, p.reduce((cur === undefined ? p.initial() : cur), event));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
#readRaw(name) {
|
|
42
|
+
const path = this.mvPath(name);
|
|
43
|
+
if (!existsSync(path))
|
|
44
|
+
return undefined;
|
|
45
|
+
const o = JSON.parse(readFileSync(path, 'utf8'));
|
|
46
|
+
return o.state;
|
|
47
|
+
}
|
|
48
|
+
/** 读 MV (深冻结 → 业务代码 mutate 即抛). */
|
|
49
|
+
read(name) {
|
|
50
|
+
const raw = this.#readRaw(name);
|
|
51
|
+
if (raw === undefined) {
|
|
52
|
+
const p = this.projectors.get(name);
|
|
53
|
+
if (!p)
|
|
54
|
+
throw new Error(`未注册 projector: ${name}`);
|
|
55
|
+
return deepFreeze(p.initial());
|
|
56
|
+
}
|
|
57
|
+
return deepFreeze(raw);
|
|
58
|
+
}
|
|
59
|
+
/** 删除全部 MV (rebuild-views 前). */
|
|
60
|
+
clear() {
|
|
61
|
+
if (!existsSync(this.dir))
|
|
62
|
+
return;
|
|
63
|
+
for (const f of readdirSync(this.dir))
|
|
64
|
+
if (f.endsWith('.json'))
|
|
65
|
+
rmSync(join(this.dir, f));
|
|
66
|
+
}
|
|
67
|
+
}
|