worktrunk icon indicating copy to clipboard operation
worktrunk copied to clipboard

Docs recipe request: reproducible numerical experiments and independent validation across agent worktrees

Open FABIO8495 opened this issue 3 weeks ago • 1 comments

Description

Would you consider a documentation recipe for reproducible numerical experiments across agent worktrees, with independent validation before integration?

We are evaluating Worktrunk for “Mega-Sena · Histórico e quadrantes”, a lottery statistics dashboard and covering-design research project. This is a prospective workflow question, not a reproduced Worktrunk bug. We have not yet integrated Worktrunk.

Our main goal is to test whether experimental indicators genuinely improve future coverage, without data leakage or fabricated execution results. We have no demonstrated predictive edge over independent uniform draws. Separately, we optimize six-number tickets to cover four-number subsets; those conditional combinatorial guarantees are independently enumerable.

Context and verified progress

  • Our experimental Z-core selects nine of twelve fixed five-number groups (45 of 60 numbers), using standardized historical delays. It needs frozen rules and chronological out-of-sample evaluation.
  • Covering-PDO experiments produced a 15-number covering with 129 tickets covering all 1,365 four-number subsets, versus our earlier 145-ticket reference. This is not a proof of minimum size.
  • A bounded 30-number search with 2,604 tickets covered 27,345 of 27,405 subsets, leaving 60 uncovered. We explicitly reject calling that a full guarantee.
  • Previous AI-generated proposals sometimes claimed execution or coverage that their code did not establish. We therefore want each result tied to code, inputs and actual logs.

Project context already submitted elsewhere:

  • ChatDev workflow question: https://github.com/OpenBMB/ChatDev/issues/714
  • MiroFish scope question: https://github.com/666ghj/MiroFish/discussions/969

Those questions have different scope; here we are asking specifically about worktree lifecycle and validation workflows, not lottery prediction.

Proposed Worktrunk workflow

One worktree per experiment, plus a separate validator workflow. Each run would record a unique run ID, source commit, dataset hash, seed, configuration, command, runtime, outputs and independent verification result. Failed experiments must remain auditable. Production code and shared mutable databases should not be touched by experiment agents.

We read the Tips & Patterns documentation on per-branch variables, task runners in hooks, progressive validation, per-worktree databases and agent handoffs. Those appear to provide much of the foundation.

The remaining questions are:

  1. What is the recommended lifecycle for durable experiment artifacts that must survive worktree removal? Should an external task runner archive them by run ID, with Worktrunk only storing references in per-branch state?
  2. For independent verification, is the recommended pattern a pre-merge hook invoking a pinned external validator, backed by required CI checks? We understand local hooks and worktrees alone are neither a security boundary nor protection against an agent modifying its own tests.
  3. How should run manifests identify the exact code tested when squash/rebase changes commit IDs? We want to prevent a successful check on one revision from being reported as evidence for another.
  4. Would a small documented recipe combining existing hooks, aliases and per-branch variables be appropriate, or is this orchestration better kept entirely in an external experiment runner?

Desired acceptance criteria: concurrent runs cannot overwrite each other's outputs; identical declared inputs are reproducible where the underlying algorithm permits; a failed validator blocks the normal integration path; and cleanup retains an inspectable execution record.

Pointers to existing examples are welcome. We are not requesting custom model development, winning numbers, or a statistical guarantee from Worktrunk.

Prepared with AI assistance and submitted on behalf of the project owner.

FABIO8495 avatar Nov 07 '26 00:11 FABIO8495

Keep the experiment runner outside Worktrunk, and let Worktrunk start and hook into it. Worktrunk owns worktree lifecycle and hook points. It has no store for durable artifacts and no trust boundary, so the run ledger, artifact archive and validator belong to your runner and CI. Below is how each of your questions maps onto what exists today.

1. Artifacts that survive removal. Treat the worktree as scratch space. The runner should write outputs to an external store keyed by run ID, not to a path inside the worktree. That keeps concurrent runs from overwriting each other, whatever happens to the worktree. pre-remove runs in the worktree before deletion and is documented for "saving test artifacts". A failing pre-remove aborts the removal, so an archive step there that exits non-zero on error keeps the worktree when archiving fails. wt config state vars works for references only (for example run-id=…). It is stored in the repository's local git config as worktrunk.state.<branch>.vars.<key>, so it is keyed by branch name and is not a durable record.

2. Independent verification. pre-merge runs after squash and rebase, and a failure aborts wt merge (pipeline). That makes it the right local gate, but it is a convenience, not an enforcement point. Project hooks are read from .config/wt.toml in the worktree the command runs in, which is the file an experiment agent can edit. Approvals do require re-approval when a command changes, but --yes skips the prompt. Anything meant to be independent should be a user hook in ~/.config/worktrunk/config.toml, which is outside the worktree, invoking a validator pinned outside the repo. Required CI checks on the integration branch should be the real gate, as you already suspected. Anyone can still run plain git merge and skip every Worktrunk hook.

3. Identifying the tested code across squash/rebase. In the default wt merge flow, squash and rebase happen before pre-merge, and the next step fast-forwards the target to that exact commit. A pre-merge validator that records git rev-parse HEAD (the hook's working directory is the worktree) therefore records the commit that lands. With --no-ff a merge commit is added on top, so record the tree too. git rev-parse HEAD^{tree} is a content hash that doesn't change when a squash rewrites commit IDs over the same content, so it's a good secondary key for linking a manifest to a revision. A check run on a pre-rebase commit is not evidence for the post-rebase tree when the target has moved. Compare tree IDs instead of trusting commit messages or branch names.

4. Recipe vs. external runner. Every piece above already exists: one worktree per run via wt switch --create <run-id> -x <runner>, a pre-merge validator, a pre-remove archive step, and vars for references. Your acceptance criteria (no overwrites, reproducibility, a blocked integration path, a retained record) all depend on the external store and CI, not on Worktrunk. Whether a generic "validated agent experiments" recipe belongs in Tips & Patterns is a maintainer call. I'm not opening a docs PR for it on my own.

These points come from the docs and source, not from an end-to-end run of this setup. One part I haven't checked is whether a pre-merge {{ commit }} template variable reflects the post-rebase commit. That's why the recipe above calls git rev-parse HEAD inside the hook.

worktrunk-bot avatar Nov 07 '26 00:11 worktrunk-bot