Commit graph

829 commits

Author SHA1 Message Date
openhands
52ed8ef233 fix: red-team.sh sudo strips FORK_URL before docker compose sees it (#729)
red-team.sh called bare `sudo docker compose up/down` which applies
env_reset and drops FORK_URL before anvil-entrypoint.sh can read it.
Change both calls to `sudo -E` so the caller's FORK_URL override is
propagated to docker-compose and into the anvil container.

Update ENVIRONMENT.md to reflect that a plain `FORK_URL=... bash
red-team.sh` invocation now works correctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-14 08:30:49 +00:00
openhands
5b4e867c4b fix: address AI review feedback on ENVIRONMENT.md Network Contexts section
- Fix factual error: bootstrap deploys KRAIKEN protocol contracts and uses
  the existing V3 Factory; it does not re-deploy Uniswap V3 infrastructure
- Fix count/characterisation: intro now says "two network contexts" (dev
  Anvil + backtesting tools) and clarifies FitnessEvaluator uses revm
  in-process, not Anvil
- Fix sudo env-stripping hazard: replace bare `export FORK_URL` instruction
  with `FORK_URL=... sudo -E bash red-team.sh` so the variable is not
  silently dropped by sudo
- Nit: add --match-test testBatchEvaluate to the FitnessEvaluator example
  to match the test file's own documented usage

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-14 08:10:40 +00:00
openhands
f55eaae230 fix: ENVIRONMENT.md describes Anvil as Base Sepolia but backtesting scripts use Base mainnet addresses (#729)
- Clarify that the dev Anvil defaults to Base Sepolia but can be overridden
  with FORK_URL (confirmed from containers/anvil-entrypoint.sh)
- Add "Network Contexts" section distinguishing three distinct Anvil usages:
  1. Dev stack Anvil (docker-compose): Base Sepolia by default
  2. red-team.sh: requires FORK_URL=mainnet because it uses Base mainnet
     periphery addresses (V3_FACTORY, SwapRouter02, NPM)
  3. FitnessEvaluator.t.sol: independent mainnet fork via BASE_RPC_URL,
     unrelated to the docker-compose stack

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-14 07:28:27 +00:00
johba
319632e7ae Merge pull request 'fix: V3_FACTORY address lacks a source comment (#730)' (#740) from fix/issue-730 into master 2026-03-14 08:24:28 +01:00
openhands
bc2ed50451 fix: V3_FACTORY address lacks a source comment (#730)
Add inline Basescan URL comment identifying V3_FACTORY as the Uniswap V3
Factory on Base mainnet, consistent with the existing comment style used
for NPM_ADDR in both files.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-14 06:57:02 +00:00
johba
76e5d72c3d Merge pull request 'fix: calculateParams in OptimizerV3Push3 has no NatSpec after this PR (#735)' (#737) from fix/issue-735 into master 2026-03-14 07:48:45 +01:00
openhands
2c849ec456 fix: calculateParams in OptimizerV3Push3 has no NatSpec after this PR (#735)
Move the orphaned NatSpec block (originally for calculateParams) from
above getLiquidityParams to directly precede calculateParams, and give
getLiquidityParams only its own @inheritdoc block.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-14 06:20:37 +00:00
johba
7aedcc549e Merge pull request 'fix: push3-evolution description missing crossover operator (#659)' (#736) from fix/issue-659 into master 2026-03-14 07:07:10 +01:00
openhands
0a59de9b12 fix: push3-evolution description missing crossover operator (#659) 2026-03-14 05:46:48 +00:00
johba
fd3c569c82 Merge pull request 'fix: OptimizerV3 / OptimizerV3Push3 not explicitly typed against IOptimizer (#661)' (#734) from fix/issue-661 into master 2026-03-14 06:40:43 +01:00
openhands
6978d1399f fix: OptimizerV3 / OptimizerV3Push3 not explicitly typed against IOptimizer (#661)
- Optimizer: add `is IOptimizer` and mark getLiquidityParams() with
  `override`, making the interface conformance explicit at the base level.
  OptimizerV3 inherits it transitively via Optimizer.
- OptimizerV3Push3: add `is IOptimizer` and implement getLiquidityParams()
  that calls calculateParams() with zeroed inputs, returning bear-mode
  defaults (ci=0, anchorShare=0.3e18, anchorWidth=100, discoveryDepth=0.3e18).
  Behaviour is identical to the previous try/catch fallback used by
  LiquidityManager and the backtesting deployer.
- Update backtesting comments to reflect that getLiquidityParams() now
  exists on OptimizerV3Push3 (returns bear defaults via zeroed inputs).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-14 05:08:32 +00:00
johba
de93cb8997 Merge pull request 'fix: generation_N.jsonl candidate_id format mismatch vs filenames (#669)' (#733) from fix/issue-669 into master 2026-03-14 05:47:50 +01:00
openhands
b6c07b1d93 fix: generation_N.jsonl candidate_id format mismatch vs filenames (#669) 2026-03-14 04:27:59 +00:00
openhands
0aa819f168 fix: generation_N.jsonl candidate_id format mismatch vs filenames (#669) 2026-03-14 04:07:00 +00:00
johba
12253d6ee8 Merge pull request 'fix: batch-eval.sh header comment claims wrong candidate_id format (#668)' (#732) from fix/issue-668 into master 2026-03-14 04:57:06 +01:00
openhands
958b8cfaa0 fix: batch-eval.sh header comment claims wrong candidate_id format (#668) 2026-03-14 03:36:43 +00:00
johba
3660b68048 Merge pull request 'fix: Bare integer interpolation in agent-prompt heredoc at line 494 (#671)' (#731) from fix/issue-671 into master 2026-03-14 04:34:26 +01:00
openhands
44df166b73 fix: Bare integer interpolation in agent-prompt heredoc at line 494 (#671)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-14 03:07:55 +00:00
johba
0ea2840ed0 Merge pull request 'fix: NPM_ADDR may be Base Sepolia address in both files (#686)' (#727) from fix/issue-686 into master 2026-03-14 03:59:07 +01:00
openhands
729191d8ca ci: retrigger after infra failure 2026-03-14 02:32:22 +00:00
openhands
cbab4c36da fix: NPM_ADDR may be Base Sepolia address in both files (#686)
Replace 0x27F971cb582BF9E50F397e4d29a5C7A34f11faA2 (Base Sepolia
NonfungiblePositionManager) with the correct Base mainnet address
0x03a520B32c04bf3beef7BEb72E919cF822Ed34F3 in all four files that
referenced it, and add an inline comment citing the chain and source.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-14 02:22:51 +00:00
johba
93e3495252 Merge pull request 'fix: Other clamped params lack named constants (#703)' (#725) from fix/issue-703 into master 2026-03-14 03:07:43 +01:00
openhands
f3ddec9427 fix: Other clamped params lack named constants (#703)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-14 01:40:41 +00:00
johba
051d236eb2 Merge pull request 'fix: evo_run004_champion fitness inflated by token value (#670) (#704)' (#722) from fix/issue-704 into master 2026-03-14 02:28:07 +01:00
openhands
c42a1ca768 fix: evo_run004_champion fitness inflated by token value (#670) (#704)
- Add fitness_flags="token_value_inflation" to evo_run004_champion in
  manifest.jsonl so callers can detect the inflated value without
  discarding the entry entirely.
- Add effective_fitness() helper in evolve.sh pool admission (step 5)
  that returns 0 for any entry with a token_value_inflation flag,
  preventing inflated scores from biasing the top-100 evolved pool
  ranking or eviction decisions.
- Document in evolve.sh that raw fitness values are only comparable
  within the same evaluation run.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-14 01:08:13 +00:00
johba
d0eae8b261 Merge pull request 'fix: Issue template (push3-seed.yaml) doesn't enumerate manifest.jsonl fields (#705)' (#717) from fix/issue-705 into master 2026-03-14 01:57:24 +01:00
openhands
038c9ca7bc fix: Issue template (push3-seed.yaml) doesn't enumerate manifest.jsonl fields (#705) 2026-03-14 00:37:06 +00:00
openhands
6d23073e2f fix: Issue template (push3-seed.yaml) doesn't enumerate manifest.jsonl fields (#705) 2026-03-14 00:17:04 +00:00
johba
c5a7941259 Merge pull request 'fix: int(e.get('fitness', 0)) crashes on null-fitness manifest entries (#711)' (#715) from fix/issue-711 into master 2026-03-14 01:07:07 +01:00
openhands
b7d0b63ca1 fix: int(e.get('fitness', 0)) crashes on null-fitness manifest entries (#711) 2026-03-13 23:37:00 +00:00
johba
860b56f216 Merge pull request 'fix: evo_run004_champion fitness note references unresolved issue #670 (#685)' (#702) from fix/issue-685 into master
Reviewed-on: https://codeberg.org/johba/harb/pulls/702
Reviewed-by: review_bot <review_bot@noreply.codeberg.org>
2026-03-13 21:46:27 +01:00
openhands
23ca929f8a ci: retrigger after infra failure 2026-03-13 20:43:28 +00:00
johba
0c4cd23dfa fix: feat: Seed kindergarten — persistent top-100 candidate pool (#667) (#683)
Fixes #667

## Changes
## Summary

Implemented persistent top-100 candidate pool in `tools/push3-evolution/evolve.sh`:

### Changes

**`--run-id <N>` flag** (line 96)
- Optional integer; auto-increments from highest `run` field in `manifest.jsonl` when omitted
- Zero-padded to 3 digits (`001`, `002`, …)

**Seeds pool constants** (after path canonicalization)
- `SEEDS_DIR` → `$SCRIPT_DIR/seeds/`
- `POOL_MANIFEST` → `seeds/manifest.jsonl`
- `ADMISSION_THRESHOLD` → `6000000000000000000000` (6e21 wei)

**`--diverse-seeds` mode** now has two paths:
1. **Pool mode** (pool non-empty): random-shuffles the pool and takes up to `POPULATION` candidates — real evolved diversity, not parametric clones
2. **Fallback** (pool empty): original `seed-gen-cli` parametric variant behavior
- Both paths fall back to mutating `--seed` to fill any shortfall

**Step 5 — End-of-run admission** (after the diff step):
1. Scans all `generation_*.jsonl` in `OUTPUT_DIR` for candidates with `fitness ≥ 6e21`
2. Maps `candidate_id` (e.g. `gen2_c005`) back to `.push3` files in `WORK_DIR` (still exists since cleanup fires on EXIT)
3. Deduplicates by SHA-256 content hash against existing pool
4. Names new files `run{RUN_ID}_gen{N}_c{MMM}.push3`
5. Merges with existing pool, sorts by fitness descending, keeps top 100
6. Copies admitted files to `seeds/`, removes evicted evolved files (never hand-written), rewrites `manifest.jsonl`

Co-authored-by: openhands <openhands@all-hands.dev>
Reviewed-on: https://codeberg.org/johba/harb/pulls/683
Reviewed-by: review_bot <review_bot@noreply.codeberg.org>
2026-03-13 20:45:03 +01:00
johba
944e537d5b Merge pull request 'fix: LiquidityManager silently clamps anchorWidth to 100, undocumented upper bound (#689)' (#701) from fix/issue-689 into master 2026-03-13 20:36:03 +01:00
johba
e230a62e11 fix: feat: LLM seed — Fee Maximizer optimizer (#673) (#696)
Fixes #673

## Changes
Done. Here's a summary of what was implemented:

## Changes

**`tools/push3-evolution/seeds/llm_fee_maximizer.push3`** (new file)
A Push3 optimizer seed implementing the "every trade pays us" philosophy. It reads `percentageStaked` (slot 0) and `averageTaxRate` (slot 1), then branches on two thresholds:
- Staking threshold: 60% (bullish vs. neutral sentiment)
- Tax threshold: 10% of 1e18 (high vs. low swap volume)

Strategy matrix:
| | tax < 10% | tax ≥ 10% |
|---|---|---|
| **staked < 60%** | AS=0.70, AW=60, DD=0.50 | AS=0.80, AW=80, DD=0.60 |
| **staked ≥ 60%** | AS=0.90, AW=40, DD=0.80 | AS=0.95, AW=50, DD=0.90 |

CI is always 0. Anchor share is always ≥ 0.70e18 (capital stays in fee-earning zone). High staking shifts discovery depth up; high tax widens the anchor to capture more swap volume.

**`tools/push3-evolution/seeds/manifest.jsonl`** — new entry for `llm_fee_maximizer.push3` with `origin=llm`.

Transpiled successfully: 48-line Solidity function body, outputs correctly bound to `ci`, `anchorShare`, `anchorWidth`, `discoveryDepth`.

Co-authored-by: openhands <openhands@all-hands.dev>
Reviewed-on: https://codeberg.org/johba/harb/pulls/696
Reviewed-by: review_bot <review_bot@noreply.codeberg.org>
2026-03-13 19:56:39 +01:00
johba
382b7ec9b3 Merge pull request 'fix: feat: LLM seed — Momentum Follower optimizer (#674)' (#695) from fix/issue-674 into master 2026-03-13 19:39:50 +01:00
openhands
39c25fa330 fix: LiquidityManager silently clamps anchorWidth to 100, undocumented upper bound (#689)
- Extract magic number into named constant MAX_ANCHOR_WIDTH = 100 in LiquidityManager.sol
- Document effective ceiling in IOptimizer.sol natspec for anchorWidth return value
- Add testAnchorWidthAbove100IsClamped in LiquidityManager.t.sol asserting that
  optimizer-returned anchorWidth=150 is silently clamped to 100 (not rejected)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-13 18:14:37 +00:00
openhands
04dc44e76b ci: retrigger 2026-03-13 18:12:49 +00:00
openhands
f59361b047 state: LLM seed — Momentum Follower optimizer (#695) 2026-03-13 15:12:05 +00:00
openhands
24c4e94a6b fix: feat: LLM seed — Momentum Follower optimizer (#674)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-13 14:50:26 +00:00
johba
e484d4b03a feat: issue templates — bug, feature, push3-seed, refactor (#678)
Four templates for Codeberg issue creation:

- **Bug** — what, repro steps, affected files, acceptance criteria
- **Feature** — problem, solution, affected files (incl e2e tests), max 5 acceptance criteria
- **Push3 Seed** — strategy philosophy, behavior spec, pre-filled reference files + register mapping
- **Refactor** — what, approach, affected files, risks

All templates require affected files and acceptance criteria — the two things the dev-agent needs most. Push3 seed template has pre-filled deps (#667) and reference docs.

Gardener agent can enforce these on unstructured issues that come in without templates.

Co-authored-by: openhands <openhands@all-hands.dev>
Reviewed-on: https://codeberg.org/johba/harb/pulls/678
Reviewed-by: review_bot <review_bot@noreply.codeberg.org>
2026-03-13 13:02:50 +01:00
johba
3226aa58b6 Merge pull request 'feat: seed kindergarten — initial population with OG + first evolution champion' (#681) from chore/seed-kindergarten-initial into master
Reviewed-on: https://codeberg.org/johba/harb/pulls/681
2026-03-13 11:51:30 +01:00
johba
68c0769b5f Merge pull request 'fix: Stale JSDoc in navigateToStakePage refers to '/stake' not '/app/stake' (#509)' (#682) from fix/issue-509 into master
Reviewed-on: https://codeberg.org/johba/harb/pulls/682
2026-03-13 11:49:21 +01:00
johba
f22fe22f80 feat: STATE.md — running log of what harb is and does (#680)
Seeded with current reality. Dev-agent appends one line per merge (before merge, on the PR branch — goes through review). Planner will collapse into compact snapshot periodically.

Ref: dark-factory#5
Co-authored-by: openhands <openhands@all-hands.dev>
Reviewed-on: https://codeberg.org/johba/harb/pulls/680
2026-03-13 11:46:34 +01:00
openhands
a18512a644 fix: Stale JSDoc in navigateToStakePage refers to '/stake' not '/app/stake' (#509) 2026-03-13 10:37:14 +00:00
openhands
c7196aa2b0 feat: seed kindergarten — initial population with OG + first evolution champion
seeds/optimizer_v3.push3     — hand-written original (8.26e21)
seeds/evo_run004_champion.push3 — first evolution winner (2.31e24, gen 3)
seeds/manifest.jsonl         — fitness + provenance tracking

Note: champion fitness inflated by token value (#670). Strategy is
'always bull' — wide positions, max anchor share. Pending ETH-only
metric fix to validate.
2026-03-13 10:32:35 +00:00
johba
f1b64a448f Merge pull request 'fix: claude subprocess not killed on INT/TERM in cleanup trap (#530)' (#679) from fix/issue-530 into master 2026-03-13 11:26:02 +01:00
openhands
659044e2d1 fix: claude subprocess not killed on INT/TERM in cleanup trap (#530)
Track CLAUDE_PID before launching the claude subprocess so cleanup()
can kill it before reverting Anvil state. Running claude via `&` +
`wait` lets the trap fire immediately on INT/TERM, killing the
subprocess and preventing it from making calls against an
already-reverted chain.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-13 09:48:34 +00:00
johba
8b1d1ce146 Merge pull request 'fix: fix: Fitness metric should measure ETH only, not token value (#670)' (#677) from fix/issue-670 into master 2026-03-13 10:39:17 +01:00
openhands
defa1bfb6c fix: fix: Fitness metric should measure ETH only, not token value (#670)
Replace _positionEthValue() with _positionEthOnly() in FitnessEvaluator.t.sol.
The new function returns only the WETH component of each position (amount0 if
token0isWeth, else amount1), ignoring KRK token value entirely. This prevents
evolution from gaming the fitness metric by inflating KRK price through position
placement — the score now reflects actual ETH reserves only.

Also removes the now-unused FullMath import.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-13 09:11:31 +00:00