Skip to content

feat(improvement): train and serve a checkpoint through improve with a receipt - #1287

Merged
drewstone merged 5 commits into
mainfrom
feat/improve-training-mode
Sep 19, 2026
Merged

drewstone merged 5 commits into
mainfrom
feat/improve-training-mode

Conversation

@drewstone

@drewstone drewstone commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Status

Ready for review; all four required CI checks pass on final head 87694f15b5af2c669ffa844df63dc31485166127.

https://github.com/tangle-network/agent-runtime/actions/runs/35417723461

Passed: ci, agent-bench, official-optimizers, and packed-cohort. This includes the full test suite, lint, source/example typechecks, release-version checks, packed exports, edge execution, and generated-document freshness. Main 466a7a2237b0ed603159b4f02a96b90d628995be is integrated with no conflicts. The PR is non-draft.

The repository still requires one approving review. Review has been requested from the existing tangletools reviewer. The Codex review bot reports exhausted review quota; its unavailable review is not represented as a pass. No protections were bypassed.

Purpose and existing work

Train weights through improve(profile, { mode: 'training', ... }) or a bound harness's train(...), then return an exact checkpoint-backed candidate and portable training receipt. Training does not imply a held-out improvement or authorize promotion.

The reusable pieces already existed, but not this checkpoint-to-profile composition:

  • Published Interface 2.10.0 owns receipt schemas, artifact-addressed model identity, and ancestry validation (agent-sdk#341/examples: supervisor + coordinator MCP, workers on sandbox OR cli-bridge (one knob) #342).
  • Eval owns training export policy, evaluation, and promotion. Existing row payloads remain unchanged; Runtime inventories all exposed train/validation tasks and refuses cross-partition reuse.
  • Runtime already owns runAbortable and publishExclusiveDurableFile; this PR now reuses them instead of maintaining parallel cancellation and publication code.

The original dependency blocker is resolved. Peer floor, catalog, frozen lockfile, and exact packed cohort agree on Interface 2.10.0. Public imports use the existing root entrypoint, not an unsupported ./improvement package subpath.

Correctness repairs

  • Cancellation during input writes or checkpoint fsync cannot dispatch training or serving afterward.
  • Checkpoint mutation during serving or candidate validation is rejected before profile publication.
  • The receipt is durably published before the profile. Cancellation after committed publication does not retract the result. Storage failures attempt durable withdrawal and report cleanup failures explicitly.
  • Failure results retain the failed stage and uncertainty about external training/serving resources.
  • The command trainer pins its executable and declared inputs, supplies only an explicit public environment, bounds output, and cancels its POSIX process group.

Regression evidence

Re-ran the original PR implementation at ace732e0d7d118db899b2a819a513ea43f0d3912 with Interface 2.10.0 installed. Three new regressions fail there: training dispatch after cancellation, serving dispatch after cancellation, and accepting checkpoint mutation by the validator. Thus the dependency bump alone was insufficient.

The repaired product tree passes 95 focused tests across five files, including 29 training tests (19 original plus 10 new boundary regressions). Source typecheck and full lint also passed locally. Normal final-head CI above independently passes the complete repository checks.

Earlier clean preparation ran 4,226 tests successfully with six existing skips. Its temporary logging pipeline hid a Bench version-check failure behind tee; artifact inspection caught that. Bench's patch bump fixes it, and normal final-head CI now proves the release gate passes. The temporary preparation workflow was retired and is absent from this PR.

Release and boundaries

Prepare Runtime 0.242.0 and Bench 0.13.4, with changelogs, generated fixtures/API metadata, and packed-consumer import/type probes. Update this same PR by fast-forward; no force-push or mainline code loss.

No new optimizer, GPU scheduler, managed-training implementation, or Router deployment client. Command execution is trusted host code, not an OS sandbox. Managed adapters own remote cleanup and reconciliation. These checks prove execution/receipt contracts, not production model quality or a live GPU/Router deployment. No merge, publication, deployment, or paid model run performed.

Part of tangle-network/blueprint-agent#2473.

drewstone and others added 4 commits September 17, 2026 23:44
…a receipt

improve(profile, { mode: 'training' }) runs a controlled trainer command
or a managed adapter over a byte-verified dataset and parent profile,
hashes the checkpoint, verifies serving, writes the receipt, then
exposes the trained profile whose lineage the profile schema admits.

Part of tangle-network/blueprint-agent#2473
@drewstone
drewstone marked this pull request as ready for review September 19, 2026 03:06
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

tangletools
tangletools previously approved these changes Sep 19, 2026

@tangletools tangletools left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Auto-approved drewstone PR — 74b00acb

This PR was opened by the trusted drewstone account.
The full PR reviewer audit still runs separately and will publish findings if it detects issues.

This approval is provisional. It rests on the audit running. If the audit cannot run — for example the CLI bridge rejects it — this approval is dismissed rather than left standing, so an unrun check never reads as a passing one.

tangletools · auto-approval · reason: drewstone_author · 2026-09-19T03:06:49Z

@drewstone
drewstone merged commit 6a419ea into main Sep 19, 2026
4 checks passed
drewstone added a commit that referenced this pull request Sep 20, 2026
…olidation waves (#1304)

* refactor(improvement): one owner per rule after the training and consolidation waves

#1287 and #1300 landed hours apart and each added its own spelling of rules the
other already had. Collapse them without changing a public export or behavior:

- executionRef was checked three ways: a hand-rolled regex in the harness, a
  safeParse in method execution, and a bare schema parse in training that threw
  a ZodError instead of a ConfigError. candidate-validation now owns the rule.
- method-execution imported agent-interface's canonicalCandidateDigest under the
  alias interfaceCandidateDigest while also importing the runtime's own, which
  is the same sha256Bytes(canonicalCandidateBytes(value)). Use one name.
- copyProvenance was an alias for immutableCandidateValue.
- Both candidate admission points prepared the surface and shaped the validator
  input separately; one helper does it, and the redundant caller-side
  Object.freeze is gone because validateProfileCandidate already freezes.
  check() also deep-copied a profile the materializer had already detached.
- profile-surface had a private validateProfileCandidate(candidate, surface)
  with the same name as candidate-validation's exported
  validateProfileCandidate(validator, input) and a different job. It parses a
  materialized candidate, so it is now parseMaterializedProfile.
- improve.ts re-listed by hand every type improve-types and training export, so
  each new option type was a three-file edit. `export type *` from the owning
  modules keeps the identical surface.

The meta-harness case added by #1300 repeated an assertion the preceding case
already made; its new half is folded into that case.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* test(improvement): resolve the training output root the fixture hands training

runProfileTraining realpaths its output directory before syncing it, so on
macOS, where tmpdir() is a symlink to /private/var, the synced path never
equals the path the fixture passed and "publishes the durable receipt before
the profile through the shared writer" fails locally while CI stays green.
Resolve the fixture root once so both paths are the same string.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* chore(deps): take agent-profile-materialize 0.20.1 and agent-core 0.9.7

Both are the newest published versions and need no code change: Materialize
0.20.1 peers on agent-interface ^2.6.1, which the catalog already pins at
^2.10.0, and Core 0.9.7 is inside the range the catalog already declares.

agent-eval 0.183.0 is left out. agent-knowledge@17.0.2, the newest published,
peers on `@tangle-network/agent-eval` `>=0.182.0 <0.183.0`, so under this
workspace's strictPeerDependencies the install fails:

  [ERR_PNPM_PEER_DEP_ISSUES] Unmet peer dependencies
      ">=0.182.0 <0.183.0":
        @tangle-network/agent-knowledge@17.0.2

Runtime uses none of the /rl exports 0.183.0 changes; only bench/src/corpus.ts
imports a type from that entry point. The bump needs an agent-knowledge release
that admits 0.183, not a change here.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* test(candidate-execution): take Materialize 0.20's generated-file marker

agent-profile-materialize 0.20 puts a provenance comment on line 1 of every
context file it generates from prompt.instructions, so the next materialization
can prove which bytes it is about to replace. Files whose bytes are the
caller's own — an explicit profile resource, a system-prompt replacement — stay
verbatim, which is why only the agent-root AGENTS.md in these cases moves and
the workspace one does not.

Three expectations pinned the unmarked bytes. They now build the expected file
through tests/helpers/materialized-context.ts so the marker's shape is stated
once rather than in each test, matching how the subagent marker is already
spelled in candidate-execution-prepare.test.ts.

The checked-in improvement-proposal fixtures are regenerated: they carry both
runtimeVersion and the profile plan digest, and both moved.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* fix(deps): keep the pre-1.0 window range for agent-core

`pnpm update @tangle-network/agent-core --recursive` rewrote the catalog entry
from `>=0.9.6 <0.10.0` to `^0.9.7`, and the packed-consumer gate refused it:

  Error: packed consumer must load exactly one @tangle-network/agent-core@^0.9.7;
  found 1 installed path(s)
    - 0.9.7 at agent-core

That refusal is correct. `caretAdmits` in scripts/lib/packed-package-test.mjs
returns false for any caret below 1.0, because a pre-1.0 package makes no
promise that a minor is additive — the repo's shape for one is the
`>=X.Y.Z <X.Y+1.0` window `currentMinorPeerRange` builds. Restore the window.

The declared range already admitted 0.9.7, so only the lockfile moves and the
consumer-visible specifier is unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* docs(api): carry the 0.245.0 version into the generated catalog and prose

The docs gate regenerates docs/api and then refuses any curated page whose
stated version does not match package.json, so the version bump this PR pays
for the manifest change with left both stale.

`pnpm run docs:api` rewrites exactly one line of docs/api/primitive-catalog.md
— the version in its GENERATED banner. Nothing else in the generated reference
moves, which is the same result check:api-surface reports: replacing improve.ts's
hand-written re-export list with `export type *` changed no exported symbol.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants