@ashlr/hub 3.2.7 → 3.3.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/CHANGELOG.md +268 -0
- package/README.md +4 -1
- package/dist/build-identity.json +2 -2
- package/dist/cli/activation.d.ts +41 -0
- package/dist/cli/activation.js +485 -0
- package/dist/cli/activation.js.map +1 -0
- package/dist/cli/audit.js +18 -0
- package/dist/cli/audit.js.map +1 -1
- package/dist/cli/backlog.d.ts +0 -5
- package/dist/cli/backlog.js +18 -0
- package/dist/cli/backlog.js.map +1 -1
- package/dist/cli/comms.js +20 -0
- package/dist/cli/comms.js.map +1 -1
- package/dist/cli/completions.d.ts +6 -1
- package/dist/cli/completions.js +35 -11
- package/dist/cli/completions.js.map +1 -1
- package/dist/cli/daemon.js +10 -3
- package/dist/cli/daemon.js.map +1 -1
- package/dist/cli/demo.d.ts +0 -27
- package/dist/cli/demo.js +17 -0
- package/dist/cli/demo.js.map +1 -1
- package/dist/cli/help.js +19 -3
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/inbox.d.ts +14 -2
- package/dist/cli/inbox.js +137 -23
- package/dist/cli/inbox.js.map +1 -1
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +10 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/onboard.d.ts +0 -13
- package/dist/cli/onboard.js +20 -0
- package/dist/cli/onboard.js.map +1 -1
- package/dist/cli/resources.js +15 -0
- package/dist/cli/resources.js.map +1 -1
- package/dist/cli/run.js +1 -1
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/sandbox.js +43 -0
- package/dist/cli/sandbox.js.map +1 -1
- package/dist/cli/tui.d.ts +0 -6
- package/dist/cli/tui.js +14 -0
- package/dist/cli/tui.js.map +1 -1
- package/dist/core/config.js +70 -0
- package/dist/core/config.js.map +1 -1
- package/dist/core/daemon/activation-permit.d.ts +268 -33
- package/dist/core/daemon/activation-permit.js +1111 -106
- package/dist/core/daemon/activation-permit.js.map +1 -1
- package/dist/core/daemon/loop.d.ts +13 -1
- package/dist/core/daemon/loop.js +192 -9
- package/dist/core/daemon/loop.js.map +1 -1
- package/dist/core/daemon/runtime-activation-resident-start-protocol.d.ts +141 -0
- package/dist/core/daemon/runtime-activation-resident-start-protocol.js +462 -0
- package/dist/core/daemon/runtime-activation-resident-start-protocol.js.map +1 -0
- package/dist/core/daemon/runtime-activation-resident-start-runtime.d.ts +27 -0
- package/dist/core/daemon/runtime-activation-resident-start-runtime.js +28 -0
- package/dist/core/daemon/runtime-activation-resident-start-runtime.js.map +1 -0
- package/dist/core/daemon/runtime-activation-stopped-consumer.d.ts +139 -0
- package/dist/core/daemon/runtime-activation-stopped-consumer.js +995 -0
- package/dist/core/daemon/runtime-activation-stopped-consumer.js.map +1 -0
- package/dist/core/daemon/runtime-activation-stopped-runtime.d.ts +36 -0
- package/dist/core/daemon/runtime-activation-stopped-runtime.js +134 -0
- package/dist/core/daemon/runtime-activation-stopped-runtime.js.map +1 -0
- package/dist/core/daemon/runtime-activation-transaction.d.ts +41 -17
- package/dist/core/daemon/runtime-activation-transaction.js +80 -11
- package/dist/core/daemon/runtime-activation-transaction.js.map +1 -1
- package/dist/core/daemon/runtime-release-dependency-inventory.js +1 -0
- package/dist/core/daemon/runtime-release-dependency-inventory.js.map +1 -1
- package/dist/core/daemon/service-install-authority.d.ts +0 -4
- package/dist/core/daemon/service-install-authority.js +18 -3
- package/dist/core/daemon/service-install-authority.js.map +1 -1
- package/dist/core/dashboard.d.ts +10 -0
- package/dist/core/dashboard.js +103 -28
- package/dist/core/dashboard.js.map +1 -1
- package/dist/core/effective-config.js +7 -0
- package/dist/core/effective-config.js.map +1 -1
- package/dist/core/fleet/automerge-pass.js +33 -0
- package/dist/core/fleet/automerge-pass.js.map +1 -1
- package/dist/core/fleet/decisions-ledger.js +35 -12
- package/dist/core/fleet/decisions-ledger.js.map +1 -1
- package/dist/core/fleet/external-skill-git-capture.js +9 -1
- package/dist/core/fleet/external-skill-git-capture.js.map +1 -1
- package/dist/core/fleet/judge-decision-metadata.d.ts +8 -1
- package/dist/core/fleet/judge-decision-metadata.js +14 -1
- package/dist/core/fleet/judge-decision-metadata.js.map +1 -1
- package/dist/core/fleet/manager.d.ts +15 -1
- package/dist/core/fleet/manager.js +108 -30
- package/dist/core/fleet/manager.js.map +1 -1
- package/dist/core/fleet/post-merge-credit.d.ts +134 -9
- package/dist/core/fleet/post-merge-credit.js +350 -10
- package/dist/core/fleet/post-merge-credit.js.map +1 -1
- package/dist/core/fleet/self-improve.d.ts +34 -1
- package/dist/core/fleet/self-improve.js +106 -1
- package/dist/core/fleet/self-improve.js.map +1 -1
- package/dist/core/fleet/skill-library.d.ts +21 -2
- package/dist/core/fleet/skill-library.js +54 -12
- package/dist/core/fleet/skill-library.js.map +1 -1
- package/dist/core/fleet/status.js +1 -0
- package/dist/core/fleet/status.js.map +1 -1
- package/dist/core/fleet/worked-ledger.d.ts +22 -0
- package/dist/core/fleet/worked-ledger.js +32 -0
- package/dist/core/fleet/worked-ledger.js.map +1 -1
- package/dist/core/foundry/automerge-scope-policy.d.ts +2 -2
- package/dist/core/foundry/automerge-scope-policy.js +9 -2
- package/dist/core/foundry/automerge-scope-policy.js.map +1 -1
- package/dist/core/goals/store.js +18 -4
- package/dist/core/goals/store.js.map +1 -1
- package/dist/core/inbox/apply.js +5 -2
- package/dist/core/inbox/apply.js.map +1 -1
- package/dist/core/inbox/merge.d.ts +94 -1
- package/dist/core/inbox/merge.js +349 -16
- package/dist/core/inbox/merge.js.map +1 -1
- package/dist/core/integrations/github.d.ts +2 -0
- package/dist/core/integrations/github.js +2 -1
- package/dist/core/integrations/github.js.map +1 -1
- package/dist/core/learn/reflect.d.ts +42 -4
- package/dist/core/learn/reflect.js +56 -5
- package/dist/core/learn/reflect.js.map +1 -1
- package/dist/core/run/engines.d.ts +8 -0
- package/dist/core/run/engines.js +9 -1
- package/dist/core/run/engines.js.map +1 -1
- package/dist/core/run/learned-router.js +28 -3
- package/dist/core/run/learned-router.js.map +1 -1
- package/dist/core/run/orchestrator.d.ts +7 -2
- package/dist/core/run/orchestrator.js +86 -60
- package/dist/core/run/orchestrator.js.map +1 -1
- package/dist/core/swarm/rollback.d.ts +11 -0
- package/dist/core/swarm/rollback.js +54 -0
- package/dist/core/swarm/rollback.js.map +1 -1
- package/dist/core/swarm/runner.js +94 -8
- package/dist/core/swarm/runner.js.map +1 -1
- package/dist/core/types.d.ts +100 -1
- package/dist/core/types.js.map +1 -1
- package/dist/core/web/api.js +105 -7
- package/dist/core/web/api.js.map +1 -1
- package/dist/core/web/control.d.ts +20 -0
- package/dist/core/web/control.js +44 -32
- package/dist/core/web/control.js.map +1 -1
- package/dist/core/web/fleet-status-cache.d.ts +68 -0
- package/dist/core/web/fleet-status-cache.js +120 -0
- package/dist/core/web/fleet-status-cache.js.map +1 -0
- package/dist/core/web/public/next/assets/index-CY0U241s.css +1 -0
- package/dist/core/web/public/next/assets/index-Ct0mf8n4.js +69 -0
- package/dist/core/web/public/next/assets/index-Ct0mf8n4.js.map +1 -0
- package/dist/core/web/public/next/index.html +15 -0
- package/dist/release-dependency-inventory.json +1 -1
- package/docs/RUNTIME_ACTIVATION_AUTHORITY.md +126 -21
- package/docs/contracts/CONTRACT-M521.md +102 -0
- package/package.json +20 -3
- package/schema/config.schema.json +800 -5
- package/node_modules/which/CHANGELOG.md +0 -166
|
@@ -1,11 +1,56 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Positive post-merge learning authority.
|
|
2
|
+
* Positive post-merge learning authority — the release protocol.
|
|
3
3
|
*
|
|
4
|
-
* A realized merge is an immutable operational fact, not proof that the
|
|
5
|
-
* remained beneficial.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* A realized merge is an immutable operational fact, not proof that the
|
|
5
|
+
* change remained beneficial. This module is the ONLY place allowed to mint
|
|
6
|
+
* "post-merge credit release" authority, and it does so conservatively:
|
|
7
|
+
*
|
|
8
|
+
* 1. The proposal must carry an AUTHENTICATED realized-merge witness
|
|
9
|
+
* (authenticatedRealizedMergeOf — binds to this exact proposal via a
|
|
10
|
+
* local receipt HMAC or host reconciliation; shape alone is never
|
|
11
|
+
* authority).
|
|
12
|
+
* 2. At least MIN_POST_MERGE_OBSERVATION_WINDOW_MS must have elapsed since
|
|
13
|
+
* the merge was observed. The regression sentinel / outcome watcher
|
|
14
|
+
* (outcome-watcher.ts) sweeps merged proposals on a 6h throttle with a
|
|
15
|
+
* 7-day follow-up window; 14 days gives ~2x that follow-up window and
|
|
16
|
+
* dozens of scan cycles of headroom before we trust the silence.
|
|
17
|
+
* 3. The signed, observation-only post-merge-observations ledger
|
|
18
|
+
* (post-merge-observations.ts) must contain NO adverse record
|
|
19
|
+
* ('regressed' | 'reverted' | 'followed-up') for this exact
|
|
20
|
+
* (repo, proposalId, mergeCommit) event, and the ledger must have read
|
|
21
|
+
* back healthy/complete (a degraded read fails closed — we never treat
|
|
22
|
+
* "couldn't check" as "checked clean").
|
|
23
|
+
*
|
|
24
|
+
* That ledger is adverse-only (it never records a positive "we checked, it's
|
|
25
|
+
* clean" row), so eligibility here is inherently a "silence after a
|
|
26
|
+
* conservative window" heuristic, not a positive confirmation. That is a
|
|
27
|
+
* known, documented limitation — see sweepPostMergeCreditReleases' doc
|
|
28
|
+
* comment — not an oversight.
|
|
29
|
+
*
|
|
30
|
+
* MINTING: hasReleasedPostMergeCredit(labelBasis) verifies a self-describing,
|
|
31
|
+
* HMAC-signed token — NOT bare string equality against
|
|
32
|
+
* POST_MERGE_CREDIT_RELEASE_LABEL. This is deliberate: several downstream
|
|
33
|
+
* consumers persist labelBasis-shaped fields on structures that are, at least
|
|
34
|
+
* in tests and in caller-authored proposal/ledger data, fully attacker/
|
|
35
|
+
* test-controlled. A bare literal is trivially replayable; only a value
|
|
36
|
+
* carrying a valid local-key HMAC over the specific (repo, proposalId,
|
|
37
|
+
* mergeCommit) event can pass. isPostMergeCreditReleaseLabel() remains
|
|
38
|
+
* "structural recognition only" — matching the bare literal — for the
|
|
39
|
+
* existing defensive filters elsewhere that specifically reject the
|
|
40
|
+
* unauthenticated literal (e.g. skill-records.ts, decisions-ledger.ts).
|
|
8
41
|
*/
|
|
42
|
+
import { createHmac, timingSafeEqual } from 'node:crypto';
|
|
43
|
+
import { resolve } from 'node:path';
|
|
44
|
+
import { loadOrCreateKey, signSkillCardAttestation } from '../foundry/provenance.js';
|
|
45
|
+
import { authenticatedRealizedMergeOf } from '../inbox/realized-merge.js';
|
|
46
|
+
import { listProposalsDetailed } from '../inbox/store.js';
|
|
47
|
+
import { causalMetadataFromProposal } from '../learning/causal.js';
|
|
48
|
+
import { readDecisions, recordDecision } from './decisions-ledger.js';
|
|
49
|
+
import { postMergeObservationEventId, readPostMergeObservations } from './post-merge-observations.js';
|
|
50
|
+
import { skillCardContentHash } from './skill-attestation.js';
|
|
51
|
+
// ---------------------------------------------------------------------------
|
|
52
|
+
// Structural constants
|
|
53
|
+
// ---------------------------------------------------------------------------
|
|
9
54
|
export const POST_MERGE_CREDIT_POLICY_VERSION = 'post-merge-credit-v1';
|
|
10
55
|
export const POST_MERGE_CREDIT_RELEASE_LABEL = 'post-merge-credit-release-v1';
|
|
11
56
|
/** Structural recognition only; this string is not release authority. */
|
|
@@ -13,11 +58,306 @@ export function isPostMergeCreditReleaseLabel(labelBasis) {
|
|
|
13
58
|
return labelBasis === POST_MERGE_CREDIT_RELEASE_LABEL;
|
|
14
59
|
}
|
|
15
60
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
61
|
+
* Minimum wall-clock time since the realized merge before credit MAY be
|
|
62
|
+
* released. See module doc for rationale (~2x the outcome-watcher follow-up
|
|
63
|
+
* window, dozens of throttled scan cycles of headroom).
|
|
64
|
+
*/
|
|
65
|
+
export const MIN_POST_MERGE_OBSERVATION_WINDOW_MS = 14 * 24 * 60 * 60 * 1000;
|
|
66
|
+
/** Domain-separated HMAC payload prefix for minted credit tokens. */
|
|
67
|
+
const CREDIT_TOKEN_DOMAIN = 'ashlr:post-merge-credit-release:v1';
|
|
68
|
+
/**
|
|
69
|
+
* Both segments are truncated to 24 hex chars (96 bits each) — plenty for
|
|
70
|
+
* MAC-forgery infeasibility and event-identifier collision-resistance at
|
|
71
|
+
* fleet scale, and DELIBERATELY short for two independent reasons discovered
|
|
72
|
+
* empirically (see test/post-merge-credit-release.test.ts):
|
|
73
|
+
* 1. decisions-ledger.ts's generic secret-scrubber (util/scrub.ts) redacts
|
|
74
|
+
* any bare 64+ char hex run as a likely API key/hash — a 64-char segment
|
|
75
|
+
* would be silently corrupted the moment it passed through
|
|
76
|
+
* recordDecision().
|
|
77
|
+
* 2. recordDecision() -> sanitizeDecisionEntry() unconditionally ends with
|
|
78
|
+
* normalizeDecisionLearningFields() (learning/causal.ts), which re-runs
|
|
79
|
+
* causalMetadata() and applies boundedText(labelBasis, 80) — ANY
|
|
80
|
+
* labelBasis over 80 chars is silently truncated, with no way to opt
|
|
81
|
+
* out from a caller outside that module. The full token
|
|
82
|
+
* ("post-merge-credit-release-v1:" (30 chars) + eventRef + ':' + mac)
|
|
83
|
+
* must fit in 80 chars total, so each hex segment is capped at 24
|
|
84
|
+
* (30 + 24 + 1 + 24 = 79).
|
|
85
|
+
* Neither constraint is owned by this module; 24 hex chars satisfies both
|
|
86
|
+
* with margin.
|
|
87
|
+
*/
|
|
88
|
+
const CREDIT_REF_HEX_CHARS = 24;
|
|
89
|
+
/** `post-merge-credit-release-v1:<event-ref-hex32>:<hmac-hex32>` */
|
|
90
|
+
const CREDIT_TOKEN_RE = new RegExp(`^post-merge-credit-release-v1:([a-f0-9]{${CREDIT_REF_HEX_CHARS}}):([a-f0-9]{${CREDIT_REF_HEX_CHARS}})$`);
|
|
91
|
+
/** Truncate a full sha256 eventId to the reference used inside the token. */
|
|
92
|
+
function creditEventRef(eventId) {
|
|
93
|
+
return eventId.slice(0, CREDIT_REF_HEX_CHARS);
|
|
94
|
+
}
|
|
95
|
+
function computeCreditMac(eventRef) {
|
|
96
|
+
try {
|
|
97
|
+
return createHmac('sha256', loadOrCreateKey())
|
|
98
|
+
.update(`${CREDIT_TOKEN_DOMAIN}:${eventRef}`)
|
|
99
|
+
.digest('hex')
|
|
100
|
+
.slice(0, CREDIT_REF_HEX_CHARS);
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function equalHex(left, right) {
|
|
107
|
+
try {
|
|
108
|
+
const a = Buffer.from(left, 'hex');
|
|
109
|
+
const b = Buffer.from(right, 'hex');
|
|
110
|
+
return a.length === b.length && a.length > 0 && timingSafeEqual(a, b);
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Verify that `labelBasis` is a validly-signed post-merge-credit release
|
|
118
|
+
* token minted by evaluatePostMergeCreditRelease. Pure, synchronous
|
|
119
|
+
* (host-local key read only), never throws. Deliberately rejects the bare
|
|
120
|
+
* POST_MERGE_CREDIT_RELEASE_LABEL literal and any other string that is not a
|
|
121
|
+
* correctly-formed, correctly-signed token — so raw ledgers, injected
|
|
122
|
+
* dependencies, and caller-controlled metadata cannot mint credit.
|
|
123
|
+
*/
|
|
124
|
+
export function hasReleasedPostMergeCredit(labelBasis) {
|
|
125
|
+
try {
|
|
126
|
+
if (typeof labelBasis !== 'string')
|
|
127
|
+
return false;
|
|
128
|
+
const match = CREDIT_TOKEN_RE.exec(labelBasis);
|
|
129
|
+
if (!match)
|
|
130
|
+
return false;
|
|
131
|
+
const eventRef = match[1];
|
|
132
|
+
const mac = match[2];
|
|
133
|
+
const expected = computeCreditMac(eventRef);
|
|
134
|
+
if (!expected)
|
|
135
|
+
return false;
|
|
136
|
+
return equalHex(mac, expected);
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Determine whether `proposal` is eligible for post-merge credit release
|
|
144
|
+
* RIGHT NOW, and mint the signed token when it is. Fail-closed on every
|
|
145
|
+
* ambiguous path (missing witness, unparseable timestamp, window not yet
|
|
146
|
+
* elapsed, degraded/incomplete observation-ledger read, any adverse
|
|
147
|
+
* observation for this exact merge event, signing failure). Never throws.
|
|
148
|
+
*
|
|
149
|
+
* This function does NOT persist anything — see sweepPostMergeCreditReleases
|
|
150
|
+
* for the write-back that records a minted label to the decisions ledger.
|
|
151
|
+
*/
|
|
152
|
+
export function evaluatePostMergeCreditRelease(proposal, opts = {}) {
|
|
153
|
+
try {
|
|
154
|
+
if (!proposal || typeof proposal.id !== 'string' || proposal.id.length === 0) {
|
|
155
|
+
return { eligible: false, label: null, reason: 'no-authenticated-merge-witness' };
|
|
156
|
+
}
|
|
157
|
+
const evidence = authenticatedRealizedMergeOf(proposal);
|
|
158
|
+
if (!evidence || typeof proposal.repo !== 'string' || proposal.repo.length === 0) {
|
|
159
|
+
return { eligible: false, label: null, reason: 'no-authenticated-merge-witness' };
|
|
160
|
+
}
|
|
161
|
+
const observedAtIso = evidence.source === 'github-host'
|
|
162
|
+
? evidence.reconciliation.observedAt
|
|
163
|
+
: evidence.observedAt;
|
|
164
|
+
const mergedAtMs = Date.parse(observedAtIso);
|
|
165
|
+
if (!Number.isFinite(mergedAtMs)) {
|
|
166
|
+
return { eligible: false, label: null, reason: 'invalid-merge-timestamp' };
|
|
167
|
+
}
|
|
168
|
+
const nowMs = opts.nowMs ?? Date.now();
|
|
169
|
+
if (nowMs < mergedAtMs || nowMs - mergedAtMs < MIN_POST_MERGE_OBSERVATION_WINDOW_MS) {
|
|
170
|
+
return { eligible: false, label: null, reason: 'observation-window-not-elapsed' };
|
|
171
|
+
}
|
|
172
|
+
let repoAbs;
|
|
173
|
+
try {
|
|
174
|
+
repoAbs = resolve(proposal.repo);
|
|
175
|
+
}
|
|
176
|
+
catch {
|
|
177
|
+
return { eligible: false, label: null, reason: 'no-authenticated-merge-witness' };
|
|
178
|
+
}
|
|
179
|
+
const eventId = postMergeObservationEventId({
|
|
180
|
+
repo: repoAbs,
|
|
181
|
+
proposalId: proposal.id,
|
|
182
|
+
mergeCommit: evidence.mergeCommitOid.toLowerCase(),
|
|
183
|
+
});
|
|
184
|
+
// Adverse-only ledger: absence of a row is the only "clean" signal it can
|
|
185
|
+
// ever give us. A degraded/incomplete read must NOT be treated as clean.
|
|
186
|
+
const read = readPostMergeObservations({ requireComplete: true });
|
|
187
|
+
if (read.sourceState === 'degraded' || !read.complete) {
|
|
188
|
+
return { eligible: false, label: null, reason: 'observation-ledger-degraded' };
|
|
189
|
+
}
|
|
190
|
+
if (read.observations.some((observation) => observation.eventId === eventId)) {
|
|
191
|
+
return { eligible: false, label: null, reason: 'adverse-outcome-observed' };
|
|
192
|
+
}
|
|
193
|
+
const eventRef = creditEventRef(eventId);
|
|
194
|
+
const mac = computeCreditMac(eventRef);
|
|
195
|
+
if (!mac)
|
|
196
|
+
return { eligible: false, label: null, reason: 'signing-unavailable' };
|
|
197
|
+
return {
|
|
198
|
+
eligible: true,
|
|
199
|
+
label: `${POST_MERGE_CREDIT_RELEASE_LABEL}:${eventRef}:${mac}`,
|
|
200
|
+
reason: 'clean-window-elapsed',
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
catch {
|
|
204
|
+
return { eligible: false, label: null, reason: 'error' };
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
// ---------------------------------------------------------------------------
|
|
208
|
+
// sweepPostMergeCreditReleases — periodic write-back
|
|
209
|
+
// ---------------------------------------------------------------------------
|
|
210
|
+
/**
|
|
211
|
+
* Bound on candidates inspected per sweep pass — mirrors outcome-watcher.ts's
|
|
212
|
+
* own bounding so a large backlog degrades gracefully instead of blocking.
|
|
213
|
+
*/
|
|
214
|
+
const MAX_SWEEP_CANDIDATES = 200;
|
|
215
|
+
/**
|
|
216
|
+
* Sweep applied proposals for newly-eligible post-merge credit and record it
|
|
217
|
+
* to the decisions ledger (a new 'merged' row with the signed labelBasis
|
|
218
|
+
* token — decisions-ledger.ts's own newest-row-wins semantics let this
|
|
219
|
+
* supersede the plain merge-fact row written at merge time). Idempotent: a
|
|
220
|
+
* proposal that already carries a released decision row is left alone.
|
|
221
|
+
*
|
|
222
|
+
* KNOWN LIMITATION (by design, not a bug): the post-merge-observations ledger
|
|
223
|
+
* only ever records ADVERSE outcomes. This sweep therefore releases credit on
|
|
224
|
+
* "no adverse record after a conservative window", not on a positive
|
|
225
|
+
* "actively confirmed clean" signal — there is no such positive signal
|
|
226
|
+
* anywhere in the fleet today. If a repo's outcome-watcher coverage were
|
|
227
|
+
* somehow disabled for a specific proposal's repo (not enrolled, or the local
|
|
228
|
+
* clone was deleted), this sweep cannot detect that and would release credit
|
|
229
|
+
* on elapsed time alone. The MIN_POST_MERGE_OBSERVATION_WINDOW_MS margin
|
|
230
|
+
* exists specifically to bound that risk; closing it fully would require
|
|
231
|
+
* outcome-watcher.ts (unowned here) to also persist a positive "swept clean"
|
|
232
|
+
* marker per merge event.
|
|
233
|
+
*
|
|
234
|
+
* SCALING NOTE: unlike outcome-watcher.ts, this sweep has no persistent
|
|
235
|
+
* cursor — it re-scans applied proposals from the top of listProposalsDetailed
|
|
236
|
+
* every pass, bounded by MAX_SWEEP_CANDIDATES. At small-to-moderate applied-
|
|
237
|
+
* proposal counts this converges fine (already-released proposals are
|
|
238
|
+
* skipped instantly via the decisions-ledger dedup check, so the cap mostly
|
|
239
|
+
* matters for proposals still awaiting their window). At very large scale a
|
|
240
|
+
* persistent cursor (mirroring monitoring-cursor.ts) would be needed to
|
|
241
|
+
* guarantee every proposal eventually gets swept; out of scope here.
|
|
242
|
+
*
|
|
243
|
+
* Never throws.
|
|
244
|
+
*/
|
|
245
|
+
export function sweepPostMergeCreditReleases(opts = {}) {
|
|
246
|
+
const result = {
|
|
247
|
+
scanned: 0, released: 0, skipped: 0, sourceComplete: true,
|
|
248
|
+
};
|
|
249
|
+
try {
|
|
250
|
+
const nowMs = opts.nowMs ?? Date.now();
|
|
251
|
+
let proposals;
|
|
252
|
+
if (typeof opts.listProposals === 'function') {
|
|
253
|
+
try {
|
|
254
|
+
proposals = opts.listProposals();
|
|
255
|
+
}
|
|
256
|
+
catch {
|
|
257
|
+
proposals = [];
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
const read = listProposalsDetailed({ status: 'applied', requireComplete: true });
|
|
262
|
+
if (!read.complete || read.sourceState === 'degraded') {
|
|
263
|
+
result.sourceComplete = false;
|
|
264
|
+
return result;
|
|
265
|
+
}
|
|
266
|
+
proposals = read.proposals;
|
|
267
|
+
}
|
|
268
|
+
let inspected = 0;
|
|
269
|
+
for (const proposal of proposals) {
|
|
270
|
+
if (proposal.status !== 'applied')
|
|
271
|
+
continue;
|
|
272
|
+
if (inspected >= MAX_SWEEP_CANDIDATES) {
|
|
273
|
+
result.sourceComplete = false;
|
|
274
|
+
break;
|
|
275
|
+
}
|
|
276
|
+
inspected++;
|
|
277
|
+
result.scanned++;
|
|
278
|
+
try {
|
|
279
|
+
const existing = readDecisions({ proposalId: proposal.id, requireComplete: true });
|
|
280
|
+
const existingQuality = existing.sourceQuality;
|
|
281
|
+
if (existingQuality && (existingQuality.sourceState === 'degraded' || existingQuality.complete === false)) {
|
|
282
|
+
result.skipped++;
|
|
283
|
+
result.sourceComplete = false;
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
286
|
+
const alreadyReleased = existing.some((entry) => entry.action === 'merged' && hasReleasedPostMergeCredit(entry.labelBasis));
|
|
287
|
+
if (alreadyReleased)
|
|
288
|
+
continue;
|
|
289
|
+
const eligibility = evaluatePostMergeCreditRelease(proposal, { nowMs });
|
|
290
|
+
if (!eligibility.eligible || !eligibility.label) {
|
|
291
|
+
result.skipped++;
|
|
292
|
+
continue;
|
|
293
|
+
}
|
|
294
|
+
const ts = new Date(nowMs).toISOString();
|
|
295
|
+
recordDecision({
|
|
296
|
+
ts,
|
|
297
|
+
proposalId: proposal.id,
|
|
298
|
+
// NOTE: labelBasis is intentionally NOT routed through
|
|
299
|
+
// causalMetadataFromProposal's `input.labelBasis` — causalMetadata()
|
|
300
|
+
// (learning/causal.ts) applies boundedText(value, 80) to that field,
|
|
301
|
+
// which would silently truncate our signed token (>80 chars) into
|
|
302
|
+
// an unverifiable fragment. Set it directly below instead, after the
|
|
303
|
+
// spread, so the full token survives.
|
|
304
|
+
...causalMetadataFromProposal(proposal, { ts, learningSource: 'outcome-record' }),
|
|
305
|
+
action: 'merged',
|
|
306
|
+
verdict: 'applied',
|
|
307
|
+
labelBasis: eligibility.label,
|
|
308
|
+
repo: proposal.repo ?? '',
|
|
309
|
+
engine: proposal.engineModel ?? '',
|
|
310
|
+
model: '',
|
|
311
|
+
});
|
|
312
|
+
result.released++;
|
|
313
|
+
}
|
|
314
|
+
catch {
|
|
315
|
+
result.skipped++;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
return result;
|
|
319
|
+
}
|
|
320
|
+
catch {
|
|
321
|
+
return result;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
// ---------------------------------------------------------------------------
|
|
325
|
+
// attestPostMergeCreditSkillCard — dedicated signing boundary
|
|
326
|
+
// ---------------------------------------------------------------------------
|
|
327
|
+
/**
|
|
328
|
+
* Sign a SkillCard that legitimately carries released post-merge credit.
|
|
329
|
+
*
|
|
330
|
+
* skill-attestation.ts's generic attestSkillCard() deliberately refuses any
|
|
331
|
+
* card for which hasReleasedPostMergeCredit(card.labelBasis) is true — its
|
|
332
|
+
* signature payload doesn't cover the credit-release claim, so it must not
|
|
333
|
+
* be the thing vouching for it. This module owns that proof, so it owns this
|
|
334
|
+
* signing boundary too: same crypto primitive (signSkillCardAttestation),
|
|
335
|
+
* same payload shape, so verifyAttestedSkillCard() on the read side still
|
|
336
|
+
* validates cards signed here — only the gating differs (this function signs
|
|
337
|
+
* ONLY when hasReleasedPostMergeCredit is true; attestSkillCard signs only
|
|
338
|
+
* when it is false).
|
|
339
|
+
*
|
|
340
|
+
* Never throws.
|
|
19
341
|
*/
|
|
20
|
-
export function
|
|
21
|
-
|
|
342
|
+
export function attestPostMergeCreditSkillCard(card) {
|
|
343
|
+
try {
|
|
344
|
+
if (!hasReleasedPostMergeCredit(card.labelBasis))
|
|
345
|
+
return null;
|
|
346
|
+
const diffHash = card.verification?.diffHash;
|
|
347
|
+
if (!card.proposalId || !diffHash)
|
|
348
|
+
return null;
|
|
349
|
+
const contentHash = skillCardContentHash(card);
|
|
350
|
+
const attestation = signSkillCardAttestation({
|
|
351
|
+
contentHash,
|
|
352
|
+
skillId: card.skillId,
|
|
353
|
+
revision: card.revision,
|
|
354
|
+
proposalId: card.proposalId,
|
|
355
|
+
diffHash,
|
|
356
|
+
});
|
|
357
|
+
return attestation ? { ...card, contentHash, attestation } : null;
|
|
358
|
+
}
|
|
359
|
+
catch {
|
|
360
|
+
return null;
|
|
361
|
+
}
|
|
22
362
|
}
|
|
23
363
|
//# sourceMappingURL=post-merge-credit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"post-merge-credit.js","sourceRoot":"","sources":["../../../src/core/fleet/post-merge-credit.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"post-merge-credit.js","sourceRoot":"","sources":["../../../src/core/fleet/post-merge-credit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBA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C;QACH,OAAO,WAAW,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACpE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* - TELEMETRY: a usage counter is appended to the decisions ledger under
|
|
24
24
|
* action 'self-improve:written' for observability (no PII, no secrets).
|
|
25
25
|
*/
|
|
26
|
-
import type { AshlrConfig, GenomeEntry } from '../types.js';
|
|
26
|
+
import type { AshlrConfig, DecisionEntry, GenomeEntry } from '../types.js';
|
|
27
27
|
/** Hard cap on total characters injected from anti-playbook entries per run. */
|
|
28
28
|
export declare const ANTI_PLAYBOOK_INJECT_CAP = 800;
|
|
29
29
|
type RejectionVerdict = 'review' | 'noise' | 'harmful';
|
|
@@ -51,6 +51,39 @@ export declare function deriveLesson(verdict: RejectionVerdict, _reasoning: stri
|
|
|
51
51
|
* @param cfg Fleet config.
|
|
52
52
|
*/
|
|
53
53
|
export declare function learnFromRejection(proposalId: string, proposalTitle: string, verdict: string, reasoning: string, cfg: AshlrConfig): void;
|
|
54
|
+
export interface RejectionLearningSweepResult {
|
|
55
|
+
/** Distinct proposals with a rejection-shaped judge verdict inspected. */
|
|
56
|
+
scanned: number;
|
|
57
|
+
/** Proposals for which learnFromRejection actually wrote a lesson. */
|
|
58
|
+
written: number;
|
|
59
|
+
/** Proposals inspected but skipped (already written, or a transient error). */
|
|
60
|
+
skipped: number;
|
|
61
|
+
/** False when the decisions source was incomplete/degraded, or the
|
|
62
|
+
* candidate cap was hit — a hint the pass should be retried. */
|
|
63
|
+
sourceComplete: boolean;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Sweep the decisions ledger for judged rejection verdicts (review | noise |
|
|
67
|
+
* harmful) and call learnFromRejection() for each one that hasn't already
|
|
68
|
+
* produced a genome lesson.
|
|
69
|
+
*
|
|
70
|
+
* learnFromRejection's ONLY prior caller was automerge-pass.ts, reached
|
|
71
|
+
* exclusively from inside the auto-merge pass (cfg.foundry.autoMerge.enabled
|
|
72
|
+
* === true). With auto-merge off — the default — a judge verdict could still
|
|
73
|
+
* be recorded (manual `ashlr judge`, a shadow/observe-only judge pass, etc.)
|
|
74
|
+
* but the fleet never learned from it. This sweep reads the SAME
|
|
75
|
+
* decisions-ledger 'judged' rows regardless of what produced them, so a
|
|
76
|
+
* rejected or failed run teaches the fleet whether or not auto-merge is on.
|
|
77
|
+
*
|
|
78
|
+
* Idempotent: a proposalId that already has a 'self-improve:written'
|
|
79
|
+
* telemetry row is skipped. Bounded, fail-open-on-nothing-to-do,
|
|
80
|
+
* fail-closed-on-source-degradation (sourceComplete:false signals "retry
|
|
81
|
+
* later", never treated as "nothing to learn"). Never throws.
|
|
82
|
+
*/
|
|
83
|
+
export declare function sweepRejectionLearning(cfg: AshlrConfig, opts?: {
|
|
84
|
+
sinceMs?: number;
|
|
85
|
+
listDecisions?: () => DecisionEntry[];
|
|
86
|
+
}): RejectionLearningSweepResult;
|
|
54
87
|
/**
|
|
55
88
|
* Filter a list of genome entries to anti-playbook entries suitable for
|
|
56
89
|
* inject-time grounding. Applies:
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* action 'self-improve:written' for observability (no PII, no secrets).
|
|
25
25
|
*/
|
|
26
26
|
import { appendHubEntry } from '../genome/store.js';
|
|
27
|
-
import { recordDecision } from './decisions-ledger.js';
|
|
27
|
+
import { readDecisions, readDecisionsDetailed, recordDecision } from './decisions-ledger.js';
|
|
28
28
|
// ---------------------------------------------------------------------------
|
|
29
29
|
// Constants
|
|
30
30
|
// ---------------------------------------------------------------------------
|
|
@@ -118,6 +118,111 @@ export function learnFromRejection(proposalId, proposalTitle, verdict, reasoning
|
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
// ---------------------------------------------------------------------------
|
|
121
|
+
// Public: sweepRejectionLearning — auto-merge-independent reachability
|
|
122
|
+
// ---------------------------------------------------------------------------
|
|
123
|
+
/**
|
|
124
|
+
* Bound on judged-decision candidates inspected per sweep pass.
|
|
125
|
+
*/
|
|
126
|
+
const MAX_REJECTION_SWEEP_CANDIDATES = 200;
|
|
127
|
+
/**
|
|
128
|
+
* Sweep the decisions ledger for judged rejection verdicts (review | noise |
|
|
129
|
+
* harmful) and call learnFromRejection() for each one that hasn't already
|
|
130
|
+
* produced a genome lesson.
|
|
131
|
+
*
|
|
132
|
+
* learnFromRejection's ONLY prior caller was automerge-pass.ts, reached
|
|
133
|
+
* exclusively from inside the auto-merge pass (cfg.foundry.autoMerge.enabled
|
|
134
|
+
* === true). With auto-merge off — the default — a judge verdict could still
|
|
135
|
+
* be recorded (manual `ashlr judge`, a shadow/observe-only judge pass, etc.)
|
|
136
|
+
* but the fleet never learned from it. This sweep reads the SAME
|
|
137
|
+
* decisions-ledger 'judged' rows regardless of what produced them, so a
|
|
138
|
+
* rejected or failed run teaches the fleet whether or not auto-merge is on.
|
|
139
|
+
*
|
|
140
|
+
* Idempotent: a proposalId that already has a 'self-improve:written'
|
|
141
|
+
* telemetry row is skipped. Bounded, fail-open-on-nothing-to-do,
|
|
142
|
+
* fail-closed-on-source-degradation (sourceComplete:false signals "retry
|
|
143
|
+
* later", never treated as "nothing to learn"). Never throws.
|
|
144
|
+
*/
|
|
145
|
+
export function sweepRejectionLearning(cfg, opts = {}) {
|
|
146
|
+
const result = {
|
|
147
|
+
scanned: 0, written: 0, skipped: 0, sourceComplete: true,
|
|
148
|
+
};
|
|
149
|
+
try {
|
|
150
|
+
const foundry = cfg.foundry;
|
|
151
|
+
if (foundry?.['selfImprove'] === false)
|
|
152
|
+
return result;
|
|
153
|
+
let decisions;
|
|
154
|
+
if (typeof opts.listDecisions === 'function') {
|
|
155
|
+
try {
|
|
156
|
+
decisions = opts.listDecisions();
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
decisions = [];
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
const read = readDecisionsDetailed({
|
|
164
|
+
requireComplete: true,
|
|
165
|
+
...(opts.sinceMs !== undefined ? { sinceMs: opts.sinceMs } : {}),
|
|
166
|
+
});
|
|
167
|
+
if (!read.complete || read.sourceState === 'degraded') {
|
|
168
|
+
result.sourceComplete = false;
|
|
169
|
+
return result;
|
|
170
|
+
}
|
|
171
|
+
decisions = read.decisions;
|
|
172
|
+
}
|
|
173
|
+
// Newest judged verdict per proposalId — mirrors the isNewerDecision
|
|
174
|
+
// pattern used elsewhere (feedback.ts, quality-metrics.ts). The compare
|
|
175
|
+
// must run over EVERY judged verdict (not just rejection-shaped ones):
|
|
176
|
+
// if a proposal's latest verdict is 'ship', a stale earlier
|
|
177
|
+
// noise/harmful/review verdict must not be taught as a lesson — it was
|
|
178
|
+
// superseded.
|
|
179
|
+
const latestJudged = new Map();
|
|
180
|
+
for (const entry of decisions) {
|
|
181
|
+
if (entry.action !== 'judged')
|
|
182
|
+
continue;
|
|
183
|
+
const existing = latestJudged.get(entry.proposalId);
|
|
184
|
+
if (!existing || Date.parse(entry.ts) > Date.parse(existing.ts)) {
|
|
185
|
+
latestJudged.set(entry.proposalId, entry);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
const latestRejection = new Map();
|
|
189
|
+
for (const [proposalId, entry] of latestJudged) {
|
|
190
|
+
const verdict = (entry.verdict ?? '').toLowerCase();
|
|
191
|
+
if (isRejection(verdict))
|
|
192
|
+
latestRejection.set(proposalId, entry);
|
|
193
|
+
}
|
|
194
|
+
let inspected = 0;
|
|
195
|
+
for (const [proposalId, entry] of latestRejection) {
|
|
196
|
+
if (inspected >= MAX_REJECTION_SWEEP_CANDIDATES) {
|
|
197
|
+
result.sourceComplete = false;
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
inspected++;
|
|
201
|
+
result.scanned++;
|
|
202
|
+
try {
|
|
203
|
+
const existing = readDecisions({ proposalId, requireComplete: true });
|
|
204
|
+
const existingQuality = existing.sourceQuality;
|
|
205
|
+
if (existingQuality && (existingQuality.sourceState === 'degraded' || existingQuality.complete === false)) {
|
|
206
|
+
result.skipped++;
|
|
207
|
+
result.sourceComplete = false;
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
if (existing.some((row) => row.action === 'self-improve:written'))
|
|
211
|
+
continue;
|
|
212
|
+
learnFromRejection(proposalId, '', entry.verdict ?? 'review', '', cfg);
|
|
213
|
+
result.written++;
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
result.skipped++;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return result;
|
|
220
|
+
}
|
|
221
|
+
catch {
|
|
222
|
+
return result;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
// ---------------------------------------------------------------------------
|
|
121
226
|
// Curator: curateAntiPlaybooks
|
|
122
227
|
// ---------------------------------------------------------------------------
|
|
123
228
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"self-improve.js","sourceRoot":"","sources":["../../../src/core/fleet/self-improve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"self-improve.js","sourceRoot":"","sources":["../../../src/core/fleet/self-improve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG7F,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E;gDACgD;AAChD,MAAM,UAAU,GAAG,EAAE,CAAC;AAEtB,gFAAgF;AAChF,MAAM,CAAC,MAAM,wB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AAK,EAAE,CAAC;YACtB,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;YAC5C,IAAI,SAAS,GAAG,IAAI,GAAG,wBAAwB;gBAAE,MAAM;YACvD,SAAS,IAAI,IAAI,CAAC;YAClB,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACjB,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -69,7 +69,26 @@ export declare function distillWorkflow(proposal: Proposal): string;
|
|
|
69
69
|
*/
|
|
70
70
|
export declare function learnFromApplied(proposal: Proposal, cfg: AshlrConfig): void;
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
73
|
-
* and
|
|
72
|
+
* Genome hub entries are unsigned free text — appendHubEntry has no
|
|
73
|
+
* authentication, and (per test/m243.skill-library.test.ts's "release
|
|
74
|
+
* verifier unavailable" suite) a forged entry carrying tags ['m243:skill',
|
|
75
|
+
* 'credit:released-v1'] must not be trusted into future-agent prompts just
|
|
76
|
+
* because it carries the right tag. There is no way to cryptographically
|
|
77
|
+
* verify a GenomeEntry's authenticity — genome rows carry no attestation
|
|
78
|
+
* field at all, unlike SkillCard (contentHash + attestation).
|
|
79
|
+
*
|
|
80
|
+
* Real positive-credit skill recall is NOT this function's job: it already
|
|
81
|
+
* exists, and already works, via skill-retrieval.ts's
|
|
82
|
+
* selectVerifiedSkills()/inspectVerifiedSkillCorpus() — those read the
|
|
83
|
+
* cryptographically-signed SkillCard corpus (skill-records.ts) and verify
|
|
84
|
+
* each card's attestation (verifyAttestedSkillCard) plus
|
|
85
|
+
* hasReleasedPostMergeCredit(card.labelBasis) before ever surfacing it. That
|
|
86
|
+
* pathway is what lights up once evaluatePostMergeCreditRelease() /
|
|
87
|
+
* attestPostMergeCreditSkillCard() start minting real signed cards — no
|
|
88
|
+
* change to this function was needed or safe to make.
|
|
89
|
+
*
|
|
90
|
+
* curateSkills() therefore stays a closed stub, matching curateAntiPlaybooks'
|
|
91
|
+
* signature for API symmetry with self-improve.ts but never promoting
|
|
92
|
+
* unsigned genome text to injected grounding. Pure; never throws.
|
|
74
93
|
*/
|
|
75
94
|
export declare function curateSkills(_entries: GenomeEntry[]): GenomeEntry[];
|