@dsh-cc/input-budget 0.0.0-stage → 0.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.i18n.yaml +6 -0
- package/README.md +98 -2
- package/README.zh.md +99 -0
- package/lib/classes.d.ts +56 -0
- package/lib/classes.d.ts.map +1 -0
- package/lib/classes.js +115 -0
- package/lib/classes.js.map +1 -0
- package/lib/core.d.ts +136 -0
- package/lib/core.d.ts.map +1 -0
- package/lib/core.js +307 -0
- package/lib/core.js.map +1 -0
- package/lib/index.d.ts +32 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +32 -0
- package/lib/index.js.map +1 -0
- package/lib/ledger.d.ts +74 -0
- package/lib/ledger.d.ts.map +1 -0
- package/lib/ledger.js +140 -0
- package/lib/ledger.js.map +1 -0
- package/lib/listener.d.ts +138 -0
- package/lib/listener.d.ts.map +1 -0
- package/lib/listener.js +266 -0
- package/lib/listener.js.map +1 -0
- package/lib/pipeline.d.ts +50 -0
- package/lib/pipeline.d.ts.map +1 -0
- package/lib/pipeline.js +48 -0
- package/lib/pipeline.js.map +1 -0
- package/lib/plugin.d.ts +22 -0
- package/lib/plugin.d.ts.map +1 -0
- package/lib/plugin.js +24 -0
- package/lib/plugin.js.map +1 -0
- package/lib/row.d.ts +51 -0
- package/lib/row.d.ts.map +1 -0
- package/lib/row.js +55 -0
- package/lib/row.js.map +1 -0
- package/lib/settings.d.ts +80 -0
- package/lib/settings.d.ts.map +1 -0
- package/lib/settings.js +172 -0
- package/lib/settings.js.map +1 -0
- package/package.json +42 -3
package/lib/pipeline.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The governor pipeline seam — plan doc
|
|
3
|
+
* `docs/plans/2026-11-12-per-step-input-budget-governor.md` §"Dependencies &
|
|
4
|
+
* interactions": the `govern()` order is **dedupe → caps → budget trim**, and
|
|
5
|
+
* doc 7 (injection dedupe / per-class caps) plugs its two stages into this same
|
|
6
|
+
* listener ahead of the trim.
|
|
7
|
+
*
|
|
8
|
+
* This module fixes the ORDER and nothing else: the trim stage IS `govern()`,
|
|
9
|
+
* the two earlier stages are typed hook slots that slice 5 leaves empty. No
|
|
10
|
+
* dedupe and no cap logic lives here — the stages exist so that slice cannot be
|
|
11
|
+
* added as a post-trim patch that would arbitrate against already-charged
|
|
12
|
+
* bytes.
|
|
13
|
+
*
|
|
14
|
+
* @module @dsh-cc/input-budget/pipeline
|
|
15
|
+
*/
|
|
16
|
+
import { govern, } from "./core.js";
|
|
17
|
+
/** The fixed stage order (dedupe → caps → budget trim), as a runtime value. */
|
|
18
|
+
export const GOVERNOR_STAGES = Object.freeze([
|
|
19
|
+
'dedupe',
|
|
20
|
+
'caps',
|
|
21
|
+
'trim',
|
|
22
|
+
]);
|
|
23
|
+
/**
|
|
24
|
+
* Run one gate invocation through the pipeline: every registered hook in stage
|
|
25
|
+
* order over the fresh batch, then the budget trim over the result.
|
|
26
|
+
*
|
|
27
|
+
* Hook failures propagate to the caller: the listener contains them by
|
|
28
|
+
* returning the unmodified decision and recording `{ error: true }`, so a
|
|
29
|
+
* broken stage can never half-apply a batch.
|
|
30
|
+
*
|
|
31
|
+
* @param input - the gate invocation: batch, settings, backlog and `gateSeq`.
|
|
32
|
+
* @param hooks - pre-trim stages; empty until doc 7 lands.
|
|
33
|
+
* @returns the same shape {@link govern} returns.
|
|
34
|
+
*/
|
|
35
|
+
export function runGovernorPipeline(input, hooks = []) {
|
|
36
|
+
let messages = input.messages;
|
|
37
|
+
for (const stage of GOVERNOR_STAGES) {
|
|
38
|
+
if (stage === 'trim')
|
|
39
|
+
continue;
|
|
40
|
+
for (const hook of hooks) {
|
|
41
|
+
if (hook.stage !== stage)
|
|
42
|
+
continue;
|
|
43
|
+
messages = hook.run(messages, input.settings);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return govern({ ...input, messages });
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=pipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../src/pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,MAAM,GAKP,MAAM,WAAW,CAAA;AAKlB,+EAA+E;AAC/E,MAAM,CAAC,MAAM,eAAe,GAA6B,MAAM,CAAC,MAAM,CAAC;IACrE,QAAQ;IACR,MAAM;IACN,MAAM;CACE,CAAC,CAAA;AAmBX;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAqB,EACrB,QAAyC,EAAE;IAE3C,IAAI,QAAQ,GAAiB,KAAK,CAAC,QAAQ,CAAA;IAC3C,KAAK,MAAM,KAAK,IAAI,eAAe,EAAE,CAAC;QACpC,IAAI,KAAK,KAAK,MAAM;YAAE,SAAQ;QAC9B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,IAAI,IAAI,CAAC,KAAK,KAAK,KAAK;gBAAE,SAAQ;YAClC,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAA;QAC/C,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAA;AACvC,CAAC"}
|
package/lib/plugin.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cordis plugin entry — what the preset's `input-budget` row mounts (plan doc
|
|
3
|
+
* `docs/plans/2026-11-12-per-step-input-budget-governor.md` §"Package & seam").
|
|
4
|
+
*
|
|
5
|
+
* The package publishes no Service, so the row carries no isolate key and the
|
|
6
|
+
* plugin declares no `inject`. The whole behavior is the prepended
|
|
7
|
+
* `agent/pre-step` listener (plus session-state hygiene), registered on the
|
|
8
|
+
* PRESET context: each preset tree gates its own agents with its own per-session
|
|
9
|
+
* clocks and backlogs. Registering as a fiber effect is what makes a preset
|
|
10
|
+
* unload remove the listener with it.
|
|
11
|
+
*
|
|
12
|
+
* @module @dsh-cc/input-budget/plugin
|
|
13
|
+
*/
|
|
14
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
15
|
+
/** Cordis plugin id — the preset row id. */
|
|
16
|
+
export declare const name = "input-budget";
|
|
17
|
+
/**
|
|
18
|
+
* Mount the governor for the calling preset.
|
|
19
|
+
* @param ctx - the preset context mounting this plugin.
|
|
20
|
+
*/
|
|
21
|
+
export declare function apply(ctx: Context): void;
|
|
22
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAGlD,4CAA4C;AAC5C,eAAO,MAAM,IAAI,iBAAiB,CAAA;AAElC;;;GAGG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,GAAG,IAAI,CAExC"}
|
package/lib/plugin.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cordis plugin entry — what the preset's `input-budget` row mounts (plan doc
|
|
3
|
+
* `docs/plans/2026-11-12-per-step-input-budget-governor.md` §"Package & seam").
|
|
4
|
+
*
|
|
5
|
+
* The package publishes no Service, so the row carries no isolate key and the
|
|
6
|
+
* plugin declares no `inject`. The whole behavior is the prepended
|
|
7
|
+
* `agent/pre-step` listener (plus session-state hygiene), registered on the
|
|
8
|
+
* PRESET context: each preset tree gates its own agents with its own per-session
|
|
9
|
+
* clocks and backlogs. Registering as a fiber effect is what makes a preset
|
|
10
|
+
* unload remove the listener with it.
|
|
11
|
+
*
|
|
12
|
+
* @module @dsh-cc/input-budget/plugin
|
|
13
|
+
*/
|
|
14
|
+
import { registerGovernorListener } from "./listener.js";
|
|
15
|
+
/** Cordis plugin id — the preset row id. */
|
|
16
|
+
export const name = 'input-budget';
|
|
17
|
+
/**
|
|
18
|
+
* Mount the governor for the calling preset.
|
|
19
|
+
* @param ctx - the preset context mounting this plugin.
|
|
20
|
+
*/
|
|
21
|
+
export function apply(ctx) {
|
|
22
|
+
ctx.effect(() => registerGovernorListener(ctx), 'input-budget: release governor listener');
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAA;AAExD,4CAA4C;AAC5C,MAAM,CAAC,MAAM,IAAI,GAAG,cAAc,CAAA;AAElC;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAC,GAAY;IAChC,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,wBAAwB,CAAC,GAAG,CAAC,EAAE,yCAAyC,CAAC,CAAA;AAC5F,CAAC"}
|
package/lib/row.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The row-construction seam — plan doc
|
|
3
|
+
* `docs/plans/2026-11-12-per-step-input-budget-governor.md` §"GovernorRow":
|
|
4
|
+
* `@dsh-cc/input-ledger` owns the row schema (single schema source, doc 3);
|
|
5
|
+
* this package supplies only the fields it owns — `mode`, `bytesByClass`,
|
|
6
|
+
* `trimmed`, `offeredBacklog`, `hardOver` — plus the `{ error: true }` marker
|
|
7
|
+
* of the failure path.
|
|
8
|
+
*
|
|
9
|
+
* The seam exists so the ledger emission is a pure wiring step: this module
|
|
10
|
+
* builds a complete `GovernorRow` and hands it to the listener's `emit` sink,
|
|
11
|
+
* which `ledger.ts` binds to the input-ledger append sink. On a host without a
|
|
12
|
+
* dsh-home (or with the ledger disabled) rows are simply dropped; the governor
|
|
13
|
+
* still runs, so a missing ledger can never change admission.
|
|
14
|
+
*
|
|
15
|
+
* @module @dsh-cc/input-budget/row
|
|
16
|
+
*/
|
|
17
|
+
import { type GovernorRow } from '@dsh-cc/input-ledger';
|
|
18
|
+
import type { GovernorDecision } from './core.ts';
|
|
19
|
+
import type { InputBudgetMode } from './settings.ts';
|
|
20
|
+
/**
|
|
21
|
+
* Every class key at zero bytes, in the design table's order. Used by the
|
|
22
|
+
* failure path, where no batch was measured: the row keeps the full key set so
|
|
23
|
+
* a reader never has to distinguish "class absent" from "class empty".
|
|
24
|
+
*/
|
|
25
|
+
export declare function emptyBytesByClass(): Record<string, number>;
|
|
26
|
+
/** The inputs one `GovernorRow` is built from. */
|
|
27
|
+
export interface GovernorRowInput {
|
|
28
|
+
/** Durable session id the invocation belongs to. */
|
|
29
|
+
sessionId: string;
|
|
30
|
+
/** Process boot id stamped into every row (the ledger's `gen`). */
|
|
31
|
+
gen: string;
|
|
32
|
+
/** Turn-local attribution from the pre-step payload, when present. */
|
|
33
|
+
turn?: number | undefined;
|
|
34
|
+
/** Turn-local attribution from the pre-step payload, when present. */
|
|
35
|
+
step?: number | undefined;
|
|
36
|
+
/** The governor's decision for this invocation; absent on the failure path. */
|
|
37
|
+
decision?: GovernorDecision | undefined;
|
|
38
|
+
/** Mode to record when `decision` is absent (the failure path). */
|
|
39
|
+
mode?: InputBudgetMode | undefined;
|
|
40
|
+
/** The governor threw and returned the batch unmodified. */
|
|
41
|
+
error?: true | undefined;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Build one `GovernorRow`.
|
|
45
|
+
*
|
|
46
|
+
* @param input - the invocation's attribution plus either its decision or the
|
|
47
|
+
* failure marker.
|
|
48
|
+
* @returns the row, ready for the ledger sink.
|
|
49
|
+
*/
|
|
50
|
+
export declare function buildGovernorRow(input: GovernorRowInput): GovernorRow;
|
|
51
|
+
//# sourceMappingURL=row.d.ts.map
|
package/lib/row.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row.d.ts","sourceRoot":"","sources":["../src/row.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAyB,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAE9E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAEpD;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAI1D;AAED,kDAAkD;AAClD,MAAM,WAAW,gBAAgB;IAC/B,oDAAoD;IACpD,SAAS,EAAE,MAAM,CAAA;IACjB,mEAAmE;IACnE,GAAG,EAAE,MAAM,CAAA;IACX,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,sEAAsE;IACtE,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAA;IACvC,mEAAmE;IACnE,IAAI,CAAC,EAAE,eAAe,GAAG,SAAS,CAAA;IAClC,4DAA4D;IAC5D,KAAK,CAAC,EAAE,IAAI,GAAG,SAAS,CAAA;CACzB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,GAAG,WAAW,CAiBrE"}
|
package/lib/row.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The row-construction seam — plan doc
|
|
3
|
+
* `docs/plans/2026-11-12-per-step-input-budget-governor.md` §"GovernorRow":
|
|
4
|
+
* `@dsh-cc/input-ledger` owns the row schema (single schema source, doc 3);
|
|
5
|
+
* this package supplies only the fields it owns — `mode`, `bytesByClass`,
|
|
6
|
+
* `trimmed`, `offeredBacklog`, `hardOver` — plus the `{ error: true }` marker
|
|
7
|
+
* of the failure path.
|
|
8
|
+
*
|
|
9
|
+
* The seam exists so the ledger emission is a pure wiring step: this module
|
|
10
|
+
* builds a complete `GovernorRow` and hands it to the listener's `emit` sink,
|
|
11
|
+
* which `ledger.ts` binds to the input-ledger append sink. On a host without a
|
|
12
|
+
* dsh-home (or with the ledger disabled) rows are simply dropped; the governor
|
|
13
|
+
* still runs, so a missing ledger can never change admission.
|
|
14
|
+
*
|
|
15
|
+
* @module @dsh-cc/input-budget/row
|
|
16
|
+
*/
|
|
17
|
+
import { LEDGER_SCHEMA_VERSION } from '@dsh-cc/input-ledger';
|
|
18
|
+
import { INPUT_CLASSES } from "./classes.js";
|
|
19
|
+
/**
|
|
20
|
+
* Every class key at zero bytes, in the design table's order. Used by the
|
|
21
|
+
* failure path, where no batch was measured: the row keeps the full key set so
|
|
22
|
+
* a reader never has to distinguish "class absent" from "class empty".
|
|
23
|
+
*/
|
|
24
|
+
export function emptyBytesByClass() {
|
|
25
|
+
const bytesByClass = {};
|
|
26
|
+
for (const cls of INPUT_CLASSES)
|
|
27
|
+
bytesByClass[cls] = 0;
|
|
28
|
+
return bytesByClass;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Build one `GovernorRow`.
|
|
32
|
+
*
|
|
33
|
+
* @param input - the invocation's attribution plus either its decision or the
|
|
34
|
+
* failure marker.
|
|
35
|
+
* @returns the row, ready for the ledger sink.
|
|
36
|
+
*/
|
|
37
|
+
export function buildGovernorRow(input) {
|
|
38
|
+
const decision = input.decision;
|
|
39
|
+
return {
|
|
40
|
+
v: LEDGER_SCHEMA_VERSION,
|
|
41
|
+
ts: Date.now(),
|
|
42
|
+
sessionId: input.sessionId,
|
|
43
|
+
gen: input.gen,
|
|
44
|
+
...(input.turn === undefined ? {} : { turn: input.turn }),
|
|
45
|
+
...(input.step === undefined ? {} : { step: input.step }),
|
|
46
|
+
type: 'governor',
|
|
47
|
+
mode: decision?.mode ?? input.mode ?? 'observe',
|
|
48
|
+
bytesByClass: decision?.bytesByClass ?? emptyBytesByClass(),
|
|
49
|
+
trimmed: decision?.trimmed ?? [],
|
|
50
|
+
offeredBacklog: decision?.offeredBacklog ?? 0,
|
|
51
|
+
hardOver: decision?.hardOver ?? false,
|
|
52
|
+
...(input.error === true ? { error: true } : {}),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=row.js.map
|
package/lib/row.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"row.js","sourceRoot":"","sources":["../src/row.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,qBAAqB,EAAoB,MAAM,sBAAsB,CAAA;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAI5C;;;;GAIG;AACH,MAAM,UAAU,iBAAiB;IAC/B,MAAM,YAAY,GAA2B,EAAE,CAAA;IAC/C,KAAK,MAAM,GAAG,IAAI,aAAa;QAAE,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACtD,OAAO,YAAY,CAAA;AACrB,CAAC;AAoBD;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAuB;IACtD,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAA;IAC/B,OAAO;QACL,CAAC,EAAE,qBAAqB;QACxB,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;QACd,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,GAAG,EAAE,KAAK,CAAC,GAAG;QACd,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;QACzD,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;QACzD,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,QAAQ,EAAE,IAAI,IAAI,KAAK,CAAC,IAAI,IAAI,SAAS;QAC/C,YAAY,EAAE,QAAQ,EAAE,YAAY,IAAI,iBAAiB,EAAE;QAC3D,OAAO,EAAE,QAAQ,EAAE,OAAO,IAAI,EAAE;QAChC,cAAc,EAAE,QAAQ,EAAE,cAAc,IAAI,CAAC;QAC7C,QAAQ,EAAE,QAAQ,EAAE,QAAQ,IAAI,KAAK;QACrC,GAAG,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,IAAa,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC1D,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Settings for the per-step input budget governor (plan doc
|
|
3
|
+
* `docs/plans/2026-11-12-per-step-input-budget-governor.md` §"Settings —
|
|
4
|
+
* `cc-input-budget`"), two halves — the completion-gate / input-ledger
|
|
5
|
+
* dual-half pattern:
|
|
6
|
+
*
|
|
7
|
+
* 1. namespace registration via `@dsh-cc/settings/ns` (kebab keys, for /config
|
|
8
|
+
* UX and validation only);
|
|
9
|
+
* 2. a RAW user-layer read of `<dshHome>/settings.json` re-read per gate
|
|
10
|
+
* invocation, so a hot toggle applies on the next step without a restart.
|
|
11
|
+
*
|
|
12
|
+
* Four-surface default discipline: the schema `.default()`s, the
|
|
13
|
+
* {@link DEFAULT_INPUT_BUDGET_SETTINGS} constants, the fail-soft raw reader
|
|
14
|
+
* (absent or malformed file, out-of-bounds integers → defaults or bounds), and
|
|
15
|
+
* the wiring fallback in the slice-5 mount all agree. No settings file means
|
|
16
|
+
* the defaults, which means `mode: 'observe'` — the governor records decisions
|
|
17
|
+
* and changes nothing.
|
|
18
|
+
*
|
|
19
|
+
* @module @dsh-cc/input-budget/settings
|
|
20
|
+
*/
|
|
21
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
22
|
+
import type { SettingsNamespace } from '@dsh-cc/settings';
|
|
23
|
+
import z from '@deepseek-ai/schemastery';
|
|
24
|
+
import type { GovernorSettings } from './core.ts';
|
|
25
|
+
/** The settings namespace carrying the governor knobs. */
|
|
26
|
+
export declare const SETTINGS_NAMESPACE: SettingsNamespace;
|
|
27
|
+
/** Bounds of `enter-budget-bytes`. */
|
|
28
|
+
export declare const MIN_ENTER_BUDGET_BYTES = 4096;
|
|
29
|
+
export declare const MAX_ENTER_BUDGET_BYTES = 262144;
|
|
30
|
+
/** Bounds of `advisory-budget-bytes`. */
|
|
31
|
+
export declare const MIN_ADVISORY_BUDGET_BYTES = 512;
|
|
32
|
+
export declare const MAX_ADVISORY_BUDGET_BYTES = 65536;
|
|
33
|
+
/** Bounds of `memory-budget-bytes`. */
|
|
34
|
+
export declare const MIN_MEMORY_BUDGET_BYTES = 1024;
|
|
35
|
+
export declare const MAX_MEMORY_BUDGET_BYTES = 131072;
|
|
36
|
+
/** Bounds of `defer-ttl-steps`. */
|
|
37
|
+
export declare const MIN_DEFER_TTL_STEPS = 1;
|
|
38
|
+
export declare const MAX_DEFER_TTL_STEPS = 16;
|
|
39
|
+
/** The two governance modes. A flip to `enforce` starts with an empty defer queue. */
|
|
40
|
+
export type InputBudgetMode = 'observe' | 'enforce';
|
|
41
|
+
/** Resolved settings shape (kebab keys). */
|
|
42
|
+
export interface InputBudgetSettings extends GovernorSettings {
|
|
43
|
+
/** Whether the governor runs at all; disabling is a full no-op, not a passthrough trim. */
|
|
44
|
+
enabled: boolean;
|
|
45
|
+
mode: InputBudgetMode;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Namespace schema. Wrapped in the z.const(undefined) union (turn-rules
|
|
49
|
+
* convention) so a genuinely absent namespace value stays absent instead of
|
|
50
|
+
* materializing defaults into the cascade.
|
|
51
|
+
*/
|
|
52
|
+
export declare const SettingsSchema: z<Record<string, unknown>>;
|
|
53
|
+
/**
|
|
54
|
+
* Ship defaults: enabled, observe mode, and budgets sized from the ledger's
|
|
55
|
+
* observe-mode plan — 24 KiB enter, 8 KiB advisory, 16 KiB memory (recall
|
|
56
|
+
* bodies), 3-invocation defer TTL.
|
|
57
|
+
*/
|
|
58
|
+
export declare const DEFAULT_INPUT_BUDGET_SETTINGS: InputBudgetSettings;
|
|
59
|
+
/**
|
|
60
|
+
* Register the settings namespace (for /config UX and validation only — the
|
|
61
|
+
* listener reads the raw user file per gate invocation).
|
|
62
|
+
* @param ctx - context that may carry the settings provider.
|
|
63
|
+
*/
|
|
64
|
+
export declare function registerSettings(ctx: Context): void;
|
|
65
|
+
/**
|
|
66
|
+
* Read the settings DIRECTLY from `<dshHome>/settings.json`, bypassing the
|
|
67
|
+
* merged cascade. Fail-soft: an absent file, parse error, or malformed section
|
|
68
|
+
* yields {@link DEFAULT_INPUT_BUDGET_SETTINGS} (observe mode).
|
|
69
|
+
* @param dshHome - the harness home directory root.
|
|
70
|
+
*/
|
|
71
|
+
export declare function readUserSettings(dshHome: string): Promise<InputBudgetSettings>;
|
|
72
|
+
/**
|
|
73
|
+
* SYNCHRONOUS raw read of `<dshHome>/settings.json` — the hot-path half of the
|
|
74
|
+
* dual-half pattern: the listener re-reads per gate invocation, so settings
|
|
75
|
+
* hot-toggle takes effect on the next step without a restart. Same fail-soft
|
|
76
|
+
* semantics as {@link readUserSettings}.
|
|
77
|
+
* @param dshHome - the harness home directory root.
|
|
78
|
+
*/
|
|
79
|
+
export declare function readUserSettingsSync(dshHome: string): InputBudgetSettings;
|
|
80
|
+
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAKH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,CAAC,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
|
+
* Settings for the per-step input budget governor (plan doc
|
|
3
|
+
* `docs/plans/2026-11-12-per-step-input-budget-governor.md` §"Settings —
|
|
4
|
+
* `cc-input-budget`"), two halves — the completion-gate / input-ledger
|
|
5
|
+
* dual-half pattern:
|
|
6
|
+
*
|
|
7
|
+
* 1. namespace registration via `@dsh-cc/settings/ns` (kebab keys, for /config
|
|
8
|
+
* UX and validation only);
|
|
9
|
+
* 2. a RAW user-layer read of `<dshHome>/settings.json` re-read per gate
|
|
10
|
+
* invocation, so a hot toggle applies on the next step without a restart.
|
|
11
|
+
*
|
|
12
|
+
* Four-surface default discipline: the schema `.default()`s, the
|
|
13
|
+
* {@link DEFAULT_INPUT_BUDGET_SETTINGS} constants, the fail-soft raw reader
|
|
14
|
+
* (absent or malformed file, out-of-bounds integers → defaults or bounds), and
|
|
15
|
+
* the wiring fallback in the slice-5 mount all agree. No settings file means
|
|
16
|
+
* the defaults, which means `mode: 'observe'` — the governor records decisions
|
|
17
|
+
* and changes nothing.
|
|
18
|
+
*
|
|
19
|
+
* @module @dsh-cc/input-budget/settings
|
|
20
|
+
*/
|
|
21
|
+
import { readFileSync } from 'node:fs';
|
|
22
|
+
import { readFile } from 'node:fs/promises';
|
|
23
|
+
import { join } from 'node:path';
|
|
24
|
+
import z from '@deepseek-ai/schemastery';
|
|
25
|
+
import { registerNamespaceSafe } from '@dsh-cc/settings/ns';
|
|
26
|
+
/** The settings namespace carrying the governor knobs. */
|
|
27
|
+
export const SETTINGS_NAMESPACE = 'cc-input-budget';
|
|
28
|
+
/** Bounds of `enter-budget-bytes`. */
|
|
29
|
+
export const MIN_ENTER_BUDGET_BYTES = 4096;
|
|
30
|
+
export const MAX_ENTER_BUDGET_BYTES = 262_144;
|
|
31
|
+
/** Bounds of `advisory-budget-bytes`. */
|
|
32
|
+
export const MIN_ADVISORY_BUDGET_BYTES = 512;
|
|
33
|
+
export const MAX_ADVISORY_BUDGET_BYTES = 65_536;
|
|
34
|
+
/** Bounds of `memory-budget-bytes`. */
|
|
35
|
+
export const MIN_MEMORY_BUDGET_BYTES = 1024;
|
|
36
|
+
export const MAX_MEMORY_BUDGET_BYTES = 131_072;
|
|
37
|
+
/** Bounds of `defer-ttl-steps`. */
|
|
38
|
+
export const MIN_DEFER_TTL_STEPS = 1;
|
|
39
|
+
export const MAX_DEFER_TTL_STEPS = 16;
|
|
40
|
+
const opt = (t) => z.union([t, z.const(undefined)]);
|
|
41
|
+
/** Mode schema: exactly two spellings, no free-form fallback. */
|
|
42
|
+
const ModeSchema = z.union([z.const('observe'), z.const('enforce')]);
|
|
43
|
+
/** Inner object shape (kebab keys). Absence resolves to defaults via schemastery. */
|
|
44
|
+
const SettingsObject = z.object({
|
|
45
|
+
enabled: z.boolean().default(true),
|
|
46
|
+
mode: ModeSchema.default('observe'),
|
|
47
|
+
'enter-budget-bytes': z.number().min(MIN_ENTER_BUDGET_BYTES).max(MAX_ENTER_BUDGET_BYTES)
|
|
48
|
+
.default(24_576),
|
|
49
|
+
'advisory-budget-bytes': z.number().min(MIN_ADVISORY_BUDGET_BYTES).max(MAX_ADVISORY_BUDGET_BYTES)
|
|
50
|
+
.default(8192),
|
|
51
|
+
'memory-budget-bytes': z.number().min(MIN_MEMORY_BUDGET_BYTES).max(MAX_MEMORY_BUDGET_BYTES)
|
|
52
|
+
.default(16_384),
|
|
53
|
+
'defer-ttl-steps': z.number().min(MIN_DEFER_TTL_STEPS).max(MAX_DEFER_TTL_STEPS).default(3),
|
|
54
|
+
});
|
|
55
|
+
/**
|
|
56
|
+
* Namespace schema. Wrapped in the z.const(undefined) union (turn-rules
|
|
57
|
+
* convention) so a genuinely absent namespace value stays absent instead of
|
|
58
|
+
* materializing defaults into the cascade.
|
|
59
|
+
*/
|
|
60
|
+
export const SettingsSchema = opt(SettingsObject);
|
|
61
|
+
/**
|
|
62
|
+
* Ship defaults: enabled, observe mode, and budgets sized from the ledger's
|
|
63
|
+
* observe-mode plan — 24 KiB enter, 8 KiB advisory, 16 KiB memory (recall
|
|
64
|
+
* bodies), 3-invocation defer TTL.
|
|
65
|
+
*/
|
|
66
|
+
export const DEFAULT_INPUT_BUDGET_SETTINGS = {
|
|
67
|
+
enabled: true,
|
|
68
|
+
mode: 'observe',
|
|
69
|
+
'enter-budget-bytes': 24_576,
|
|
70
|
+
'advisory-budget-bytes': 8192,
|
|
71
|
+
'memory-budget-bytes': 16_384,
|
|
72
|
+
'defer-ttl-steps': 3,
|
|
73
|
+
};
|
|
74
|
+
/** Truncate a raw integer setting and clamp it into `[min, max]`, fail-soft. */
|
|
75
|
+
function boundedInt(value, fallback, min, max) {
|
|
76
|
+
const n = typeof value === 'number' && Number.isFinite(value) ? Math.trunc(value) : fallback;
|
|
77
|
+
if (n < min)
|
|
78
|
+
return min;
|
|
79
|
+
if (n > max)
|
|
80
|
+
return max;
|
|
81
|
+
return n;
|
|
82
|
+
}
|
|
83
|
+
/** Resolve one raw boolean setting: a non-boolean falls back to the ship default. */
|
|
84
|
+
function booleanOf(value, fallback) {
|
|
85
|
+
return typeof value === 'boolean' ? value : fallback;
|
|
86
|
+
}
|
|
87
|
+
/** Resolve one raw mode setting: anything but `'enforce'` resolves to `'observe'`. */
|
|
88
|
+
function modeOf(value, fallback) {
|
|
89
|
+
return value === 'enforce' || value === 'observe' ? value : fallback;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Resolve one raw section into the settings shape. The schema above is the
|
|
93
|
+
* validation surface (/config UX); the raw reader must stay fail-soft, so it
|
|
94
|
+
* clamps out-of-bounds integers into the documented bounds instead of rejecting
|
|
95
|
+
* the whole section.
|
|
96
|
+
*/
|
|
97
|
+
function resolveSection(section) {
|
|
98
|
+
return {
|
|
99
|
+
enabled: booleanOf(section.enabled, DEFAULT_INPUT_BUDGET_SETTINGS.enabled),
|
|
100
|
+
mode: modeOf(section.mode, DEFAULT_INPUT_BUDGET_SETTINGS.mode),
|
|
101
|
+
'enter-budget-bytes': boundedInt(section['enter-budget-bytes'], DEFAULT_INPUT_BUDGET_SETTINGS['enter-budget-bytes'], MIN_ENTER_BUDGET_BYTES, MAX_ENTER_BUDGET_BYTES),
|
|
102
|
+
'advisory-budget-bytes': boundedInt(section['advisory-budget-bytes'], DEFAULT_INPUT_BUDGET_SETTINGS['advisory-budget-bytes'], MIN_ADVISORY_BUDGET_BYTES, MAX_ADVISORY_BUDGET_BYTES),
|
|
103
|
+
'memory-budget-bytes': boundedInt(section['memory-budget-bytes'], DEFAULT_INPUT_BUDGET_SETTINGS['memory-budget-bytes'], MIN_MEMORY_BUDGET_BYTES, MAX_MEMORY_BUDGET_BYTES),
|
|
104
|
+
'defer-ttl-steps': boundedInt(section['defer-ttl-steps'], DEFAULT_INPUT_BUDGET_SETTINGS['defer-ttl-steps'], MIN_DEFER_TTL_STEPS, MAX_DEFER_TTL_STEPS),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Register the settings namespace (for /config UX and validation only — the
|
|
109
|
+
* listener reads the raw user file per gate invocation).
|
|
110
|
+
* @param ctx - context that may carry the settings provider.
|
|
111
|
+
*/
|
|
112
|
+
export function registerSettings(ctx) {
|
|
113
|
+
const settings = ctx.get('settings');
|
|
114
|
+
if (settings === undefined)
|
|
115
|
+
return;
|
|
116
|
+
registerNamespaceSafe(ctx, SETTINGS_NAMESPACE, SettingsSchema);
|
|
117
|
+
}
|
|
118
|
+
/** Parse a raw `<dshHome>/settings.json` text into settings, fail-soft. */
|
|
119
|
+
function parseSettings(text) {
|
|
120
|
+
let root;
|
|
121
|
+
try {
|
|
122
|
+
root = JSON.parse(text);
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
return DEFAULT_INPUT_BUDGET_SETTINGS;
|
|
126
|
+
}
|
|
127
|
+
if (typeof root !== 'object' || root === null)
|
|
128
|
+
return DEFAULT_INPUT_BUDGET_SETTINGS;
|
|
129
|
+
const section = root[SETTINGS_NAMESPACE];
|
|
130
|
+
if (typeof section !== 'object' || section === null)
|
|
131
|
+
return DEFAULT_INPUT_BUDGET_SETTINGS;
|
|
132
|
+
try {
|
|
133
|
+
return resolveSection(section);
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
return DEFAULT_INPUT_BUDGET_SETTINGS;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Read the settings DIRECTLY from `<dshHome>/settings.json`, bypassing the
|
|
141
|
+
* merged cascade. Fail-soft: an absent file, parse error, or malformed section
|
|
142
|
+
* yields {@link DEFAULT_INPUT_BUDGET_SETTINGS} (observe mode).
|
|
143
|
+
* @param dshHome - the harness home directory root.
|
|
144
|
+
*/
|
|
145
|
+
export async function readUserSettings(dshHome) {
|
|
146
|
+
let text;
|
|
147
|
+
try {
|
|
148
|
+
text = await readFile(join(dshHome, 'settings.json'), 'utf8');
|
|
149
|
+
}
|
|
150
|
+
catch {
|
|
151
|
+
return DEFAULT_INPUT_BUDGET_SETTINGS;
|
|
152
|
+
}
|
|
153
|
+
return parseSettings(text);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* SYNCHRONOUS raw read of `<dshHome>/settings.json` — the hot-path half of the
|
|
157
|
+
* dual-half pattern: the listener re-reads per gate invocation, so settings
|
|
158
|
+
* hot-toggle takes effect on the next step without a restart. Same fail-soft
|
|
159
|
+
* semantics as {@link readUserSettings}.
|
|
160
|
+
* @param dshHome - the harness home directory root.
|
|
161
|
+
*/
|
|
162
|
+
export function readUserSettingsSync(dshHome) {
|
|
163
|
+
let text;
|
|
164
|
+
try {
|
|
165
|
+
text = readFileSync(join(dshHome, 'settings.json'), 'utf8');
|
|
166
|
+
}
|
|
167
|
+
catch {
|
|
168
|
+
return DEFAULT_INPUT_BUDGET_SETTINGS;
|
|
169
|
+
}
|
|
170
|
+
return parseSettings(text);
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/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,CAAC,OAAe;IAClD,IAAI,IAAY,CAAA;IAChB,IAAI,CAAC;QACH,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,eAAe,CAAC,EAAE,MAAM,CAAC,CAAA;IAC7D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,6BAA6B,CAAA;IACtC,CAAC;IACD,OAAO,aAAa,CAAC,IAAI,CAAC,CAAA;AAC5B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dsh-cc/input-budget",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"description": "Per-step input budget governor: class-based byte budgets, FIFO trim, a deterministic defer backlog and observe-mode shadow state over the final agent/pre-step enter batch (docs/plans/2026-11-12-per-step-input-budget-governor.md)",
|
|
4
|
+
"version": "0.9.5",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/dsh-cc/dsh-cc.git",
|
|
8
|
+
"directory": "packages/context/input-budget"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./lib/index.d.ts",
|
|
14
|
+
"default": "./lib/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./src/*": "./src/*",
|
|
17
|
+
"./package.json": "./package.json"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"lib"
|
|
21
|
+
],
|
|
22
|
+
"license": "Apache-2.0",
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"@deepseek-ai/cordis": ">=0.2.0-rc.2",
|
|
25
|
+
"@deepseek-ai/schemastery": "^3.18.1",
|
|
26
|
+
"@dsh-cc/settings": "^0.9.5"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@dsh-cc/input-ledger": "^0.9.5",
|
|
30
|
+
"@dsh-cc/settings": "^0.9.5"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@deepseek-ai/cordis": "link:../../../../deepseek-harness/vendor/cordis",
|
|
34
|
+
"@deepseek-ai/schemastery": "link:../../../../deepseek-harness/vendor/schemastery",
|
|
35
|
+
"vitest": "^4.1.8",
|
|
36
|
+
"@dsh-cc/input-ledger": "^0.9.5",
|
|
37
|
+
"@dsh-cc/settings": "^0.9.5"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"test": "vitest run"
|
|
44
|
+
}
|
|
6
45
|
}
|