Detailed reference for src/, distilled from the former per-topic docs. Keep
this as the single source of truth for composition architecture, tuning
context, subsystem responsibilities, and design primitives.
- Engine Model
- Subsystem Map
- Conductor Pipeline
- Layer Isolation
- Boundaries
- Module Registry
- Key Systems
- Tuning Context
- Machine Anchors
- Calibration Anchors
- Diagnostics
Polychron generates MIDI through two polyrhythmic layers. Each layer is independent enough to retain its own timing and state, but coupled enough to create convergence, feedback, imitation, friction, and relief.
One beat has this shape:
conductor tick
-> compute density / tension / flicker / regime products
-> processBeat(layer)
-> playNotes()
-> crossLayerBeatRecord()
-> update trust, feedback, convergence, and diagnostics
The conductor decides global conditions. Cross-layer modules negotiate how the two layers interact. The play loop emits notes and records what actually happened.
src/utils/- validators, registries, lifecycle helpers, random helpers, L0 event bus, trust-system names, safe preboot utilities.src/conductor/- signal pipeline, profiles, regime detection, dampening, coupling management, hypermeta controllers, diagnostics.src/rhythm/- pattern generation, rhythm helpers, drum support, feedback listeners.src/time/-LayerManager, tempo feel, timing units, phrase/section time.src/composers/- composer families, voice management, motif logic, harmonic material.src/fx/- stutter variants, pan/balance, binaural/noise/color effects.src/crossLayer/- rhythm, harmony, dynamics, structure, trust, convergence, CIM, feedback, melodic/rhythmic emergence.src/writer/- CSV/MIDI output and finale writing.src/play/- beat loop, emission path, layer passes, feedback graph contract.
Directory-level README files carry local rules where the directory has its own cohesion boundary. The HME dir-intent index reads those README metadata blocks.
The conductor computes three core products every beat:
- Density product: how many notes to emit.
- Tension product: harmonic and structural intensity.
- Flicker product: micro-oscillation and surface instability.
Recorders tick through conductorIntelligence.runRecorders(ctx). They are
L1-only unless they are explicitly layer-safe. conductorSignalBridge is the
exception: it refreshes the read-only conductor snapshot used by cross-layer
modules.
Bias providers register density, tension, and flicker influences. Bias bounds
are locked by src/scripts/pipeline/bias-bounds-manifest.json and checked by the
hypermeta-jurisdiction validator.
L1 and L2 alternate through LM.activate().
On activation:
- Save outgoing layer globals into
LM.perLayerState. - Restore incoming layer globals.
- Advance the PRNG on L2 to avoid mirrored randomness.
Use LM.perLayerState or byLayer maps for mutable state that is written in a
per-layer pass and later read by both layers. Shared state is allowed only when
the value is truly global, such as system-wide pressure or total history.
- Cross-layer code reads conductor state through
conductorSignalBridge. - Cross-layer code does not register conductor biases directly.
- Cross-module event flow should prefer L0 channels over hidden direct calls.
systemDynamicsProfileris for conductor/coupling internals; cross-layer regime reads useregimeClassifieror the bridge.- Timing units (
spBeat,spDiv, etc.) are owned by timing setup functions. Do not mutate them ad hoc.
src/utils/moduleLifecycle.js is the stepping-stone dependency registry. A
manifest declares:
depsprovidesinit(deps)crossLayerScopesconductorScopesrecorderstateProvider
Boot order:
parseControls()moduleLifecycle.initializeAll()- bootstrap global assertion
- lifecycle resets through conductor and cross-layer managers
Legacy IIFEs and registerInitializer() still coexist during incremental
migration. New work should prefer explicit manifests when it reduces guard code
or hidden ordering.
Nineteen variants self-register through stutterVariants.register(). Selection
uses weighted random choice across regime, phase, articulation, harmonic
distance, coupling labels, entropy reversal, call-response history, phrase
position, hocket mode, and inverse-frequency balancing.
Emission has two gates:
- pattern gate from Euclidean/binary/hex/random/onset/rotate patterns
- probabilistic gate scaled by sustain, variant self-gate, density, tension, feedback, emission gap, convergence memory, and phrase ramp
Add a variant by creating src/fx/stutter/variants/<name>.js, registering it,
requiring it from variants/index.js, and adding regime weights.
coordinationIndependenceManager owns twelve dials from 0 independent to 1
coordinated:
restSync-rhythmComplementstutterContagion-stutterVariantsspectralComp-velocityInterferencefeedbackOsc-emergentDownbeatstutterChannels-coordinationharmonic-pitchCorrectionrhythm-phaseLockGravityrhythm-grooveConvergencedynamics-envelopeInterferencedynamics-articulationTexturestructure-trustNegotiationmotif-echoIdentity
Targets blend phase, regime, topology, section intent, entropy, density, canon mode, and effectiveness. CIM sets dials; each target module decides what its dial means.
Hypermeta controllers tune behavior that used to be hand-adjusted. Do not manual-tune constants a controller owns; change the controller logic.
Primary controllers:
- coupling target adaptation
- regime distribution equilibrium
- pipeline product centroid correction
- flicker range elasticity
- trust starvation nourishment
- coherent relaxation
- entropy PI control
- progressive dampening strength
- coupling gain budget
- meta-observation telemetry
- controller interaction watchdog
- coupling energy homeostasis
- axis energy equilibrator
- phase energy floor
- per-pair gain ceilings
- section-0 warmup ramps
hyperMetaManagerorchestration- correlation shuffler
The regime classifier also self-balances coherent share through
coherentThresholdScale.
Trust scores are EMA payoffs over named systems in trustSystems. Trust affects
negotiation, composer-family bias, starvation recovery, hotspot detection, and
module influence. Never hardcode trust names outside the canonical registry.
Closed-loop controllers register through closedLoopController.create() and
enroll in feedbackRegistry. Current loop families include coherence monitor,
pipeline balancers, coupling manager, regime damping, entropy regulation,
stutter variant feedback, correlation shuffling, emergent rhythm, rhythmic
contagion, and emergent melody.
feedbackOscillator creates cross-layer rhythmic round trips. Damping is 0.55;
energy can drive stutter probability, arc selection, and L0 feedback events.
Convergence systems turn L1/L2 agreement into landmarks:
convergenceDetectordetects aligned onsets.convergenceHarmonicTriggermay fire harmonic bursts on rare convergence.convergenceVelocitySurgeboosts impact after convergence.convergenceMemorylearns beat-position histograms.emergentDownbeatinfers perceived downbeats from convergence, cadence, velocity, phase lock, and regime shifts.
Metaprofiles bias regime distribution, coupling topology, trust shape, tension arc, density envelope, phase energy, composer families, conductor affinity, section arcs, layer variants, disabled controllers, and prescribed coupling pairs. They are profile-level fields, not one-off constants.
When two modules show strong negative correlation, do not average the conflict away. Identify the shared upstream and couple both sides to it with opposing responses. The tension becomes structure.
Bridge workflow:
- Detect candidates from
src/output/metrics/trace.jsonl. - Record candidates, confirmed bridges, and refutations in
tools/HME/runtime/metrics/hme-suspected-upstreams.json. - Add a falsifier before wiring a hypothesis.
- Re-check correlation after the bridge exists.
The invariant antagonism-registry-covers-observed-pairs depends on this
registry.
Use this section before changing feedback constants.
Critical constants and relationships:
coherenceMonitor.SMOOTHING = 0.55coherenceMonitor.BIAS_FLOOR = 0.60coherenceMonitor.BIAS_CEILING = 1.38entropyRegulator.SMOOTHING = 0.3- entropy target blends section arc and section intent
profileAdaptation.STREAK_TRIGGER = 6- negotiation
playScaleclamp is[0.4, 1.8] - negotiation
stutterScaleclamp is[0.25, 2.2] - trust weight clamp is
[0.4, 1.8] pipelineCouplingManager.GAIN_INIT = 0.16GAIN_MIN = 0.08GAIN_MAX = 0.60_AXIS_BUDGET = 0.24axisEnergyEquilibrator.CROSS_INHIBIT_WINDOW = 6phaseFloorController.RECOVERY_ATTRIBUTION_WINDOW = 12criticalityEngine.TARGET_RATE = 0.20feedbackOscillator.DAMPING = 0.55
Cross-constant invariants:
- Density ceiling chain:
1.38 * 1.8 = 2.48; avoid note-cramming. - Trust-weight clamp mirrors negotiation play clamp.
- Entropy has broad internal headroom, but negotiation clamps bound effect.
- Streak hints activate within a section at default tempo.
- Coherence monitor half-life stays responsive near two beats.
- Coupling tail gates scale by regime.
- Equilibrator tightening is throttled by homeostasis.
- Low-effectiveness pairs get lower gain ceilings.
- Coherent gate freezes tightening; coherent share must not monopolize a run.
- Regime hysteresis uses majority window, not consecutive-only streaks.
- Phase retraction never blocks genuine collapse recovery.
- Cross-adjuster inhibit prevents direction reversal, not same-direction continuation.
Some validators read this file for names that must stay visible.
Known active coupling labels:
- density-entropy
- density-flicker
- density-phase
- density-tension
- entropy-phase
- entropy-trust
- flicker-entropy
- flicker-phase
- tension-entropy
- tension-flicker
- tension-phase
Melodic coupling sections:
directionBias modulates dynamicRoleSwap swap probability. Ascending tendency
suppresses swaps to sustain build; descending tendency amplifies swaps.
directionBias modulates articulationComplement contrast. Ascending softens
contrast; descending sharpens it.
directionBias modulates voiceModulator chord velocity spread through the L0
emergent melody channel.
contourShape affects convergence velocity surge, groove transfer damping,
velocity interference, and stutter contagion. Rising arcs tend to build impact
and independence; falling arcs tend to release and converge.
- Base timing units are immutable outside timing setup.
- Coherent safety floor below 0.88 has been destructive.
- Low coherent share can still sound excellent; coherent share is not a quality proxy.
- Repeated density suppression requires a unified budget.
- Per-layer beat-processing state must be per-layer.
- L0 entries can persist across section resets; gate one-time reads.
- Conductor cannot write cross-layer state.
- Trust payoffs must align with regime behavior.
- If the same constant is adjusted three times, convert the issue into a self-regulating mechanism.
Composition runs write the useful truth to src/output/metrics/:
trace-summary.jsontrace.jsonlfingerprint-comparison.jsonruntime-snapshots.jsonadaptive-state.jsonfeedback_graph.jsonconductor-map.mdcrosslayer-map.md
Treat comments and prose as hypotheses. Treat metrics and verified listening verdicts as evidence.