@sleepy_panda_srl/portulan 0.2.0 → 0.4.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/README.md +15 -4
- package/cli/README.md +61 -6
- package/cli/advisory.mjs +167 -53
- package/cli/cache-risk.mjs +69 -0
- package/cli/comments.mjs +8 -5
- package/cli/compile.mjs +781 -130
- package/cli/context.mjs +204 -43
- package/cli/doctor.mjs +248 -31
- package/cli/drills.mjs +56 -9
- package/cli/finish.md +34 -0
- package/cli/finish.mjs +8 -67
- package/cli/form.mjs +34 -18
- package/cli/frontmatter.mjs +39 -0
- package/cli/gate.mjs +14 -12
- package/cli/guidance-files.mjs +335 -0
- package/cli/handoff-policy.mjs +76 -0
- package/cli/html-entities.mjs +2130 -0
- package/cli/import-files.mjs +15 -0
- package/cli/index.mjs +77 -24
- package/cli/init-preview.mjs +553 -0
- package/cli/init.mjs +261 -46
- package/cli/instructions-journal.mjs +1185 -0
- package/cli/instructions.mjs +332 -57
- package/cli/ledger.mjs +230 -40
- package/cli/librarian.mjs +103 -19
- package/cli/persona-routing.mjs +209 -0
- package/cli/plugin-lint.mjs +77 -56
- package/cli/portulan.mjs +1 -1
- package/cli/recipe-output.mjs +91 -0
- package/cli/recipe-runner.md +68 -0
- package/cli/recipe-runner.mjs +131 -0
- package/cli/recipe-set.mjs +12 -3
- package/cli/review-meter.mjs +14 -9
- package/cli/ritual-contexts.mjs +103 -0
- package/cli/sessions.mjs +2 -1
- package/cli/spend-analysis.mjs +111 -0
- package/cli/spend-offer.md +53 -0
- package/cli/spend-offer.mjs +93 -0
- package/cli/stop-diagnostics.mjs +114 -0
- package/cli/stop-gate.mjs +133 -90
- package/cli/stop-policy.mjs +14 -0
- package/cli/symbols.mjs +55 -8
- package/cli/telemetry.mjs +66 -17
- package/cli/upgrade.mjs +62 -44
- package/cli/vendor.mjs +207 -125
- package/core/operating/context.md +401 -18
- package/core/operating/evolution.md +3 -2
- package/core/operating/loop.md +9 -4
- package/core/operating/sessions.md +6 -15
- package/core/personas/README.md +75 -0
- package/core/personas/implementer.md +3 -0
- package/core/personas/librarian.md +3 -0
- package/core/personas/reviewer.md +3 -0
- package/core/skills/clarify/SKILL.md +1 -1
- package/core/skills/consolidate/SKILL.md +1 -1
- package/core/templates/handoff.md +6 -2
- package/evals/README.md +23 -7
- package/evals/ab/personas/README.md +111 -0
- package/evals/ab/personas/acquisition.json +330 -0
- package/evals/ab/personas/bindings/implementer.txt +43 -0
- package/evals/ab/personas/bindings/librarian.txt +40 -0
- package/evals/ab/personas/bindings/reviewer.txt +41 -0
- package/evals/ab/personas/corpus.json +69 -0
- package/evals/ab/personas/grader.mjs +171 -0
- package/evals/ab/personas/implementer.json +774 -0
- package/evals/ab/personas/implementer.md +22 -0
- package/evals/ab/personas/librarian.json +758 -0
- package/evals/ab/personas/librarian.md +22 -0
- package/evals/ab/personas/protocol/continuation.mjs.txt +284 -0
- package/evals/ab/personas/protocol/first-outcome.mjs.txt +227 -0
- package/evals/ab/personas/protocol/first-probe.mjs.txt +172 -0
- package/evals/ab/personas/protocol/publisher.mjs.txt +126 -0
- package/evals/ab/personas/protocol/second-probe.mjs.txt +193 -0
- package/evals/ab/personas/repairs/first-control-answer.txt +23 -0
- package/evals/ab/personas/repairs/grader-before-decode-repair.mjs.txt +143 -0
- package/evals/ab/personas/reviewer.json +758 -0
- package/evals/ab/personas/reviewer.md +22 -0
- package/evals/releases/0.3.0.json +150 -0
- package/evals/releases/0.3.0.md +68 -0
- package/evals/releases/0.4.0.json +154 -0
- package/evals/releases/0.4.0.md +69 -0
- package/package.json +7 -2
- package/packs/.claude-plugin/plugin.json +2 -1
- package/packs/README.md +7 -4
- package/packs/rituals/checkpoints/README.md +35 -0
- package/packs/rituals/checkpoints/pack.json +3 -2
- package/packs/tools/README.md +8 -8
- package/packs/tools/local-llm/README.md +176 -0
- package/packs/tools/local-llm/pack.json +32 -0
- package/packs/tools/local-llm/personas/local-worker.md +44 -0
- package/packs/tools/local-llm/runner/local-llm.mjs +1779 -0
- package/packs/tools/local-llm/skills/delegate-local/SKILL.md +88 -0
- package/packs/tools/local-llm/verify/README.md +18 -0
- package/spec/README.md +37 -3
- package/spec/migrations/0009-instruction-sections-on-read.mjs +60 -11
- package/spec/migrations/0011-persona-bindings-compiled.mjs +23 -0
- package/spec/migrations/README.md +6 -0
- package/spec/pack.schema.json +12 -3
- package/spec/slots.md +272 -123
- package/spec/workspace.schema.json +67 -11
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# `tools/local-llm` — Hybrid local-model execution under Portulan's rails
|
|
2
|
+
|
|
3
|
+
A tool pack for **Hybrid AI Orchestration**, argued in Proposal [`0039`](../../../.portulan/proposals/0039-a-local-model-runs-without-the-host-floor-and-under-a-thinking-cap.md). It lets a frontier orchestrator session offload bounded code transformations, verify-gated red→green retries and a screen of a curated slot for duplicate files to a local OpenAI-compatible runtime (such as **LM Studio** on `http://127.0.0.1:1234/v1` or **Ollama** on `http://127.0.0.1:11434/v1`) with **no API tokens for the local model's own work** and a **zero-floor prompt prefix**. Each call to it is still a parent request, which re-reads the parent's context like any other (fact 1 below).
|
|
4
|
+
|
|
5
|
+
Composed through a workspace's `packs` array as `tools/local-llm`.
|
|
6
|
+
|
|
7
|
+
| Contributes | What |
|
|
8
|
+
|---|---|
|
|
9
|
+
| Skill | [`delegate-local`](skills/delegate-local/SKILL.md) — the pass a frontier session follows to hand a bounded edit or digest to the runner; its description names the precondition, a workspace composing this pack and a server answering on loopback |
|
|
10
|
+
| Persona | [`local-worker`](personas/local-worker.md) — a context-firewall worker operating with an omitted host floor (`omitClaudeMd`) and a hard input-byte ceiling |
|
|
11
|
+
| Verify | [`runner-rails`](verify/README.md) — offline verification of the runner's loopback-only guard, input-budget rail, rollback contract, and `dedup`'s refusals (zero network calls) |
|
|
12
|
+
| Gate | `local-llm-off-loopback` (`propose`) — marks leaving loopback (`127.0.0.1` / `localhost` / `[::1]`) as a decision requiring explicit approval |
|
|
13
|
+
|
|
14
|
+
The skill registers where a plugin manifest declares `skills/`, and this repository's manifests may
|
|
15
|
+
declare only the skills of packs its own workspace composes, as its `.portulan/workspace.json` composes
|
|
16
|
+
this one.
|
|
17
|
+
|
|
18
|
+
## Why this pack exists
|
|
19
|
+
|
|
20
|
+
Proposal [`0036`](../../../.portulan/proposals/0036-what-a-host-loads-into-every-context-is-budgeted.md) budgets what a host loads into every fresh context, and Proposal [`0038`](../../../.portulan/proposals/0038-what-a-change-spends-is-measured.md) prices what a change spends across turns (`m_r × (F·T + g·T²/2)`). Together they expose two structural facts about hybrid local+cloud development:
|
|
21
|
+
|
|
22
|
+
1. **Parent-context turns are quadratic, and a local call is one of them.** Every tool call in a frontier session re-reads the entire session history, the one that runs the runner included, so a local call costs nothing only in the local model's own tokens. A one-span `transform` that replaces one parent Edit saves the few hundred output tokens between writing the instruction and writing the code, and a miss, a call that keeps nothing or a kept edit the parent then touches up, adds a whole request. One run measured in [#583](https://github.com/sleepy-panda-srl/portulan/issues/583) missed 20% of its calls, against a break-even of 5–12% at a 236k-token context and the price ratios the skill's [*When it pays*](skills/delegate-local/SKILL.md#when-it-pays) states, and spent more parent tokens than it saved. A 10-file comment cleanup sent as ten `transform` calls, each its own tool call, is ten parent requests; a loop over the ten inside one Bash call is one, and that batching is not measured.
|
|
23
|
+
2. **Local models choke on the host floor (`F`), not on the task.** A cloud subagent inherits a 44k–85k token prefix (`F`) subsidized by provider prompt caching. On local hardware, pre-filling 85k tokens into a 30B model's KV cache takes tens of seconds before the first token appears, whereas a **surgical prompt of a few hundred tokens** (built using [`cli/symbols.mjs`](../../../cli/symbols.mjs) spans) pre-filled in 0.85–1.9 seconds in proposal 0039's measurement.
|
|
24
|
+
|
|
25
|
+
## What the runner enforces in code
|
|
26
|
+
|
|
27
|
+
[`runner/local-llm.mjs`](runner/local-llm.mjs) has **zero npm dependencies** (Node.js `>=20` built-in HTTP, `fetch` and `node:child_process`) and enforces these rails:
|
|
28
|
+
|
|
29
|
+
1. **Loopback-only by default.** Only `127.0.0.1`, `localhost`, and `[::1]` are permitted unless `--allow-remote` is explicitly passed, and a redirect is refused rather than followed off the machine. A proxy listening on loopback that forwards elsewhere is not visible to it, which is what the `local-llm-off-loopback` gate fragment records.
|
|
30
|
+
2. **Zero-floor input budget (`--max-input-bytes`, default `32768`).** Refuses oversized prompts, and for `dedup` any file over the ceiling, before hitting the local server, directing the caller to scope with [`cli/symbols.mjs`](../../../cli/symbols.mjs) and `--lines` first. A value that is not a whole number is refused rather than read as no limit.
|
|
31
|
+
3. **Explicit thinking request (`--effort low`).** Passes `reasoning_effort: "low"` and `enable_thinking: false` by default. Backend/template support determines their effect; sending these fields is not a hard reasoning-token cap or a guarantee against output-budget exhaustion.
|
|
32
|
+
4. **Verify-gated transforms (`transform --file <path> --verify <cmd>`, `--verify` required).** Applies the local model's edit, runs the verify command, retries with the end of its output on exit `1`, and **restores the original file byte-for-byte** unless the command reaches exit `0`. Any exit other than `0` or `1` — `2`, a missing command, a signal — is no verdict: the file is restored at once and the runner exits `2`. SIGINT, SIGTERM and SIGHUP, whether they arrive during the model call or while the verify command runs, stop the verify, restore the file and exit `2`. **The limits:** this is a rollback, not an atomic write — any other signal that ends the runner (SIGKILL and SIGQUIT among them) or a power loss between the edit and its verdict leaves the edit in place, and since the verify runs in a process group of its own, such a signal leaves the verify running too, even one sent to the runner's whole group. Signal handling is POSIX's: on Windows no SIGTERM arrives, and stopping the verify stops only its shell.
|
|
33
|
+
5. **Role screening (`eval`).** Grades an installed local model against Portulan's own [`cli/comments.mjs`](../../../cli/comments.mjs), [`cli/doctor.mjs`](../../../cli/doctor.mjs), and [`cli/skill-goldens.mjs`](../../../cli/skill-goldens.mjs) predicates across `code`, `codify`, and `handoff` tasks. It takes **one sample per task and has no baseline arm**, so it is a screen, not the A/B run `0038` requires before a role is routed: a model that fails it is not routed, and passing it earns nothing. It needs `cli/` beside `packs/`, as the repository and the npm package carry it, exiting `2` where only `packs/` was installed. The A/B run is [*The A/B record*](#the-ab-record) below.
|
|
34
|
+
|
|
35
|
+
Default loopback `/chat/completions` calls use a finite 15-minute deadline over the
|
|
36
|
+
connection, headers and complete response body, with a 256-KiB response limit.
|
|
37
|
+
This avoids Node fetch's five-minute header wait for non-streaming thinking models.
|
|
38
|
+
`localhost` is pinned to 127.0.0.1 without DNS; `[::1]` remains available. Redirects
|
|
39
|
+
are refused. Explicit injected fetches, authorized remote calls and embeddings
|
|
40
|
+
retain their existing transport behavior and response capacity. A caller injecting
|
|
41
|
+
its own transport can explicitly use the exported `localModelFetch`; the default
|
|
42
|
+
repair cannot change a transport hidden inside an injection.
|
|
43
|
+
|
|
44
|
+
A response ending with `finish_reason: length` is incomplete and is rejected before
|
|
45
|
+
a replacement or verifier can run. Workspaces may enforce stronger completion or
|
|
46
|
+
slice limits without changing earned routing or model profiles. The code extractor
|
|
47
|
+
accepts valid whitespace/language fences, preserves inline backticks, and rejects
|
|
48
|
+
an unfinished fence. Provenance: owner Marius, November 5, 2026; local thinking
|
|
49
|
+
generations were interrupted by a client deadline and valid generated fences were
|
|
50
|
+
misparsed. These repairs change transport/completion handling, not model quality.
|
|
51
|
+
|
|
52
|
+
A receipt prints `reasoning=` as a subset of `out=` and `cached-in=` as a subset
|
|
53
|
+
of `in=`; neither is added to its parent. Counts must be safe nonnegative integers
|
|
54
|
+
and subsets cannot exceed their reported parent. Missing, invalid or unverifiable
|
|
55
|
+
counts print `?`; reported zero stays zero. Transform attempts sum each measurement
|
|
56
|
+
once, with an unknown attempt making that sum unknown. `time=` is summed model
|
|
57
|
+
request time: the runner does not stream, so it cannot see a first token. The ledger
|
|
58
|
+
accepts both historical and extended receipts and continues counting parent totals.
|
|
59
|
+
Update runner and ledger together: older strict receipt readers do not understand
|
|
60
|
+
the added fields.
|
|
61
|
+
|
|
62
|
+
On `length`, the diagnostic distinguishes a measured all-reasoning response from
|
|
63
|
+
other combined-budget exhaustion. A short input does not cap thinking. Inspect the
|
|
64
|
+
backend's actual thinking controls and the task contract before another request;
|
|
65
|
+
do not silently lower a pinned profile, retry identical work, or accept truncated
|
|
66
|
+
output. An advertised reasoning-budget parameter needs a binding runtime test,
|
|
67
|
+
not just a short successful response. Provenance: the November 6 Q06 investigation
|
|
68
|
+
on [#578](https://github.com/sleepy-panda-srl/portulan/issues/578#issuecomment-6695966000),
|
|
69
|
+
with accounting on [#571](https://github.com/sleepy-panda-srl/portulan/issues/571).
|
|
70
|
+
|
|
71
|
+
## Screening a slot for duplicates
|
|
72
|
+
|
|
73
|
+
`dedup --dir <slot-dir> [--threshold 0.80] [--model <id>] [--max-input-bytes <per file>]` embeds every file directly in the directory whose name ends in `.md`, in any letter case, sorted by name, in one `POST /v1/embeddings` request to the loopback endpoint, with `text-embedding-nomic-embed-text-v1.5` (`PORTULAN_LOCAL_EMBED_MODEL`) unless `--model` names another; `--role` picks a chat model and is refused here. It prints each pair whose cosine similarity is at or above the threshold, highest first and ties in file-name order, one line each, `0.829 0036-….md 0038-….md`, and two lines on stderr: `dedup files=8 pairs=1 threshold=0.8`, followed by the shared receipt `OK mode=dedup model=… attempts=1 in=…t out=? time=…ms rate=? reasoning=? cached-in=? spend=$0.00`. The ledger reads the receipt as embedding work at $0.00; output tokens and rate are unreported, never zero.
|
|
74
|
+
|
|
75
|
+
- **A slot's `README.md` is left out**, in any letter case: it describes the slot rather than being one of its entries, and would rank against every entry it summarizes. Subdirectories, symbolic links and other files are left out too.
|
|
76
|
+
- **The ceiling is per file**, since the model embeds each input on its own, and it measures the file's text: its size on disk before it is read, and its UTF-8 bytes after. A file over it refuses the run with exit `1`, naming every such file with its size, and nothing is truncated. The request as a whole is not capped: a slot of `n` files sends at most `n` times the ceiling of file text, which JSON escaping can enlarge in the request body, to about six times for control characters. Raise `--max-input-bytes` only as far as the embedding model's context holds.
|
|
77
|
+
- **The threshold is a plain decimal from `-1` to `1`**, the range of a cosine; `-1` lists every pair. Anything else is exit `2`, as every malformed argument to the runner is, and never read as the default.
|
|
78
|
+
- **Exit `0` is a run, with pairs or with none**, since a candidate pair is for a human to judge, not a red. Exit `1` is a refusal before any request: an endpoint off loopback, or a file over the ceiling. Exit `2` is no server, a redirect, an HTTP error, a response that is not one finite vector of one length per file, or a directory with fewer than two entries to compare. A zero vector scores `0` against everything rather than `NaN`.
|
|
79
|
+
|
|
80
|
+
A score is a candidate, not a verdict: the runner neither merges nor edits a file.
|
|
81
|
+
|
|
82
|
+
## Delegating to it
|
|
83
|
+
|
|
84
|
+
The pass is the [`delegate-local`](skills/delegate-local/SKILL.md) skill: check the server with
|
|
85
|
+
`status`, scope the input with [`cli/symbols.mjs`](../../../cli/symbols.mjs) and `--lines`, choose the
|
|
86
|
+
supported role by task shape, gate every edit with `--verify`, and read only the receipt back.
|
|
87
|
+
The acquired [record](../../../evals/ab/local-worker.md) supports `code` at low effort; shared `prose`
|
|
88
|
+
is disabled because codify failed all five local turns. `summarize` defaults to that disabled role and
|
|
89
|
+
refuses. An explicit `--model` without `--role` is an operator-selected candidate, not automatic routing.
|
|
90
|
+
Delegate one complete function or a small test group per call, specify one observable change, prefer
|
|
91
|
+
serial calls, and keep output to the selected replacement. On truncated output inspect the diagnostic and task contract; on transport
|
|
92
|
+
failure inspect the transport; on verifier failure inspect code. For reasoning-only
|
|
93
|
+
exhaustion, investigate backend/profile/task behavior before selecting another span.
|
|
94
|
+
Do not lower an operator-pinned
|
|
95
|
+
model/effort or bypass verification. This advice reduces failures, does not guarantee completion.
|
|
96
|
+
|
|
97
|
+
## The A/B record
|
|
98
|
+
|
|
99
|
+
The acquired [capture](../../../evals/ab/local-worker.json) and its generated
|
|
100
|
+
[register](../../../evals/ab/local-worker.md) record five turns per task and arm on 2026-11-03:
|
|
101
|
+
code L5/H5, codify L0/H3, handoff L5/H5. The [acquisition note](../../../evals/ab/local-worker-acquisition.md)
|
|
102
|
+
keeps the failed authentication acquisition and the authorized host-only replacement auditable.
|
|
103
|
+
|
|
104
|
+
The rule fixed before outcomes requires all five local turns to pass and all five host turns to
|
|
105
|
+
complete, with local passes at least host passes. A positive 5/5 tie qualifies; a 0/5 tie does not.
|
|
106
|
+
Both tasks must qualify for the shared prose role. Thus **code is enabled and prose is disabled**.
|
|
107
|
+
Operational defaults and explicit `--role` calls require the measured model at low effort; a model
|
|
108
|
+
override or environment variable cannot silently substitute another. Explicit `--model` without
|
|
109
|
+
`--role`, `eval` and `eval --ab` remain candidate paths and never enable routing by themselves.
|
|
110
|
+
|
|
111
|
+
`EARNED_ROUTING` embeds the capture's SHA-256, measured model IDs and support bits, so packs-only
|
|
112
|
+
installs need no root `evals/` directory at runtime. The repository's
|
|
113
|
+
[`cli/local-routing.mjs`](../../../cli/local-routing.mjs) regrades the record, reproduces its register,
|
|
114
|
+
and independently derives those bits and models before comparing them with the shipped table.
|
|
115
|
+
It is repository workshop tooling, excluded from npm like the earlier A/B instruments.
|
|
116
|
+
|
|
117
|
+
- **`eval --ab --k 5 --seed <s> --host-cmd "<command>" --host-model <id> --write` captures it.** Arm L
|
|
118
|
+
is each task's model as routed (`code` to `--role code`; `codify` and `handoff` to `--role prose`)
|
|
119
|
+
at `--effort low`, on loopback, with a sampling seed per turn derived from `--seed`. Arm H is the host
|
|
120
|
+
agent, given the same prompt as one text, as the last argument of the command `--host-cmd` names, in
|
|
121
|
+
an empty directory it removes afterwards. Both arms are graded by `eval`'s predicates, `k = 5` per
|
|
122
|
+
(task, arm) cell, the k ruled for `evals/ab/baseline.md`. The record names both models, the host's
|
|
123
|
+
version, the commit, the machine and the seed, and the sha256 fingerprints of the loaded runner source, the predicates and the
|
|
124
|
+
prompts it was graded under, as the capture recorded them, since nothing can later verify the first; the register carries `baseline.md`'s limit: `k = 5` per cell supports a
|
|
125
|
+
recorded rate and nothing else. The machine is the CPU model, the memory, the platform and
|
|
126
|
+
architecture, and the Node version, and never the hostname.
|
|
127
|
+
- **Arm H consumes host-account usage and its prompts leave the machine**, fifteen host calls, so it crosses the loopback
|
|
128
|
+
rail the rest of the runner holds and that `local-llm-off-loopback` records. Usage may be charged
|
|
129
|
+
through an API account or covered by a subscription; this acquisition used Claude Max sign-in with
|
|
130
|
+
Sonnet 5.5 and a configured total ceiling of $2.25, not an independently measured invoice amount. It runs only where
|
|
131
|
+
`--host-cmd` names the host command; without it `--ab` refuses with exit `1`, the answer the runner
|
|
132
|
+
gives any refused endpoint, before anything is contacted. **It runs under the operator's full
|
|
133
|
+
environment and credentials**, which is how it reaches the host's account and also how anything the
|
|
134
|
+
operator's configuration loads reaches arm H. A command carrying `--dangerously-skip-permissions` or
|
|
135
|
+
`--permission-mode bypassPermissions` is refused with exit `2`, by the check `cli/ab-run.mjs` uses.
|
|
136
|
+
Arm L runs first, at `$0.00`, so a local failure stops the capture before any host call.
|
|
137
|
+
`--host-model` is recorded as declared: the runner does not observe the host's model.
|
|
138
|
+
- **The command is split on whitespace, with no shell**, so no argument of it can hold a space, and a
|
|
139
|
+
quoted one arrives in pieces. Its version is read by running the whole command with `--version`
|
|
140
|
+
appended, so a wrapper such as `env` reports the host it runs rather than itself; a host that read
|
|
141
|
+
`--version` as prompt text would answer it as a turn, and the record would show that answer as its
|
|
142
|
+
version.
|
|
143
|
+
- **Every turn is journalled before the next starts**, under the repository's git directory
|
|
144
|
+
(`git rev-parse --git-path portulan/local-worker-journal`), where no commit and no `git status` sees
|
|
145
|
+
it. SIGINT, SIGTERM or SIGHUP stops the running host turn, removes its directory, keeps the journal
|
|
146
|
+
and exits `2`; the same command run again resumes, re-running only turns the journal lacks, and
|
|
147
|
+
refuses with exit `2` a journal taken under other conditions (commit, tree, machine, seed, models,
|
|
148
|
+
endpoint, host command, version and model, or any fingerprint), since its arm-H turns were paid
|
|
149
|
+
for and removing it is the operator's act. A host that writes more than 16 MiB stops the capture with
|
|
150
|
+
exit `2` and the turn is re-run on resume. **The limit:** SIGKILL, or a power loss, leaves the running
|
|
151
|
+
host turn's directory behind and, since the host runs in a process group of its own, the host still
|
|
152
|
+
running and billing a turn the journal will not hold; the journal still resumes, and that turn runs again. The journal is removed once the
|
|
153
|
+
record is written, and a capture is refused where `evals/ab/local-worker.json` exists: a record is
|
|
154
|
+
captured once, and removing it is the operator's deliberate act. The final record is created
|
|
155
|
+
exclusively too: if another record appears during capture, it and its register are preserved,
|
|
156
|
+
exit `2` leaves the current journal for recovery. This prevents overwrites; it is not a lock on
|
|
157
|
+
concurrent journal writers or a crash-atomic publication. Different loaded runner bytes refuse
|
|
158
|
+
journal resume even at the same commit and with both trees dirty.
|
|
159
|
+
- **`eval --verify` checks it without running a model**: the record's shape, its matrix total over `k`,
|
|
160
|
+
every arm-L seed against `--seed`, every turn's model against the routing, **every completed turn
|
|
161
|
+
regraded** by the predicates as they ship, the prompts' fingerprint, the cells re-folded from the
|
|
162
|
+
turns, and the register byte-compared with a fresh render. A verdict that regrades differently is
|
|
163
|
+
exit `1`, and the finding says whether the predicates moved since capture or the record no longer
|
|
164
|
+
matches its own output: either way the figures would not hold under the screen that ships. A
|
|
165
|
+
predicate file that changed while every verdict regrades the same is no finding. A missing record is
|
|
166
|
+
exit `2`, and so is a payload with no `cli/` beside `packs/`, since nothing there can regrade. A
|
|
167
|
+
record carrying the synthetic fixture's `fixture` field is exit `1` from `--verify` and `--write`
|
|
168
|
+
alike: a synthetic fixture is not a capture.
|
|
169
|
+
`eval --write` re-renders the register from the record, refusing one `--verify` would red.
|
|
170
|
+
|
|
171
|
+
The `ab-run` recipe runs the earlier baseline verifier, exact no-model `eval --verify`, and the
|
|
172
|
+
shipped-routing verifier on every pull request. A red or could-not-run result survives later greens;
|
|
173
|
+
exit `2` takes precedence over exit `1`. No model is rerun in CI. `k = 5` supports these recorded rates,
|
|
174
|
+
not general reliability, arbitrary task quality or independently observed host model identity.
|
|
175
|
+
|
|
176
|
+
Not for multi-file architectural planning, ambiguous requirements (`clarify`), or pre-merge verdicts (`reviewer`).
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"portulan": {
|
|
3
|
+
"pack": "1.0",
|
|
4
|
+
"version": "0.2.0"
|
|
5
|
+
},
|
|
6
|
+
"name": "local-llm",
|
|
7
|
+
"category": "tools",
|
|
8
|
+
"summary": "Zero-dependency local LLM runner (LM Studio / Ollama) with a verify-gated red-to-green file transform loop, a zero-floor input budget rail, role evals, an embedding screen for duplicate files in a curated slot, and loopback-only enforcement.",
|
|
9
|
+
"doc": "README.md",
|
|
10
|
+
"contributes": {
|
|
11
|
+
"skills": ["skills/"],
|
|
12
|
+
"personas": ["personas/local-worker.md"],
|
|
13
|
+
"verify": [
|
|
14
|
+
{
|
|
15
|
+
"id": "runner-rails",
|
|
16
|
+
"run": "node ${PACK_ROOT}/runner/local-llm.mjs --verify-offline",
|
|
17
|
+
"requires": ["node"],
|
|
18
|
+
"doc": "verify/README.md"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"gates": [
|
|
22
|
+
{
|
|
23
|
+
"id": "local-llm-off-loopback",
|
|
24
|
+
"tier": "propose",
|
|
25
|
+
"action": {
|
|
26
|
+
"none": "No honest shell matcher. Whether a local-model invocation stays on the machine depends on the resolved endpoint (`--base-url`, `PORTULAN_LOCAL_LLM_URL`, or a proxy config), not on the binary name. `runner/local-llm.mjs` refuses non-loopback hosts in code unless `--allow-remote` is passed; this fragment records the policy boundary that a host permission rule cannot see."
|
|
27
|
+
},
|
|
28
|
+
"reason": "Routing a task to a local model is a spend and confidentiality boundary only while the endpoint resolves to loopback (`127.0.0.1`, `localhost`, `[::1]`). Pointing a local worker at a remote endpoint sends workspace context off-machine under a local tool's name; propose the remote endpoint explicitly before running."
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: local-worker
|
|
3
|
+
description: Executes bounded file transformations, test-fixture drafts, handoff compressions, and research digests on a local OpenAI-compatible model (LM Studio / Ollama) with an omitted host floor and a verify-gated rollback loop. Delegate surgical, single-file or read-parallel summarization work to it; never ask it to own multi-file architecture or merge decisions.
|
|
4
|
+
tools: [read, search, edit-code, run-verify]
|
|
5
|
+
effort: low
|
|
6
|
+
omitClaudeMd: true
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Persona — Local Worker
|
|
10
|
+
|
|
11
|
+
> A context-firewall worker whose whole value is **what it does not load and what it does not spend**.
|
|
12
|
+
> A frontier session re-reads its entire prefix (`F + g·T`) on every tool call; a cloud subagent inherits
|
|
13
|
+
> the host floor (`F ≈ 44k–85k` tokens). The local worker runs against a loopback model (`127.0.0.1`) with
|
|
14
|
+
> the host instruction floor omitted (`omitClaudeMd: true`), a hard input-byte ceiling, and a verify
|
|
15
|
+
> recipe that gates its output before anything returns to the parent loop.
|
|
16
|
+
|
|
17
|
+
## Charter
|
|
18
|
+
|
|
19
|
+
- **For:** executing one bounded, verify-gated code transformation (`transform --file <path> --verify <cmd>`),
|
|
20
|
+
drafting unit tests or fixtures against an explicit signature, compressing a session log into a
|
|
21
|
+
bounded handoff, or distilling a file span into a compact digest for the parent session.
|
|
22
|
+
- **Not for:** cross-cutting architectural design, multi-branch coordination, or final pre-merge verdicts
|
|
23
|
+
(`reviewer` / `supervisor`). It does not accept rules (`librarian`) and it does not take outward actions.
|
|
24
|
+
|
|
25
|
+
## Autonomy reach
|
|
26
|
+
|
|
27
|
+
Acts in **Auto** to read scoped inputs, run local loopback inference, apply edits in place, kept only on a
|
|
28
|
+
green verify and rolled back otherwise, and run the workspace's verify recipe. Its output into any curated
|
|
29
|
+
slot (memory, proposals, handoffs) is a draft into a **Propose** or **Gated** decision owned by the
|
|
30
|
+
parent session or human. **Prohibited is not a reach** and does not appear here as a permission: it is
|
|
31
|
+
the tier no role may act in.
|
|
32
|
+
|
|
33
|
+
## Read / write posture
|
|
34
|
+
|
|
35
|
+
Reads only the scoped files or symbol spans passed to it — never the full repository tree or the
|
|
36
|
+
always-loaded host floor. Writes are isolated to a single target file under a rollback guard: unless the
|
|
37
|
+
verify command exits `0` within the retry cap, the original bytes are restored before the worker exits,
|
|
38
|
+
short of the signals and power loss the pack's README names.
|
|
39
|
+
|
|
40
|
+
## Memory scope
|
|
41
|
+
|
|
42
|
+
Its own `local-worker` scope in the adopting workspace's memory layer: which task shapes, prompt budgets,
|
|
43
|
+
and local model identifiers pass the workspace's verify recipes on the first try versus which require
|
|
44
|
+
frontier escalation. Kept separate from `implementer` and `reviewer` memory.
|