Repository navigation
heavy facts: learn agent costs from finished agent scopes (#882 D5) - #1298
Open
scuttletoby wants to merge 894 commits into
Open
scuttletoby wants to merge 894 commits into
scuttletoby wants to merge 894 commits into
Conversation
…#875) (#1215) * fork seams: announce the fork budget lines in AgentContextBudget.test.ts (#875 PR 6) Co-Authored-By: Claude Opus 5.5 <[email protected]> * MCP profiles PR 6: delegate_task gives a sub-agent a narrower profile delegate_task takes an optional mcpProfile. Seat 2 checks it within what the sub-agent would get without it (its role default cut to the caller's) and records it for the child's thread before the dispatch. Every read of a delegated child's profile cuts the pick to that again, for the whole lineage; a task for another machine carries the pick instead of the parent's. A retry keeps the first pick; an unreadable record refuses. Part of #875 Co-Authored-By: Claude Opus 5.5 <[email protected]> * starterMcpProfiles: decodeStarterPicks is used only in this file Co-Authored-By: Claude Opus 5.5 <[email protected]> * delegate_task: the sub-agent's pick is narrowMcpProfile, a narrowing-only field The tool field shared the person-only mcpProfile setting's name. It is now narrowMcpProfile, and the person-only guard also finds a field whose name only contains a setting's, passing only reviewed narrowing picks by tool and field. The tool list grows by the one field (budget updated). Part of #875 Co-Authored-By: Claude Opus 5.5 <[email protected]> * Put agentContextBudget.json back as main has it Co-Authored-By: Claude Opus 5.5 <[email protected]> * MCP profiles PR 6: one pick per child id, no leftovers; fork bytes in the fork budget The pick is checked before the slot gate and bound to the child's id after it, under the record's lock: a call in flight on the same id must name the same pick, an accepted child keeps its first pick, a refusal or a stop before the child is made removes the record, and a retry without a pick drops one a stopped server left. A remote retry of an accepted task with a different pick is refused. Recorded names are trimmed. agentContextBudget.json is back as main has it: upstream's budget test measures each tool without the fork's input fields (the lines announced in the base PR), and ForkAgentContextBudget.test.ts counts them in forkAgentContextBudget.json. Part of #875 Co-Authored-By: Claude Opus 5.5 <[email protected]> * delegateMcpProfile: the retry refusal and the release are used only in this file Co-Authored-By: Claude Opus 5.5 <[email protected]> * starterMcpProfiles, delegateMcpProfile: the claim and hold types stay in their files Co-Authored-By: Claude Opus 5.5 <[email protected]> * MCP profiles PR 6: a pick is never dropped on a read that fails A child counts as made when the thread store has it or its command has a receipt, read from the receipt store with its errors kept: a failed read refuses the call and never means "not made", and release keeps a record unless it is known that nothing was made. Profile reads with no state folder refuse delegated-child lineages, and the plan read reads the picks. A task for another machine binds the first pick sent per clientRequestId, recorded after the checks there (no leftover on a refusal, a retry after a half-way stop is matched). A retry while the child is still being prepared is told so. Part of #875 Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…sh-session row (#877) (#1235) The 11-21 design wrapped upstream's fresh-session line in a scope, which the formatter re-indents, so the seam check refused it. The new design keeps upstream's lines in place: one fork element before that line renders "Handoff N" for a handoff's first message and hides its next sibling, upstream's "New session" divider. The unused 11-21 announcements (the scope tags and the V2LifecycleRow.tsx lines) are dropped. Co-authored-by: Claude Opus 5.5 <[email protected]>
…thon (#1233) The gate's reasons quote comment text with Python's own repr, which escapes by the runner's Unicode. On a Python with Unicode 16 a symbol new there (U+1FAE9) printed as itself, where the gate's Unicode 15.0 and T3's port write \U0001fae9: the same head got another reason text depending on the runner. lens.py_repr pins it to PY_UNICODE's table (escapes what that Unicode leaves unassigned; refuses, as UnicodeDrift, a code point only that Unicode assigns), and the four quoting sites use it. The table test now checks the table as far as the runner's Python can tell (the full table on the pinned Unicode, monotonic on a newer or older one) and expects the unicode vectors' refusal where this Python assigns a code point a rule reads otherwise, instead of asserting the runner's version. Co-authored-by: Claude Opus 5.5 <[email protected]>
…5) (#1236) One fork element just before upstream's fresh-session line in UserMessageRow renders "Handoff N" for a handoff's first message (a fresh-session user message with the server's handoff id for its thread and a [T3 handoff N] header) and hides its next sibling, upstream's "New session" divider, with CSS. Any other message renders nothing and hides nothing; old or partial rows give nothing too. Spends the three lines announced in #1235. Co-authored-by: Claude Opus 5.5 <[email protected]>
… like OpenCode Upstream pingdotgg#41726 made recovering a failed usage probe on the interval opt-in (recoverUsageOnInterval). The fork's test of the interval loop's own answer still assumed every driver recovers; it now opts in the way the OpenCode driver does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ressure too Upstream's t3_environment_read now adds a machine field that samples HostResources.readPressure. The fork's linked-machine test mocked only read, so the box's handler died and the read came back as an error. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… now needs Upstream pingdotgg#44369 made ProjectionStore.layer need effect/crypto/Digest (its pull request sweep reuses a decode while the payload digest matches). Two fork reads build their own store inside an Effect (the lens_start visibility check and the Claude MCP profile's lineage read), so Digest leaked into every MCP handler's and the Claude driver's requirements. They now provide NodeCrypto.layerDigest with the store, as upstream's own tests do; the fork tests that build the store do the same. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ironment read its host sampler Upstream's ProjectionStore layer now needs a Digest, and every environment tool now names the HostResources sampler and reads its pressure. The fork's own tests that build a store or an environment toolkit provide both, so they test the same behaviour as before on the new base. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s follow the machine (#882) (#1234) * heavy-install --memory-auto: the slice's memory caps follow the machine (#882 D7) --memory-auto works out the heavy slice's MemoryMax (MemTotal less the capacity rule's margin and its agent floor's start cost, read from the release's capacity-rule.json) and MemoryHigh (90 % of it). The config remembers it, so every later install run works the caps out again from the memory the machine has then. Fixed --memory-high/--memory-max turn it off; the two together are refused; a machine too small for a 1 GB slice is refused with nothing written. Co-Authored-By: Claude Opus 5.5 <[email protected]> * heavy-install --memory-auto: lens round 1 (unit holds the mode, kit's own margin, rounding) - A slice unit someone else wrote is refused in the check step, before anything is written, whatever the config says; the unit is written before the config. A refused run (auto, or a repeated --memory-max on main's path) no longer leaves a config that lets the next plain run overwrite the foreign unit. - The unit itself says its caps are automatic (its second line) and holds the extras, so a switch between automatic and fixed that stops half-way keeps the new way on the next run. - The margin is t3-capacity's own: the release's lib/capacity_rule.py loads and checks the rule (shipped_rule) and works the margin out (_margin: wide without swap, with unreadable swap or without cgroup v2, rounded up). A rule its loader refuses is refused here. - Both caps are rounded down to 64 MB, so small MemTotal moves leave the unit as it is. - README: the container limit is not seen; a machine that drops under the floor refuses upgrades until fixed caps are given. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fork-ci-tests: heavy install.test.py weight ~14s after the lens round's tests Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Upstream's AgentScopeShape now has controlGroups, where agents' memory is read. The slot observer test builds its scope by hand, so it says it has none, like the default scope. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A record of unknown values is advertised as a bare object type, with no value schema. Upstream's model selection options now decode such a record, so the walk missed the four reviewed options paths and the reviewed list no longer matched. The walk now counts a bare object type as open, so the reviewed paths are found again and a new one is caught too. Co-Authored-By: Claude Opus 5.5 <[email protected]>
* Handoff: set the idle timer again after a restart (#877) At start the handoff service re-arms the idle timer of each active thread with handoff on whose last turn completed less than an hour before, as the idle timer (not a turn end), so a restart neither drops a warm thread's idle handoff nor fires a size handoff of its own. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Handoff change file: name #1209 Co-Authored-By: Claude Opus 5.5 <[email protected]> * Handoff: keep the re-arm lookback private to its file knip's unused-exports check failed on HANDOFF_REARM_LOOKBACK: only HandoffService.ts reads it, so it needs no export. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Each kernel's grammar loads on first use. C++'s is large, so on a slow runner its colours took longer than the one second the wait gave them, and the test failed now and then. Each language now waits up to five seconds for its colours. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… viewer (#1046) (#1110) * File links on another environment preview media and open in the files viewer (#1046) A chat file link naming another environment (/t3-environment/<id>/<path>) now previews an image or a video in the chat's media viewer and opens any other file in the thread's files viewer, both through that environment's own connection and file-read scope (the same assets.createUrl as the link's download). Nothing is requested before a click; without a connection or file read there, the viewer and the toast say so and ask nothing. - forkEnvironmentFilePanel.tsx: the files viewer for such a path, built on upstream's AttachmentFilePreview with that environment's media-file asset. - RightPanelSurfaceContent.tsx: the two announced seam lines. - ChatMarkdown.tsx (pending): one fork comment line becomes the line that hands the thread and media viewer to the fork's link props; same count. Co-Authored-By: Claude Opus 5.5 <[email protected]> * File links: keep the ScopedThreadRef import the replay onto main dropped (#1046) Co-Authored-By: Claude Opus 5.5 <[email protected]> * File link browser test: give the device a read session The environment's session atom was never set in the test, so it stayed Initial and every connected environment read as still reconnecting. The test now owns the session atom and sets a read session with the standard scopes, and a new test pins the reconnecting message for a connected environment whose session is not read yet. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Read the file link test's scopes from its session, with the real error type The test's session mock granted the standard scopes whatever the session was, so the "session not read yet" case opened the file instead of showing the reconnect toast the real readers give. Scopes now come from the session atom through sessionHasScope, as in the product. The writable cast uses the session atom's real failure type. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…eys, #862) (#1166) * fork-ci-cache-keys: check that no stale cache can turn a red test green A dependency-free check of every cache step in the fork's workflows (.github/workflows/fork-*.yml). Each key belongs to a family: - download caches (Electron, Chromium, a pnpm store) must name their version; - build output caches (Vitest's module cache, vp's task cache, cargo's target) must hash their lockfile in the key and in every restore key, and be saved under the key the job restored. Per-commit families end with the commit; exact ones (cargo) name only their inputs, have no restore keys and are saved only on a miss. Push-only families restore with actions/cache/restore and save with actions/cache/save only on a push, and only when every step before passed. A key of no family fails, so a new cache gets its rules first. Run by the workflows job through .github/fork-ci-tests.txt; its test also runs the check on the repository's own fork workflows (green on main). Part of #862. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Fork tests: keep Vitest's module cache on Test and Test Web, cargo's on Rust Test (2 shards) and Test Web (3 shards) now restore Vitest's module cache (node_modules/.vitest-cache) before their Test step and save it only on a push to main, exactly as upstream's Test Server shards already do. Vitest keys each entry inside by the file's content, the config files, the plugin names and its own version; the cache key adds the lockfile hash and the commit. Tests always run: only the transform of an unchanged file is reused. Measured locally: apps/web unit shard 1/3 22.4 s cold -> 16.9 s warm, packages/client-runtime 15.8 s -> 13.7 s, packages/shared 10.9 s -> 9.6 s. Rust restores cargo's downloaded crates and the three crates' target folders by rustc's version and the Cargo.lock hashes (exact key, no restore keys) and saves them once per such key on a push. Cargo rebuilds the local crates (the checkout's sources are newer than any cached build) and runs every test; the cache saves rebuilding ~150 dependency crates (~36 s of the 41 s test step). fork-ci-cache-keys.test.cjs gains a check that these jobs restore their cache and save it only on a push (red before this change). Part of #862. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…uthor-check seams (#1227) * Owner questions: GitHub's issue read marks bot actors; announce the author-check seams Waiting on you now tells a bot's label from a person's: the two lines #1204 announced in gitHubIssueJson.ts toActor set isBot as upstream's pull request read does, and move from "announced" to "added". The owner-questions action's own label no longer asks a decided question again on the page. Announces the seam lines of the comment author check (next pull request) in packages/contracts/src/issue.ts and GitHubIssueTracker.ts. Part of #887. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Owner questions: change file names #1227 Part of #887 Co-Authored-By: Claude Opus 5.5 <[email protected]> * Owner questions: the author-check seam passes the issue (GitHub's REST comment list) Part of #887 Co-Authored-By: Claude Opus 5.5 <[email protected]> * Owner questions: announce authorAssociation as an optional key (exact optional type) Part of #887 Co-Authored-By: Claude Opus 5.5 <[email protected]> * Owner questions: a neutral login in the issue-read test Part of #887 Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…ushed worktree child on a linked machine) (#1247) Part of #883. Co-authored-by: Claude Opus 5.5 <[email protected]>
* Fork CI: own copy of setup-ci-deps that caches node_modules Fork workflows now use .github/actions/fork-setup-ci-deps, a copy of upstream's setup-ci-deps with node_modules cached on an exact key (all install inputs, workspace and store path, OS, arch, Node, pnpm and Vite+ versions). On a hit the 1.2 GB pnpm store restore is skipped and install only verifies; on a miss a partial node_modules is removed and the job runs as upstream's does. Lint stays the only saver. The copy records the git blob id of upstream's file. A new check in the workflows job fails when upstream's action changed and the copy was not ported and re-recorded, or when a fork workflow uses upstream's action. The nightly sync runbook does this port first. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Fork CI: node_modules cache saves only on a push to main, off for releases Review round 1 of the fork's setup-ci-deps copy: - Only a push to the default branch that tests the pushed commit saves node_modules (the key script's decision, and the event and ref again in the step). A dispatch or call that tests another ref, a schedule or a pull request only restores. - fork-release.yml turns the cache off in both jobs, and the copy check fails when a workflow that signs or attests its output uses the cache. - The key script is now node (node-modules-key.cjs). It reads empty importers, patch lines with comments or quotes and package.json's patches. Any line it cannot read for sure turns the cache off, as does a runner that is not GitHub-hosted (fleet jobs have per-job paths). The action and the script themselves, and pnpm's settings from the environment, are in the key. - The step-parity test compares each upstream step's whole text. - The runbook ports the copy right after the rebase. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
… relabel (#1255) (#1260) * Labels kit: one general label set, the fork's labels on top, sync and relabel (#1255) fork-kit/labels/general.json holds the 19 general labels (SkyRPG's names and colours) and the general groups (at most one type, size and prio). A project adds its own labels, groups, required groups and the label an unset optional group counts as in the `labels` section of its .t3code/issues.json (D1); the fork's has the seven areas (D5), requires type, size and area, and reads no prio as prio:medium (D2). labels.py sync creates missing labels and fixes colour, description and the name's case, never deletes and lists the labels the config does not know. labels.py relabel applies a reviewed TSV (D6) and refuses the whole list before any write when a label is unknown or missing from the repository, a row is a pull request, or a result breaks the rules. Both are dry runs unless --apply, read once, write only the differences: a second run changes nothing and a run stopped half-way is finished by the next. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Release test: the labels kit installs nothing (NO_INSTALLER row) Co-Authored-By: Claude Opus 5.5 <[email protected]> * Merge gate test: the labels kit is not a gate setting (OTHER_KITS row) Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Part of #882 (D5, "learn the cost of each kind of agent from measured runs": this is the host kit's half). Left for D5: the gradle overcount below, and the server and kit still keep separate run files (they agree through one case file, not one store).
What was wrong
t3-capacitysaid NOT OK even for 1024 MB while the machine had more than 7 GB available. There were two suspects: the pressure level (severe) and the room held back for pieces (reserved). The measurements below show the main cause isreserved.unknownKinds.other, a writer at its start cost of 768 MB. Each one owes768 − demandas room to grow. Real agents use 174–363 MB. So ten idle agents held about 5.2 GB that they never use. The server already learns agent costs (learnedAgentMb), but the kit only learned job kinds.severeis not the main cause. It comes from rare, short spikes, and then holds for 120 s plus 60 s. Even during that hold, the budget would have refused almost all of the same asks.Measured (one shared 12-core, 11.9 GB machine; today)
One CI tool-test step that hit its 17-minute limit. Its
heavy: waiting for capacitylines come every 2 s:Sampled every 2 s for 30.5 min (914 samples).
t3-capacity --long 1000every 30 s (60 readings). The level wasokin all 60, yet free went from 2728 down to −3673 MB as agents and one build job started.Live pieces at one reading. 11 agents with demands 174–361 MB (sum 2867), owing 5581 MB in total. One build-slot job, demand 9 MB, owing 3063 MB.
Fix
Every reading of the caller's own machine now does three things:
agent-runs.jsonin heavy's state folder, beside its peaks.ENOENT; a scope it cannot read is never ended.capacity_rule.learned_agent_mb. That is the same formula as the server'slearnedAgentMb:The new case file
packages/shared/src/capacity/agent-learning.json(11 cases) is checked by bothcapacity_rule.test.pyandslotObserve.test.ts, so the two sides cannot drift apart. An agent that does grow, for example one that runs a compiler inside its own scope, raises the learned cost on its next run.Before → after for today's readings. The after figure uses a learned writer cost of 512 MB: today's highest demand was 363 × 1.15, rounded up. If the peaks stay under 334 MB, it is 384 MB.
Kept as it was (the guards that protect T3). The severe and elevated rule and its hysteresis, the margin, the floor,
heavy.slice's caps, earlyoom, and the start cost on a fresh machine.Severe hold: not changed, on purpose. In 30.5 min there was not one raw severe sample, and in the CI step the budget alone would have refused 1132–3289 MB of free room against 3072 MB needed. A shorter hold would loosen a guard of the past overloads and give almost nothing back. If it shows up again once the budget is fixed, it gets its own change with vectors.
State question
Runs again.
Stops half-way.
os.replace, so the old file stays whole.agent-runs.json.*.tmpolder than 60 s is removed.flock, tried for 0.5 s) skips one reading's learning and never holds the answer.Old, empty or odd state.
Tests (failing on main)
capacity_rule.test.pyAgentLearning: every case ofagent-learning.json, plus bool and text runs. On main,learned_agent_mbdoes not exist.facts.test.pyAgentCosts, 8 tests throughheavy facts --freshon the fake machine:costMbof a new writer.On main a writer always costs 768.
slotObserve.test.ts: the server'slearnedAgentMbagrees on every case.The Python tests passed locally. The "red on main" run and the TS test could not run locally yet: the machine's own capacity gate (
t3-capacity 1536) stayed NOT OK for the whole session because of this same overcount. CI runs them.Follow-up (not in this PR)
A heavy ticket of kind
gradle(a project's build slot) is not a rule kind, so it costsjob-default, 3072 MB. That cost ignores the 20 learned gradle peaks (top 1420 MB, so a learned 1664 MB) and the ticket's own 2048 MB. That is about 1 GB more per build job. It is a rule-semantics question (#800: an unknown job is "never cheap"). It can be fixed by the project naming its slot--kind build, or by the rule learning unknown ticket kinds.Install plan (not installed; after review)
ci-releaseto carry the merge commit.bootstrap.sh --repo … --sha <ci-release sha>(README, "Install"). It replaces/usr/local/libexec/heavy/currentin one rename, so a rollback is the previous release.t3-capacity --long 1000still costs agents at 768 MB, because no runs are recorded yet;~/.local/state/heavy/agent-runs.jsonappears;heavy facts --freshanswers in under 1 s.learned.agent-writer.mbis between 384 and 768, and thatfreehas risen by about 2.5–4 GB at the same load.freegoes up whileavailabledrops under the margin, or if any earlyoom kill happens in heavy.slice.General vs project
General. The kit learns from whatever agent scopes the machine's T3 runs, and every number comes from
capacity-rule.json. There is no machine name, path or size in the code. The project-only part is the follow-up above: a project's build-slot kind name lives in that project's own config.🤖 Generated with Claude Code