@lmzhen/dsh-evolution-review 0.62.1 → 0.62.3
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/README.md +1 -1
- package/lib/index.js +56 -31
- package/lib/types/review-limiter.d.ts +17 -4
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ Subagent-origin, background-visibility, and review-child sessions are excluded.
|
|
|
21
21
|
|
|
22
22
|
## Events and limits
|
|
23
23
|
|
|
24
|
-
The package emits `evolution/review-scheduled`, `evolution/review-completed`, `evolution/review-error`, and an aux `evolution/plan-applied` ledger entry. `reviewTimeoutMs` bounds the aux loop (default 300s; raise it, lower `reviewMaxRounds`, or raise `reviewMaxToolCalls` for unusually long reviews); `reviewMaxRounds` (default 12) and `reviewMaxToolCalls` (default 50) bound model rounds and tool calls. Reaching any bound records `partial`/`timeout` with `hitRoundLimit` and `partialReason`, never `completed`. Review cadence state is persisted when `evolution-state` is available; without it, cadence can reset between turns.
|
|
24
|
+
The package emits `evolution/review-scheduled`, `evolution/review-completed`, `evolution/review-error`, and an aux `evolution/plan-applied` ledger entry. `reviewTimeoutMs` bounds the aux loop (default 300s; raise it, lower `reviewMaxRounds`, or raise `reviewMaxToolCalls` for unusually long reviews); `reviewMaxRounds` (default 12) and `reviewMaxToolCalls` (default 50) bound model rounds and tool calls. Aux reviews run at most 8 at once per plugin instance (`AUX_REVIEW_CONCURRENCY`): that is a provider/CPU budget, while cross-review writes are serialized per resource by the review write locks and the mutation-authority lease. Capacity is acquired **before** the parent prefix is frozen, and a queued review has its own 30s admission budget (`AUX_REVIEW_QUEUE_TIMEOUT_MS`), so `reviewTimeoutMs` starts only after admission and never pays for queue time; a review that cannot be admitted keeps its debt for the next boundary. Reaching any bound records `partial`/`timeout` with `hitRoundLimit` and `partialReason`, never `completed`. Review cadence state is persisted when `evolution-state` is available; without it, cadence can reset between turns.
|
|
25
25
|
|
|
26
26
|
**Removed metadata:** `reviewProvider`, `reviewContextMessages`, `reviewMessageChars`, `reviewMaxDepth` and `reviewToolAllow` were declared but never read, so they are gone from the registry and the bundles. Provider/model come from the parent session header; native review sees the parent catalog but only the family allowlist executes, while PTC exposes only `run_code`.
|
|
27
27
|
`memoryInterval` and `skillInterval` were removed from the live row schema in 0.48 (G0/S0.3). They survive only in the family's old-document migration table and doctor's old-key report; a deployment config that still spells them must be rewritten to `reviewMemoryInterval` and `reviewSkillInterval`.
|
package/lib/index.js
CHANGED
|
@@ -197,6 +197,7 @@ async function runReview(input) {
|
|
|
197
197
|
const stream = streamReviewModel(llm, {
|
|
198
198
|
provider: header.config.provider,
|
|
199
199
|
model: header.config.model,
|
|
200
|
+
sessionId: parent.session.id,
|
|
200
201
|
...header.config.reasoningEffort === void 0 ? {} : { reasoningEffort: header.config.reasoningEffort },
|
|
201
202
|
...header.config.temperature === void 0 ? {} : { temperature: header.config.temperature },
|
|
202
203
|
...header.config.maxTokens === void 0 ? {} : { maxTokens: header.config.maxTokens },
|
|
@@ -753,16 +754,11 @@ var ReviewWriteLocks = class {
|
|
|
753
754
|
};
|
|
754
755
|
//#endregion
|
|
755
756
|
//#region lib/types/review-limiter.js
|
|
756
|
-
/**
|
|
757
|
-
*
|
|
758
|
-
*
|
|
759
|
-
*
|
|
760
|
-
|
|
761
|
-
* before its first model request; the bounded queue is what keeps a burst of
|
|
762
|
-
* sessions from opening unbounded LLM streams.
|
|
763
|
-
*
|
|
764
|
-
* @module @lmzhen/dsh-evolution-review/review-limiter
|
|
765
|
-
*/
|
|
757
|
+
/** Maximum time a review may wait for a concurrency slot before the debt is
|
|
758
|
+
* deferred to the next boundary. Kept separate from reviewTimeoutMs: queue
|
|
759
|
+
* wait is not review execution time, and a prefix frozen through a long queue
|
|
760
|
+
* may already be cold when the first request starts. */
|
|
761
|
+
const AUX_REVIEW_QUEUE_TIMEOUT_MS = 3e4;
|
|
766
762
|
/** A tiny FIFO semaphore whose waiters can be aborted by unload/timeout. */
|
|
767
763
|
var ReviewLimiter = class {
|
|
768
764
|
limit;
|
|
@@ -1485,7 +1481,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
1485
1481
|
*/
|
|
1486
1482
|
let inFlightControllers = /* @__PURE__ */ new Set();
|
|
1487
1483
|
const reviewWriteLocks = new ReviewWriteLocks();
|
|
1488
|
-
const auxLimiter = new ReviewLimiter(
|
|
1484
|
+
const auxLimiter = new ReviewLimiter(8);
|
|
1489
1485
|
let ptcToolHost;
|
|
1490
1486
|
/**
|
|
1491
1487
|
* Freeze the parent prefix for an aux review.
|
|
@@ -1558,13 +1554,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
1558
1554
|
ctx.logger.info("dsh-evolution-review: minimal preset has no family review surface");
|
|
1559
1555
|
return true;
|
|
1560
1556
|
}
|
|
1561
|
-
const
|
|
1562
|
-
const header = session.requestHeader();
|
|
1563
|
-
if (header === void 0) {
|
|
1564
|
-
releaseKind();
|
|
1565
|
-
ctx.logger.warn("dsh-evolution-review: aux review skipped — parent has no request header");
|
|
1566
|
-
return false;
|
|
1567
|
-
}
|
|
1557
|
+
const triggerSeq = session.seq;
|
|
1568
1558
|
const llm = llmPort(ctx)?.streamRaw;
|
|
1569
1559
|
const toolsService = toolsPort(ctx);
|
|
1570
1560
|
const tools = toolsService?.execute;
|
|
@@ -1573,27 +1563,64 @@ function apply(ctx, rawConfig = {}) {
|
|
|
1573
1563
|
ctx.logger.warn("dsh-evolution-review: aux review skipped — llm/tools service is not mounted");
|
|
1574
1564
|
return false;
|
|
1575
1565
|
}
|
|
1566
|
+
const controller = new AbortController();
|
|
1567
|
+
inFlightControllers.add(controller);
|
|
1568
|
+
let queueTimedOut = false;
|
|
1569
|
+
const queueTimer = setTimeout(() => {
|
|
1570
|
+
queueTimedOut = true;
|
|
1571
|
+
controller.abort();
|
|
1572
|
+
}, AUX_REVIEW_QUEUE_TIMEOUT_MS);
|
|
1573
|
+
let limiterRelease;
|
|
1574
|
+
try {
|
|
1575
|
+
limiterRelease = await auxLimiter.acquire(controller.signal);
|
|
1576
|
+
} finally {
|
|
1577
|
+
clearTimeout(queueTimer);
|
|
1578
|
+
}
|
|
1579
|
+
if (limiterRelease === void 0 || controller.signal.aborted) {
|
|
1580
|
+
limiterRelease?.();
|
|
1581
|
+
releaseKind();
|
|
1582
|
+
inFlightControllers.delete(controller);
|
|
1583
|
+
ctx.logger.warn(queueTimedOut ? "dsh-evolution-review: aux review queue wait exceeded " + String(AUX_REVIEW_QUEUE_TIMEOUT_MS) + "ms — debt deferred to the next boundary" : "dsh-evolution-review: aux review queue aborted (plugin unloading) — debt deferred to the next boundary");
|
|
1584
|
+
return false;
|
|
1585
|
+
}
|
|
1586
|
+
let slotReleased = false;
|
|
1587
|
+
const releaseSlot = () => {
|
|
1588
|
+
if (slotReleased) return;
|
|
1589
|
+
slotReleased = true;
|
|
1590
|
+
limiterRelease?.();
|
|
1591
|
+
};
|
|
1592
|
+
if (session.seq !== triggerSeq) {
|
|
1593
|
+
releaseKind();
|
|
1594
|
+
inFlightControllers.delete(controller);
|
|
1595
|
+
releaseSlot();
|
|
1596
|
+
ctx.logger.warn("dsh-evolution-review: parent advanced before aux review admission — debt deferred");
|
|
1597
|
+
return false;
|
|
1598
|
+
}
|
|
1599
|
+
const reviewParent = snapshotReviewParent(agent);
|
|
1600
|
+
const header = session.requestHeader();
|
|
1601
|
+
if (header === void 0) {
|
|
1602
|
+
releaseKind();
|
|
1603
|
+
inFlightControllers.delete(controller);
|
|
1604
|
+
releaseSlot();
|
|
1605
|
+
ctx.logger.warn("dsh-evolution-review: aux review skipped — parent has no request header");
|
|
1606
|
+
return false;
|
|
1607
|
+
}
|
|
1576
1608
|
const liveAuthority = () => ctx.get("evolutionMutationAuthority");
|
|
1577
1609
|
const authority = liveAuthority();
|
|
1578
1610
|
let leaseToken;
|
|
1579
1611
|
if (authority?.lease !== void 0) {
|
|
1580
1612
|
const lease = await authority.lease.acquire("background_review", "review:" + session.id + ":" + kind, Math.max(config.reviewTimeoutMs + 3e4, 6e4)).catch(() => void 0);
|
|
1581
|
-
if (lease === void 0) {
|
|
1613
|
+
if (lease === void 0 || !lease.ok) {
|
|
1582
1614
|
releaseKind();
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
if (!lease.ok) {
|
|
1587
|
-
releaseKind();
|
|
1588
|
-
ctx.logger.warn("dsh-evolution-review: aux review already leased (" + lease.reason + ")");
|
|
1615
|
+
inFlightControllers.delete(controller);
|
|
1616
|
+
releaseSlot();
|
|
1617
|
+
ctx.logger.warn(lease === void 0 ? "dsh-evolution-review: aux review skipped — lease acquire failed" : "dsh-evolution-review: aux review already leased (" + lease.reason + ")");
|
|
1589
1618
|
return false;
|
|
1590
1619
|
}
|
|
1591
1620
|
leaseToken = lease.token;
|
|
1592
1621
|
}
|
|
1593
1622
|
const reviewId = "aux-" + randomUUID();
|
|
1594
1623
|
const startedAt = Date.now();
|
|
1595
|
-
const controller = new AbortController();
|
|
1596
|
-
inFlightControllers.add(controller);
|
|
1597
1624
|
let timedOut = false;
|
|
1598
1625
|
const timer = setTimeout(() => {
|
|
1599
1626
|
timedOut = true;
|
|
@@ -1642,6 +1669,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
1642
1669
|
clearTimeout(timer);
|
|
1643
1670
|
if (leaseRenewTimer !== void 0) clearInterval(leaseRenewTimer);
|
|
1644
1671
|
inFlightControllers.delete(controller);
|
|
1672
|
+
releaseSlot();
|
|
1645
1673
|
if (leaseToken !== void 0 && authority?.lease !== void 0) await authority.lease.release(leaseToken).catch(() => {});
|
|
1646
1674
|
ctx.logger.warn("dsh-evolution-review: aux review setup failed: " + (error instanceof Error ? error.message : String(error)));
|
|
1647
1675
|
return false;
|
|
@@ -1665,10 +1693,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
1665
1693
|
let hitRoundLimit = false;
|
|
1666
1694
|
let report;
|
|
1667
1695
|
let error;
|
|
1668
|
-
let limiterRelease;
|
|
1669
1696
|
try {
|
|
1670
|
-
limiterRelease = await auxLimiter.acquire(controller.signal);
|
|
1671
|
-
if (limiterRelease === void 0) throw new Error("aux review queue aborted");
|
|
1672
1697
|
const prompt = reviewPrompt(kind, "aux") + "\n\nWhen all durable changes for this review are complete, call review_done as the only tool call in your final batch. Do not call it while more edits remain. A precise no-op is still a completed review: always finish with review_done and an unchanged report instead of stopping without it. If a write is locked, call review_wait once, then re-read the target and retry; never reapply a stale patch." + (channel.instruction === void 0 ? "" : "\n\n" + channel.instruction);
|
|
1673
1698
|
const result = await withReviewContext({
|
|
1674
1699
|
reviewId,
|
|
@@ -1718,7 +1743,7 @@ function apply(ctx, rawConfig = {}) {
|
|
|
1718
1743
|
status = timedOut ? "timeout" : controller.signal.aborted ? "aborted" : "failed";
|
|
1719
1744
|
ctx.logger.warn("dsh-evolution-review: aux review failed: " + error);
|
|
1720
1745
|
} finally {
|
|
1721
|
-
|
|
1746
|
+
releaseSlot();
|
|
1722
1747
|
clearTimeout(timer);
|
|
1723
1748
|
if (leaseRenewTimer !== void 0) clearInterval(leaseRenewTimer);
|
|
1724
1749
|
const finishedAt = Date.now();
|
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Process-local bound on concurrent AUX reviews.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* One semaphore for the plugin instance, no per-session or weighted fairness.
|
|
5
|
+
* A review waits for a slot before its first model request; the bounded queue
|
|
6
|
+
* keeps a burst of sessions from opening unbounded LLM streams. This is a
|
|
7
|
+
* provider/CPU budget, not a correctness guard: cross-review writes are already
|
|
8
|
+
* serialized by the review write locks and the mutation-authority lease.
|
|
9
|
+
*
|
|
10
|
+
* 8 slots matches the observed burst size of normal multi-session use: a long
|
|
11
|
+
* queue can outlive the parent prefix cache and turn a warm aux review into a
|
|
12
|
+
* cold one. Callers that need a different budget can construct their own
|
|
13
|
+
* limiter; this constant is the shipped default.
|
|
8
14
|
*
|
|
9
15
|
* @module @lmzhen/dsh-evolution-review/review-limiter
|
|
10
16
|
*/
|
|
17
|
+
/** Shipped default for concurrent aux reviews. */
|
|
18
|
+
export declare const AUX_REVIEW_CONCURRENCY = 8;
|
|
19
|
+
/** Maximum time a review may wait for a concurrency slot before the debt is
|
|
20
|
+
* deferred to the next boundary. Kept separate from reviewTimeoutMs: queue
|
|
21
|
+
* wait is not review execution time, and a prefix frozen through a long queue
|
|
22
|
+
* may already be cold when the first request starts. */
|
|
23
|
+
export declare const AUX_REVIEW_QUEUE_TIMEOUT_MS = 30000;
|
|
11
24
|
/** A tiny FIFO semaphore whose waiters can be aborted by unload/timeout. */
|
|
12
25
|
export declare class ReviewLimiter {
|
|
13
26
|
private readonly limit;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lmzhen/dsh-evolution-review",
|
|
3
3
|
"description": "Background review orchestration (community build)",
|
|
4
|
-
"version": "0.62.
|
|
4
|
+
"version": "0.62.3",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@deepseek-ai/schemastery": "^3.18.5",
|
|
32
|
-
"@lmzhen/dsh-evolution-core": "0.62.
|
|
33
|
-
"@lmzhen/dsh-evolution-platform": "0.62.
|
|
32
|
+
"@lmzhen/dsh-evolution-core": "0.62.3",
|
|
33
|
+
"@lmzhen/dsh-evolution-platform": "0.62.3"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"@deepseek-ai/cordis": "^4.0.5",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@deepseek-ai/dsh-agent": "0.2.2-rc.5",
|
|
43
43
|
"@deepseek-ai/dsh-llm": "0.2.2-rc.5",
|
|
44
44
|
"@deepseek-ai/dsh-session": "0.2.2-rc.5",
|
|
45
|
-
"@lmzhen/dsh-evolution-core": "^0.62.
|
|
45
|
+
"@lmzhen/dsh-evolution-core": "^0.62.3"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
|
48
48
|
"dsh": "0.2.2-rc.5"
|