bareloop 0.5.0 → 0.6.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.
@@ -1,25 +0,0 @@
1
- /**
2
- * Distill/update a lineage's rules from one green run's ledger facts.
3
- * @param {object} opts
4
- * @param {object} opts.config the config that went green
5
- * @param {object} opts.provider a bareagent provider — SHELL-owned, sealed
6
- * @param {string[]|null} opts.priorRules the lineage's current rules, if any
7
- * @param {string[]} [opts.revisionDiff] changed config paths, when the run recovered mid-run
8
- * @returns {Promise<{rules: string[]|null, valid: boolean, reds: Array<object>, costUsd: number|null, raw: string}>}
9
- * costUsd is null when the spend could not be priced — the explicit-unknown
10
- * signal (F6: unpriced is never free); callers must not coerce it to 0
11
- */
12
- export function extractRules({ config, provider, priorRules, revisionDiff }: {
13
- config: object;
14
- provider: object;
15
- priorRules: string[] | null;
16
- revisionDiff?: string[] | undefined;
17
- }): Promise<{
18
- rules: string[] | null;
19
- valid: boolean;
20
- reds: Array<object>;
21
- costUsd: number | null;
22
- raw: string;
23
- }>;
24
- export const MAX_RULES: 5;
25
- export const MAX_RULE_CHARS: 200;
@@ -1,201 +0,0 @@
1
- /**
2
- * The retrieval pair (F19). `shell_read` cannot seek — it starts at byte zero — so a
3
- * pointer at a symbol was inert and the worker paged whole files to reach one function.
4
- * `ctx_recall` hands back a POINTER (no body: a search index returns pointers, and bodies
5
- * on every hit rebuild the bloat — measured, a 5-hit recall dumps ~15k tokens unbidden);
6
- * `ctx_get` trades that pointer for ONE chunk. A chunk starts at its doc-comment, so the
7
- * body arrives WITH the docstring that says what it was supposed to do.
8
- * @param {any} lc the run's LiteCtx (rooted at workdir)
9
- * @param {string} workdir
10
- * @param {(type: string, data: object) => void} emit the spine — a retrieval verb whose
11
- * RESULT is invisible cannot be judged: a `ctx_get` that silently reds (stale pointer,
12
- * bad range) looks exactly like one that worked, and the worker's fallback to a
13
- * whole-file read looks like a free choice instead of a forced one.
14
- */
15
- export function createCtxTools(lc: any, workdir: string, emit: (type: string, data: object) => void): ({
16
- name: string;
17
- description: string;
18
- parameters: {
19
- type: string;
20
- properties: {
21
- query: {
22
- type: string;
23
- description: string;
24
- };
25
- n: {
26
- type: string;
27
- description: string;
28
- };
29
- path?: undefined;
30
- startLine?: undefined;
31
- endLine?: undefined;
32
- };
33
- required: string[];
34
- };
35
- execute: ({ query, n }: {
36
- query: string;
37
- n?: number;
38
- }) => Promise<any>;
39
- } | {
40
- name: string;
41
- description: string;
42
- parameters: {
43
- type: string;
44
- properties: {
45
- path: {
46
- type: string;
47
- description: string;
48
- };
49
- startLine: {
50
- type: string;
51
- description: string;
52
- };
53
- endLine: {
54
- type: string;
55
- description: string;
56
- };
57
- query?: undefined;
58
- n?: undefined;
59
- };
60
- required: string[];
61
- };
62
- execute: ({ path: p, startLine, endLine }: {
63
- path: string;
64
- startLine: number;
65
- endLine: number;
66
- }) => Promise<any>;
67
- })[];
68
- /**
69
- * Execute a workflow config against one task under the dumb shell.
70
- *
71
- * @param {object|string} configRaw schema v1 config (object or raw JSON text)
72
- * @param {object} opts
73
- * @param {string} opts.task implement instruction shown to the worker
74
- * @param {string} [opts.target] absolute path the artifact is written to —
75
- * required in text mode; unused in tool mode (the worker writes through
76
- * the gated tools, wherever the fence allows)
77
- * @param {string[]} opts.close argv whose exit code is truth (shell-owned)
78
- * @param {number} [opts.closeExpect] the exit code the SIGNED spec calls success
79
- * @param {{pattern: string, min: number}} [opts.closeJudged] the signed spec's
80
- * judgment-rendered signal — proof the close actually judged something before
81
- * its exit code is believed in EITHER direction (PRD v1.11; the drafted config
82
- * cannot express it, and must not: it is the arbiter's own honesty check)
83
- * @param {string} [opts.closeGapKeep] the signed spec's kept-failures pattern (F28):
84
- * close-output lines matching it survive the gap bound, so a large suite's
85
- * `not ok` names reach the worker instead of being elided into "N fail" — also
86
- * arbiter territory, inexpressible in the drafted config
87
- * @param {string} opts.workdir run directory (litectx root, gate audit, scope base)
88
- * @param {number} opts.capRuns shell iteration budget; the config may tighten via loop.maxIterations, never exceed
89
- * @param {(type: string, data?: object) => object} opts.emit spine emitter
90
- * @param {object} opts.provider a bareagent provider — SHELL-owned binding (adaptlearn F8: an unsealed binding is a gate bypass)
91
- * @param {number} [opts.shellCapUsd=2] the shell's USD cap; a config budgetUsd above it REDS at validation (bounds — no silent clamping)
92
- * @param {number} [opts.closeTimeoutMs] close wall-clock cap, threaded to the shell
93
- * (shell/operator territory — the workflow config cannot express it)
94
- * @param {string[]} [opts.jobWriteScope] the job spec's outer write fence (operator law,
95
- * job-v1) — enforced HERE, the one choke point where a config becomes a Gate:
96
- * every workflow scope must fit inside it (scope-escape config-red otherwise),
97
- * on entry validation and on every revision candidate alike
98
- * @param {(o: {config: object, gaps: string[], policy: any, onLlmResult: any}) => Promise<{candidate: object|null, parseError?: string|null, costUsd?: number}>} [opts.revisor]
99
- * optional mid-run revision seam. Fires ONCE per run after STALL_REDS consecutive
100
- * close reds. The interpreter — never the revisor — owns acceptance: the candidate
101
- * must validate, and gate/escalation/loop.maxIterations must be unchanged
102
- * (arbiter-touch / cap-touch revision-reds otherwise; the run continues on the old
103
- * config). Revisor spend rides the run's own gate handlers — same budget axis as
104
- * the worker.
105
- * @param {string} [opts.closeState] the close's CURRENT output on the tree as it stands
106
- * (the shell's pre-token close check, F13) — shown to the first attempt only, and
107
- * never framed as an attempt: the worker cannot run the close itself (`run` is a
108
- * locked verb), so without this it is asked to fix a failure it cannot see
109
- * @param {'text'|'tools'} [opts.mode] middle mode (2b): 'text' (default) writes the ONE
110
- * target from the response artifact; 'tools' gives the worker Gate-governed file
111
- * tools — SPEC-side territory (the step declares it; the config cannot express it)
112
- * @param {boolean} [opts.layerRoot=false] Layer R (the within-run ratchet, src/root.js):
113
- * shell-assembled fixation detection over the run's own books, injecting an
114
- * escalating summary→verbatim note when consecutive attempts rewrite the same
115
- * files without moving the reds. Inert when the worker is not stuck (RSI §3.3).
116
- * Defaults OFF (decided 2026-07-21): fixation is extinct on every current job
117
- * (F41), so ON is unproven — the field read defers to Layer 2. `true` is the
118
- * ON/experimental arm; never a worker-visible knob
119
- * @param {string[]} [opts.tools] the spec's tool grant (subset of read|grep|write,
120
- * job-v1 validated); defaults to the full menu in tool mode
121
- * @returns {Promise<'green'|'escalated'|'config-red'>}
122
- */
123
- export function interpret(configRaw: object | string, { task, target, close, workdir, capRuns, emit, provider, shellCapUsd, jobWriteScope, revisor, closeTimeoutMs, mode, tools, closeState, closeExpect, closeJudged, closeGapKeep, layerRoot }: {
124
- task: string;
125
- target?: string | undefined;
126
- close: string[];
127
- closeExpect?: number | undefined;
128
- closeJudged?: {
129
- pattern: string;
130
- min: number;
131
- } | undefined;
132
- closeGapKeep?: string | undefined;
133
- workdir: string;
134
- capRuns: number;
135
- emit: (type: string, data?: object) => object;
136
- provider: object;
137
- shellCapUsd?: number | undefined;
138
- closeTimeoutMs?: number | undefined;
139
- jobWriteScope?: string[] | undefined;
140
- revisor?: ((o: {
141
- config: object;
142
- gaps: string[];
143
- policy: any;
144
- onLlmResult: any;
145
- }) => Promise<{
146
- candidate: object | null;
147
- parseError?: string | null;
148
- costUsd?: number;
149
- }>) | undefined;
150
- closeState?: string | undefined;
151
- mode?: "text" | "tools" | undefined;
152
- layerRoot?: boolean | undefined;
153
- tools?: string[] | undefined;
154
- }): Promise<"green" | "escalated" | "config-red">;
155
- /** @typedef {Error & {category?: string, lib?: string}} CategorizedError the failure map's carrier: ralph relays by `category`, and by `lib` when the thrower knows which library owns the failure (the ledger prefers it over prose) */
156
- export const STALL_REDS: 2;
157
- export const PERSONA_TOOLS: string;
158
- export const RETRIEVAL_STRATEGY: string;
159
- export const EDIT_STRATEGY: string;
160
- export const TOOL_BY_VERB: Readonly<{
161
- read: "shell_read";
162
- grep: "shell_grep";
163
- write: "shell_write";
164
- edit: "shell_edit";
165
- recall: "ctx_recall";
166
- get: "ctx_get";
167
- }>;
168
- export const CTX_TOOLS: readonly string[];
169
- export function toolAction(name: string, args: any, workdir?: string): {
170
- type: string;
171
- path: string;
172
- args: {
173
- bytes: number;
174
- tool?: undefined;
175
- };
176
- } | {
177
- type: string;
178
- path: string;
179
- args: {
180
- tool: string;
181
- bytes?: undefined;
182
- };
183
- } | {
184
- type: string;
185
- args: any;
186
- path?: undefined;
187
- };
188
- /**
189
- * the failure map's carrier: ralph relays by `category`, and by `lib` when the thrower knows which library owns the failure (the ledger prefers it over prose)
190
- */
191
- export type CategorizedError = Error & {
192
- category?: string;
193
- lib?: string;
194
- };
195
- /**
196
- * litectx recall hit — body present only with `{body: true}`
197
- */
198
- export type RecallHit = {
199
- body?: string | null;
200
- text?: string | null;
201
- };