@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
package/dist/hub/fake.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { computeAssetId } from '../wire/index.js';
|
|
2
|
+
const fakeAuth = {
|
|
3
|
+
kind: 'oauth_device_token',
|
|
4
|
+
login: async () => ({ id: 'fake-cred', kind: 'oauth_device_token', token: 'fake-token' }),
|
|
5
|
+
authenticate: async () => ({ headers: { authorization: 'Bearer fake-token' } }),
|
|
6
|
+
rotate: async () => ({ id: 'fake-cred-2', kind: 'oauth_device_token', token: 'fake-token-2' }),
|
|
7
|
+
revoke: async () => { },
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* 内存 HubCapability(M6-1, 测试用). 复用 InMemoryTransport 思路, 但走完整 HubCapability 形状,
|
|
11
|
+
* 让 SyncEngine/LifecycleManager/bindings 不连真 hub 即可端到端测.
|
|
12
|
+
*/
|
|
13
|
+
export class FakeHubCapability {
|
|
14
|
+
opts;
|
|
15
|
+
assets = new Map();
|
|
16
|
+
inbox = [];
|
|
17
|
+
acked = new Set();
|
|
18
|
+
pushed = [];
|
|
19
|
+
claims = [];
|
|
20
|
+
completed = [];
|
|
21
|
+
auth = fakeAuth;
|
|
22
|
+
nextPollAfterMs;
|
|
23
|
+
constructor(opts = {}) {
|
|
24
|
+
this.opts = opts;
|
|
25
|
+
}
|
|
26
|
+
/** 测试注入: 排一条 inbound 事件供 poll 拉. */
|
|
27
|
+
seedInbound(e) { this.inbox.push(e); }
|
|
28
|
+
async publish(bundle) {
|
|
29
|
+
const assetIds = bundle.map((a) => computeAssetId(a));
|
|
30
|
+
const gate = this.opts.publishGate?.(bundle[0] ?? {}) ?? { status: 'accepted' };
|
|
31
|
+
if (gate.status === 'accepted')
|
|
32
|
+
bundle.forEach((a, i) => this.assets.set(assetIds[i], { ...a, asset_id: assetIds[i] }));
|
|
33
|
+
return { receiptId: `rcpt-${(assetIds[0] ?? 'x').slice(7, 15)}`, status: gate.status, assetId: assetIds[0], assetIds, bundleId: `bundle-${(assetIds[0] ?? 'x').slice(7, 15)}`, ...(gate.reason ? { reason: gate.reason } : {}), ...(gate.terminal !== undefined ? { terminal: gate.terminal } : {}) };
|
|
34
|
+
}
|
|
35
|
+
async fetch(query) {
|
|
36
|
+
return [...this.assets.values()].filter((a) => !query.kind || a.type === query.kind).slice(0, query.limit ?? 1000);
|
|
37
|
+
}
|
|
38
|
+
search(query) { return this.fetch(query); }
|
|
39
|
+
task = {
|
|
40
|
+
claim: async (taskId) => {
|
|
41
|
+
const claimId = `claim-${taskId}`;
|
|
42
|
+
this.claims.push({ taskId, claimId });
|
|
43
|
+
return { claimId };
|
|
44
|
+
},
|
|
45
|
+
complete: async (claimId, result) => {
|
|
46
|
+
this.completed.push({ claimId, result });
|
|
47
|
+
return { status: 'completed' };
|
|
48
|
+
},
|
|
49
|
+
subscribe: async function* () {
|
|
50
|
+
/* 内存桩: 空流 */
|
|
51
|
+
}.bind(this),
|
|
52
|
+
};
|
|
53
|
+
mailbox = {
|
|
54
|
+
poll: async () => {
|
|
55
|
+
const events = this.inbox.splice(0);
|
|
56
|
+
return { events, ...(this.nextPollAfterMs !== undefined ? { nextPollAfterMs: this.nextPollAfterMs } : {}), hasMore: this.inbox.length > 0 };
|
|
57
|
+
},
|
|
58
|
+
ack: async (eventId) => { this.acked.add(eventId); },
|
|
59
|
+
push: async (event) => { this.pushed.push(event); },
|
|
60
|
+
pushMany: async (events) => {
|
|
61
|
+
this.pushed.push(...events);
|
|
62
|
+
return { outcomes: events.map((event) => ({ id: event.id, status: 'accepted' })) };
|
|
63
|
+
},
|
|
64
|
+
status: async () => ({ pending: this.inbox.length }),
|
|
65
|
+
};
|
|
66
|
+
/** 测试断言用. */
|
|
67
|
+
isAcked(id) { return this.acked.has(id); }
|
|
68
|
+
publishedCount() { return this.assets.size; }
|
|
69
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { AssetCallLog } from './assetCallLog.js';
|
|
2
|
+
export interface ReviewOutcome {
|
|
3
|
+
status?: string;
|
|
4
|
+
score?: number;
|
|
5
|
+
}
|
|
6
|
+
export interface ConstraintCheck {
|
|
7
|
+
violations?: readonly unknown[];
|
|
8
|
+
}
|
|
9
|
+
/** Submit a review to the hub. Resolve {ok:false,error} for a rejection; reject/throw for a transport error. */
|
|
10
|
+
export type ReviewSubmitter = (assetId: string, review: {
|
|
11
|
+
sender_id?: string;
|
|
12
|
+
rating: number;
|
|
13
|
+
content: string;
|
|
14
|
+
}) => Promise<{
|
|
15
|
+
ok: boolean;
|
|
16
|
+
status?: number;
|
|
17
|
+
error?: string;
|
|
18
|
+
}>;
|
|
19
|
+
export interface ReviewHistoryStore {
|
|
20
|
+
has(assetId: string): boolean;
|
|
21
|
+
mark(assetId: string, rec: {
|
|
22
|
+
rating: number;
|
|
23
|
+
success: boolean;
|
|
24
|
+
at: number;
|
|
25
|
+
}): void;
|
|
26
|
+
}
|
|
27
|
+
/** Derive a 1-5 rating from the cycle outcome. success→{5 if score≥0.85 else 4}; failure→{1 if constraint-violating else 2}. */
|
|
28
|
+
export declare function deriveRating(outcome?: ReviewOutcome, constraintCheck?: ConstraintCheck): number;
|
|
29
|
+
export interface ReviewContentParams {
|
|
30
|
+
outcome?: ReviewOutcome;
|
|
31
|
+
gene?: {
|
|
32
|
+
id?: string;
|
|
33
|
+
category?: string;
|
|
34
|
+
};
|
|
35
|
+
signals?: readonly string[];
|
|
36
|
+
blast?: {
|
|
37
|
+
files?: number;
|
|
38
|
+
lines?: number;
|
|
39
|
+
};
|
|
40
|
+
sourceType?: string;
|
|
41
|
+
}
|
|
42
|
+
/** Human-readable review body summarising the reuse outcome (capped 2000 chars). */
|
|
43
|
+
export declare function buildReviewContent({ outcome, gene, signals, blast, sourceType }: ReviewContentParams): string;
|
|
44
|
+
export interface SubmitHubReviewDeps {
|
|
45
|
+
submit: ReviewSubmitter;
|
|
46
|
+
history?: ReviewHistoryStore;
|
|
47
|
+
assetLog?: Pick<AssetCallLog, 'append'>;
|
|
48
|
+
senderId?: string;
|
|
49
|
+
now?: () => number;
|
|
50
|
+
}
|
|
51
|
+
export interface SubmitHubReviewParams {
|
|
52
|
+
reusedAssetId: string;
|
|
53
|
+
/** Only 'reused' / 'reference' are hub-sourced (others are skipped). */
|
|
54
|
+
sourceType: string;
|
|
55
|
+
outcome?: ReviewOutcome;
|
|
56
|
+
gene?: {
|
|
57
|
+
id?: string;
|
|
58
|
+
category?: string;
|
|
59
|
+
};
|
|
60
|
+
signals?: readonly string[];
|
|
61
|
+
blast?: {
|
|
62
|
+
files?: number;
|
|
63
|
+
lines?: number;
|
|
64
|
+
};
|
|
65
|
+
constraintCheck?: ConstraintCheck;
|
|
66
|
+
runId?: string | null;
|
|
67
|
+
}
|
|
68
|
+
export interface SubmitHubReviewResult {
|
|
69
|
+
submitted: boolean;
|
|
70
|
+
reason?: string;
|
|
71
|
+
rating?: number;
|
|
72
|
+
asset_id?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Submit a usage-verified review for a reused hub asset. Skips when: not hub-sourced, no asset id, or already
|
|
76
|
+
* reviewed. Never throws — a transport error is logged and swallowed (solidify must not be affected).
|
|
77
|
+
*/
|
|
78
|
+
export declare function submitHubReview(deps: SubmitHubReviewDeps, params: SubmitHubReviewParams): Promise<SubmitHubReviewResult>;
|
|
79
|
+
/** File-backed ReviewHistoryStore: a JSON map assetId → {at,rating,success}, capped to the most recent N (atomic write). */
|
|
80
|
+
export declare class FileReviewHistory implements ReviewHistoryStore {
|
|
81
|
+
private readonly path;
|
|
82
|
+
private readonly max;
|
|
83
|
+
constructor(path: string, max?: number);
|
|
84
|
+
private load;
|
|
85
|
+
has(assetId: string): boolean;
|
|
86
|
+
mark(assetId: string, rec: {
|
|
87
|
+
rating: number;
|
|
88
|
+
success: boolean;
|
|
89
|
+
at: number;
|
|
90
|
+
}): void;
|
|
91
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// Hub asset review (ported from v1 gep/hubReview.js). When an evolution cycle REUSED a hub asset, this submits
|
|
2
|
+
// a usage-verified review back to the hub after solidify — closing the quality-feedback loop so the hub can
|
|
3
|
+
// rank assets by whether reuse actually paid off (the evolver side of fetch→outcome attribution). Rating is
|
|
4
|
+
// derived from the cycle outcome: success → 4-5, failure → 1-2 (a constraint-violating reuse gets the worst
|
|
5
|
+
// rating, tying into the exec policy gate). Non-blocking: errors never affect solidify. Dedup via an injected
|
|
6
|
+
// history store. The hub POST is an injected ReviewSubmitter seam, so this is transport-agnostic and testable.
|
|
7
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
|
|
8
|
+
import { dirname } from 'node:path';
|
|
9
|
+
/** Derive a 1-5 rating from the cycle outcome. success→{5 if score≥0.85 else 4}; failure→{1 if constraint-violating else 2}. */
|
|
10
|
+
export function deriveRating(outcome, constraintCheck) {
|
|
11
|
+
if (outcome && outcome.status === 'success') {
|
|
12
|
+
const score = Number(outcome.score) || 0;
|
|
13
|
+
return score >= 0.85 ? 5 : 4;
|
|
14
|
+
}
|
|
15
|
+
const violated = !!constraintCheck && Array.isArray(constraintCheck.violations) && constraintCheck.violations.length > 0;
|
|
16
|
+
return violated ? 1 : 2;
|
|
17
|
+
}
|
|
18
|
+
/** Human-readable review body summarising the reuse outcome (capped 2000 chars). */
|
|
19
|
+
export function buildReviewContent({ outcome, gene, signals, blast, sourceType }) {
|
|
20
|
+
const status = outcome?.status ?? 'unknown';
|
|
21
|
+
const score = outcome && Number.isFinite(Number(outcome.score)) ? Number(outcome.score).toFixed(2) : '?';
|
|
22
|
+
const parts = [`Outcome: ${status} (score: ${score})`, `Reuse mode: ${sourceType ?? 'unknown'}`];
|
|
23
|
+
if (gene?.id)
|
|
24
|
+
parts.push(`Gene: ${gene.id} (${gene.category ?? 'unknown'})`);
|
|
25
|
+
if (Array.isArray(signals) && signals.length > 0)
|
|
26
|
+
parts.push(`Signals: ${signals.slice(0, 6).join(', ')}`);
|
|
27
|
+
if (blast)
|
|
28
|
+
parts.push(`Blast radius: ${blast.files ?? 0} file(s), ${blast.lines ?? 0} line(s)`);
|
|
29
|
+
parts.push(status === 'success'
|
|
30
|
+
? 'The fetched asset was successfully applied and solidified.'
|
|
31
|
+
: 'The fetched asset did not lead to a successful evolution cycle.');
|
|
32
|
+
return parts.join('\n').slice(0, 2000);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Submit a usage-verified review for a reused hub asset. Skips when: not hub-sourced, no asset id, or already
|
|
36
|
+
* reviewed. Never throws — a transport error is logged and swallowed (solidify must not be affected).
|
|
37
|
+
*/
|
|
38
|
+
export async function submitHubReview(deps, params) {
|
|
39
|
+
const { reusedAssetId, sourceType, outcome, gene, signals, blast, constraintCheck, runId = null } = params;
|
|
40
|
+
const now = deps.now ?? (() => Date.now());
|
|
41
|
+
if (!reusedAssetId || typeof reusedAssetId !== 'string')
|
|
42
|
+
return { submitted: false, reason: 'no_reused_asset_id' };
|
|
43
|
+
if (sourceType !== 'reused' && sourceType !== 'reference')
|
|
44
|
+
return { submitted: false, reason: 'not_hub_sourced' };
|
|
45
|
+
if (deps.history?.has(reusedAssetId))
|
|
46
|
+
return { submitted: false, reason: 'already_reviewed' };
|
|
47
|
+
const rating = deriveRating(outcome, constraintCheck);
|
|
48
|
+
const content = buildReviewContent({ outcome, gene, signals, blast, sourceType });
|
|
49
|
+
try {
|
|
50
|
+
const res = await deps.submit(reusedAssetId, { ...(deps.senderId ? { sender_id: deps.senderId } : {}), rating, content });
|
|
51
|
+
if (res.ok) {
|
|
52
|
+
deps.history?.mark(reusedAssetId, { rating, success: true, at: now() });
|
|
53
|
+
deps.assetLog?.append({ run_id: runId, action: 'hub_review_submitted', asset_id: reusedAssetId, extra: { rating, outcome_status: outcome?.status } });
|
|
54
|
+
return { submitted: true, rating, asset_id: reusedAssetId };
|
|
55
|
+
}
|
|
56
|
+
const errCode = res.error ?? `http_${res.status ?? 0}`;
|
|
57
|
+
if (errCode === 'already_reviewed')
|
|
58
|
+
deps.history?.mark(reusedAssetId, { rating, success: false, at: now() });
|
|
59
|
+
deps.assetLog?.append({ run_id: runId, action: 'hub_review_rejected', asset_id: reusedAssetId, extra: { rating, error: errCode } });
|
|
60
|
+
return { submitted: false, reason: errCode, rating };
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
const reason = err instanceof Error && err.name === 'AbortError' ? 'timeout' : 'fetch_error';
|
|
64
|
+
deps.assetLog?.append({ run_id: runId, action: 'hub_review_failed', asset_id: reusedAssetId, extra: { rating, reason, error: err instanceof Error ? err.message : String(err) } });
|
|
65
|
+
return { submitted: false, reason, rating };
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const HISTORY_MAX = 500;
|
|
69
|
+
/** File-backed ReviewHistoryStore: a JSON map assetId → {at,rating,success}, capped to the most recent N (atomic write). */
|
|
70
|
+
export class FileReviewHistory {
|
|
71
|
+
path;
|
|
72
|
+
max;
|
|
73
|
+
constructor(path, max = HISTORY_MAX) {
|
|
74
|
+
this.path = path;
|
|
75
|
+
this.max = max;
|
|
76
|
+
}
|
|
77
|
+
load() {
|
|
78
|
+
try {
|
|
79
|
+
if (!existsSync(this.path))
|
|
80
|
+
return {};
|
|
81
|
+
const raw = readFileSync(this.path, 'utf8').trim();
|
|
82
|
+
return raw ? JSON.parse(raw) : {};
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return {};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
has(assetId) { return !!this.load()[assetId]; }
|
|
89
|
+
mark(assetId, rec) {
|
|
90
|
+
try {
|
|
91
|
+
const history = this.load();
|
|
92
|
+
history[assetId] = rec;
|
|
93
|
+
const keys = Object.keys(history);
|
|
94
|
+
if (keys.length > this.max) {
|
|
95
|
+
const oldest = keys.map((k) => ({ k, t: history[k].at || 0 })).sort((a, b) => a.t - b.t).slice(0, keys.length - this.max);
|
|
96
|
+
for (const { k } of oldest)
|
|
97
|
+
delete history[k];
|
|
98
|
+
}
|
|
99
|
+
mkdirSync(dirname(this.path), { recursive: true });
|
|
100
|
+
const tmp = `${this.path}.tmp`;
|
|
101
|
+
writeFileSync(tmp, `${JSON.stringify(history, null, 2)}\n`, 'utf8');
|
|
102
|
+
renameSync(tmp, this.path);
|
|
103
|
+
}
|
|
104
|
+
catch { /* non-fatal */ }
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './capability.js';
|
|
2
|
+
export * from './fake.js';
|
|
3
|
+
export * from './bindings.js';
|
|
4
|
+
export * from './sanitize.js';
|
|
5
|
+
export * from './ingest.js';
|
|
6
|
+
export * from './assetCallLog.js';
|
|
7
|
+
export * from './hubReview.js';
|
|
8
|
+
export * from './reuseDecision.js';
|
|
9
|
+
export * from './conversationDistiller.js';
|
|
10
|
+
export * from './questionGenerator.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './capability.js';
|
|
2
|
+
export * from './fake.js';
|
|
3
|
+
export * from './bindings.js';
|
|
4
|
+
export * from './sanitize.js';
|
|
5
|
+
export * from './ingest.js';
|
|
6
|
+
export * from './assetCallLog.js';
|
|
7
|
+
export * from './hubReview.js';
|
|
8
|
+
export * from './reuseDecision.js';
|
|
9
|
+
export * from './conversationDistiller.js';
|
|
10
|
+
export * from './questionGenerator.js';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { HubCapability, HubQuery } from './capability.js';
|
|
2
|
+
import type { AssetStoreProvider } from '../assetstore/provider.js';
|
|
3
|
+
import { type ProvenanceStore } from '../assetstore/provenance.js';
|
|
4
|
+
export interface HubIngestResult {
|
|
5
|
+
ingested: number;
|
|
6
|
+
assetIds: string[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Fetch assets from the hub and land each into the local store as UNTRUSTED. store.put recomputes the
|
|
10
|
+
* asset_id (a remote-supplied id is never trusted) and the provenance sidecar marks each untrusted.
|
|
11
|
+
* mode 'search' uses the hub's recall strategy; 'fetch' (default) is a direct pull.
|
|
12
|
+
*/
|
|
13
|
+
export declare function ingestFromHub(cap: HubCapability, store: AssetStoreProvider, provenance: ProvenanceStore, query: HubQuery, opts?: {
|
|
14
|
+
mode?: 'fetch' | 'search';
|
|
15
|
+
}): Promise<HubIngestResult>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ingestUntrusted } from '../assetstore/provenance.js';
|
|
2
|
+
/**
|
|
3
|
+
* Fetch assets from the hub and land each into the local store as UNTRUSTED. store.put recomputes the
|
|
4
|
+
* asset_id (a remote-supplied id is never trusted) and the provenance sidecar marks each untrusted.
|
|
5
|
+
* mode 'search' uses the hub's recall strategy; 'fetch' (default) is a direct pull.
|
|
6
|
+
*/
|
|
7
|
+
export async function ingestFromHub(cap, store, provenance, query, opts = {}) {
|
|
8
|
+
const records = await (opts.mode === 'search' ? cap.search(query) : cap.fetch(query));
|
|
9
|
+
const assetIds = [];
|
|
10
|
+
for (const rec of records) {
|
|
11
|
+
const r = await ingestUntrusted(store, provenance, rec, 'hub');
|
|
12
|
+
assetIds.push(r.asset_id);
|
|
13
|
+
}
|
|
14
|
+
return { ingested: assetIds.length, assetIds };
|
|
15
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { HubQuestion } from './capability.js';
|
|
2
|
+
export declare const QUESTION_INTERVAL_MS: number;
|
|
3
|
+
export declare const URGENT_QUESTION_INTERVAL_MS: number;
|
|
4
|
+
export declare const EXPLORATION_QUESTION_INTERVAL_MS: number;
|
|
5
|
+
export declare const MAX_QUESTIONS_PER_CYCLE = 3;
|
|
6
|
+
export declare const MAX_URGENT_QUESTIONS = 2;
|
|
7
|
+
export declare const URGENT_QUESTION_RUNTIME_WIRING_STATUS: {
|
|
8
|
+
readonly status: "deferred";
|
|
9
|
+
readonly reason: "urgent_question_runtime_wiring_not_connected";
|
|
10
|
+
};
|
|
11
|
+
export interface QuestionGeneratorState {
|
|
12
|
+
lastAskedAt?: string | null;
|
|
13
|
+
lastUrgentAt?: string | null;
|
|
14
|
+
lastExploreAt?: string | null;
|
|
15
|
+
recentQuestions?: readonly string[];
|
|
16
|
+
}
|
|
17
|
+
export interface RecentEvolutionEventLike {
|
|
18
|
+
genes_used?: readonly string[];
|
|
19
|
+
genesUsed?: readonly string[];
|
|
20
|
+
}
|
|
21
|
+
export interface GenerateQuestionsInput {
|
|
22
|
+
signals?: readonly string[];
|
|
23
|
+
recentEvents?: readonly RecentEvolutionEventLike[];
|
|
24
|
+
sessionTranscript?: string;
|
|
25
|
+
memorySnippet?: string;
|
|
26
|
+
state?: QuestionGeneratorState;
|
|
27
|
+
now?: number;
|
|
28
|
+
env?: Record<string, string | undefined>;
|
|
29
|
+
explorationEnabled?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface GenerateUrgentQuestionsInput {
|
|
32
|
+
validationFailed?: boolean;
|
|
33
|
+
validationErrors?: string;
|
|
34
|
+
geneId?: string;
|
|
35
|
+
lowConfidence?: boolean;
|
|
36
|
+
confidenceScore?: number;
|
|
37
|
+
intent?: string;
|
|
38
|
+
llmReviewRejected?: boolean;
|
|
39
|
+
llmReviewReason?: string;
|
|
40
|
+
zeroBlastRadius?: boolean;
|
|
41
|
+
hadSignals?: boolean;
|
|
42
|
+
signals?: readonly string[];
|
|
43
|
+
taskCompletionFailed?: boolean;
|
|
44
|
+
taskTitle?: string;
|
|
45
|
+
taskSignals?: string;
|
|
46
|
+
state?: QuestionGeneratorState;
|
|
47
|
+
now?: number;
|
|
48
|
+
}
|
|
49
|
+
export interface GeneratedQuestion extends HubQuestion {
|
|
50
|
+
priority: number;
|
|
51
|
+
}
|
|
52
|
+
export interface QuestionGenerationResult {
|
|
53
|
+
questions: HubQuestion[];
|
|
54
|
+
state: QuestionGeneratorState;
|
|
55
|
+
changed: boolean;
|
|
56
|
+
}
|
|
57
|
+
export declare function extractTopicKeywords(transcript: string | undefined, memory: string | undefined, max?: number): string[];
|
|
58
|
+
export declare function generateQuestions(input?: GenerateQuestionsInput): QuestionGenerationResult;
|
|
59
|
+
export declare function generateUrgentQuestions(input?: GenerateUrgentQuestionsInput): QuestionGenerationResult;
|