agent-joule/crates/joule_coded
Repository files (latest commit first)
Filename Latest commit message Latest commit date
David Charlot cfe83c48a5 joule_core: Cache changes that span more than one file
joule-bench's `real` suite drew the cache's boundary exactly: every
single-file L4 close came back free on the repeat, and neither multi-file
close ever did — both paid the cloud in full again. Multi-file changes
are 53-66% of real commits, so the cascade's economics stopped at the
larger share of real work.

The open standard was never the obstacle. `Edit` has always carried its
own `path`, and SPEC §2 defines an op's `prior` as "the tree state this op
builds on". The single-file limit was ours, in three places:

- `ClaudeL4` snapshotted only `target`. For a fix with no single target
  it read an empty string before and after, concluded nothing changed,
  and returned `None` — so nothing was recorded even though the agent had
  fixed the files. That is why the benchmark graded those tasks as passed
  while the cascade cached nothing. It now snapshots the tree and records
  every changed file as one op.

- A target-less request was keyed on an empty path, giving every such
  request the same "prior". It is now keyed on the tree state.

- Replay ignored `edit.path` and spliced every edit into the one document
  in hand. A multi-file op reaching L0 would have written one file's bytes
  into another at the wrong offsets. It never happened only because no
  multi-file op had ever been recorded.

Replay onto the tree is refused unless the tree is the one the op was
recorded against, and every new file body is computed before any file is
written. A refusal costs one cloud call; a replay at the wrong offsets
would corrupt several files silently.

The tree state excludes `.joule`, the cascade's own ledger. It grows on
every close, so including it would have given each pass a different tree
and nothing could ever have hit the cache — the change would have looked
correct and never fired. Toolchain caches are excluded for the same
reason.

Proved end to end through the engine: a fix spanning two files goes to L4
once; with the tree reset, the identical request closes at L0, replays
both files, and the agent is not called again. Plus the two failure modes
that matter — a moved tree is refused with nothing written, and a
multi-file op is never spliced into a single document.

Also: the hardware energy test is now ignored by default. It read 124.9 J
and 150.4 J on an idle host and 0 J three times out of three, alone, at a
load average of 120 from unrelated builds. The doc comment previously
blamed parallel test load; the measurement says any heavy load.

Co-Authored-By: Claude Opus 5 <[email protected]>
2026-09-17 07:09:34 -04:00
..
launchd joule_coded: add fleet CLI subcommands and launchd packaging 2026-06-16 10:17:12 -04:00
src joule_core: Cache changes that span more than one file 2026-09-17 07:09:34 -04:00
tests joule_coded: Measure the tokens the metered path was reporting as zero 2026-09-07 06:33:46 -04:00
Cargo.toml fix(deps): re-point open-standards git dep to a REACHABLE rev — the pinned c4b536cf1f is on zero of 86 branches, so cargo cannot fetch it on any machine without it cached (clean-runner builds fail with 'failed to load source for jcp-bridge') 2026-08-26 09:09:21 -04:00