Skip to content

Opening stage: input-agnostic Markov chain over named channels - #14

Merged
ALopezMoreno merged 11 commits into
mainfrom
claude/project-thread-n92qzp
Oct 16, 2026
Merged

ALopezMoreno merged 11 commits into
mainfrom
claude/project-thread-n92qzp

Conversation

@ALopezMoreno

@ALopezMoreno ALopezMoreno commented Oct 16, 2026 •

Copy link
Copy Markdown
Owner

Requested by Andres · project thread

Before: the core stopped at the closed bud. The viewer's open flower was a placeholder.

After: every flower opens from its own packed bud. automark --seed 11 --frames --open 24 writes the bud's growth stages followed by 24 opening frames (stage: "open", t from 0 to 1) in the shared flower JSON. The same plant seed and flower number always give the same opening, bit for bit. Outer layers open first. Each species sets the open shape per layer (Species.opening: angle, curl and a profile across layers). For peony, the inner layers stay incurved over the centre and the guard petals open out to the sepals.

The opening machinery knows nothing about what it evolves. Every latent is a named channel with a declared rule (fixed, mean-reverting drift, windowed growth toward a target, or derived from another channel with an optional power profile), wired to other channels by name. Adding a channel such as a colour gradient changes no code and no existing flower. A test checks exactly that.

How:

  • bloom::channels: the generic stepper. It handles flower, petal and point scope with 1 or 3 numbers each, and each (channel, petal) draws from its own random stream keyed by the channel's name.
  • bloom::program: the default wiring, kept as data, including the per-layer opening angle and curl from the species.
  • bloom::consume: the only code that reads channel meanings. It builds a pose per petal: curl kept by memory, a base fold by reflex, and a splay toward the layer's opening angle. Rows are widened, flattened and cupped, and the bud's crumples are re-applied. With neutral channels the pose is exactly the packed bud (tested).
  • bloom::relax + bloom::contact: FIRE relaxation toward the poses. FIRE state is carried between frames, so the flower keeps moving as it grows. Petals are densely sampled for contact. Contact pairs use per-petal Verlet refresh, and pairs that cannot touch are skipped while staying exact. The contact search uses flat grids. The gradient is exact and checked by finite differences.
  • bloom::export: appends the opening frames and channel declarations to the bud's JSON in the agreed format.
  • Tests (core/tests/bloom.rs, core/tests/channels.rs): determinism, sibling flowers differ, adding a channel changes nothing else, sizes never shrink, thickness stays capped, outer layers open first, peony guard petals open while its centre stays incurved, gradient check, and JSON continuity with the bud frames.

Speed: seed 11 runs from seed to open flower in about 29 s natively. That was about 150 s at first. Measurements are in core/PERFORMANCE.md. The wasm package doesn't expose the opening yet.

🤖 Generated with Claude Code

https://claude.ai/code/session_015RyRGSRwEuGkCyT3Szodbz

Adds stage 2 (`bloom`): each flower opens from its packed bud as a Markov
chain whose state is the petals' geometry plus named channels.

- channels: a generic stepper. Every channel follows one declared rule
  (fixed, mean-reverting drift, windowed growth toward gain*target+bias,
  optionally monotone); parameters are constants or other channels'
  names. Each (channel, petal) has its own name-keyed random stream, so
  adding a channel never changes existing flowers.
- program: the default channel wiring, as data, fed by the bud's latents.
- consume: turns channels into a pose per petal (re-integrated centre
  curve with memory and base reflex, widened/flattened/cupped rows, bud
  crumples re-applied), margin rest lengths and thinning.
- relax + contact: FIRE relaxation toward the poses with dense-sample
  petal contact; exact gradient.
- export: appends opening frames (stage "open", t in (0, 1]) and channel
  declarations to the bud's JSON.
- CLI: --open N.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015RyRGSRwEuGkCyT3Szodbz
@ALopezMoreno ALopezMoreno self-assigned this Oct 16, 2026
# Conflicts:
#	core/README.md
#	core/src/bin/automark.rs
- Petals now open toward a species setting, Species::open_angle (inner
  and outer layer, radians from straight up): the base hinge folds until
  the base-to-tip chord has turned `splay` of the way there. Peony opens
  its outer petals out to the sepals, just past horizontal. Not written
  into the bud JSON, so bud output and golden digests are unchanged.
- New generic channel rule `derived` (x = gain * from + bias), used to
  map each petal's layer_depth to its splay angle.
- Contact candidate skin 2t -> 0.5t: the candidate list was ~1M pairs and
  95% of opening time; 24 frames now take ~40 s instead of ~110 s.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015RyRGSRwEuGkCyT3Szodbz
…esn't help

Per-node masses from #17 made the opening slower and no more relaxed: it is
not stiffness-bound, and contact rebuilds dominate its time. Energy settles
well before 120 iterations, so the default is now 60 with dt_max 0.06
(seed 11: 41 s to 27 s, final overlap 0.74t to 0.68t). Measurements in
core/PERFORMANCE.md.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015RyRGSRwEuGkCyT3Szodbz
Species.opening replaces open_angle: angle and curl for the innermost and
outermost layers, with a profile (layer_depth^profile) for those between.
Peony's inner layers keep curving inward over the centre while its guard
petals open out to the sepals. Derived channels take an optional power so
the profile stays data.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015RyRGSRwEuGkCyT3Szodbz
Verlet refresh per petal, batched: a petal past half the skin triggers a
refresh of every petal past a quarter of it. Kept pairs remain exact, and
output is byte-identical. Seed 11 bud to open: 47 s to 42.5 s.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015RyRGSRwEuGkCyT3Szodbz
The flower keeps moving as it grows instead of settling from rest each
frame. Seed 11 on the retuned bud goes from 53 s to 39 s; every layer's
opening angle and incurve is unchanged, and petals move by about half a
thickness RMS (solver noise alone is about 0.4). Measurements in
core/PERFORMANCE.md.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015RyRGSRwEuGkCyT3Szodbz
Each pair keeps a lower bound on its distance at the anchors; energy skips
it while the bound minus the nodes' motion since still clears the contact
distance. Skin goes from 0.5 to 1.0 cap. Byte-identical output; seed 11
goes from 39 s to 35 s. Recipe from the Performance thread (#23).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015RyRGSRwEuGkCyT3Szodbz
Byte-identical on seeds 11 and 2027; seed 11 goes from 35 s to 29 s.
Patch from the Performance thread.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015RyRGSRwEuGkCyT3Szodbz
@ALopezMoreno
ALopezMoreno marked this pull request as ready for review October 16, 2026 12:38
@ALopezMoreno
ALopezMoreno merged commit dbacb02 into main Oct 16, 2026
6 checks passed
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.

2 participants