/pulp:timelinefrom pulp
Build, edit, validate, explain, render, import, or integrate Pulp timeline projects via CLI, MCP tools, or C++ SDK. Supports sequencers, arrangements, clips, tempo/meter maps, automation, takes, comps, freeze, capture-to-timeline, durable journals, DAWproject import, and Standard MIDI File import/export.
Ships in pulp. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
pulp_timeline_project_open, pulp_timeline_command_apply,
pulp_timeline_diff, pulp_timeline_undo, pulp_timeline_redo,
pulp_timeline_validate, pulp_timeline_explain,
pulp_timeline_render, pulp_timeline_export, and pulp_timeline_import.
Seven operations retain stateless pulp::tool-timeline entry points; diff,
undo, and redo are MCP-local operations backed by a live DocumentSession.
Three further read-projection tools —
pulp_timeline_view_outline, pulp_timeline_view_region, and
pulp_timeline_view_diff — sit alongside that catalog rather than inside
it, because the generated ten-tool manifest is pinned to the editing verbs
it describes (see "The view projection is published outside the generated
ten-tool catalog")./seq for the agent-guided inspect, validate, edit, explain, import, and
consent-gated export workflow. Use pulp seq and pulp render directly for
shell scripts, CI, and human-operated headless workflows. Prefer seq apply
with typed command envelopes over inventing one-off mutation flags.DocumentSession,
playback derivation in PlaybackProgramCompiler, realtime rendering behind
immutable programs and transport snapshots, and capture publication as
ordinary timeline commands. A ProgramCompileRequest must declare its exact
sample_rate explicitly and carry a CompiledTempoMap built at the same
normalized RationalRate; omission or disagreement is a synchronous invalid
request rather than an inferred default.Pulp::timeline-agent-view when an agent or remote client needs a
bounded, deterministic projection of one pinned DocumentView. AgentView
exposes a committed outline, cursor-paged clip regions, and a projection of
one adjacent commit's DirtySet without widening the dependency-minimal
Pulp::timeline model.Pulp::dawproject-import SDK target only when ingesting
DAWproject XML, and Pulp::smf-interop only when reading or writing Standard
MIDI Files; keep the dependency-minimal model on Pulp::timeline.<Audio duration>, so
it refuses a WAV the reader could only recover (inspect_wav(...)->truncated)
with "truncated WAV", before the duration comparison would report a
misleading mismatch.dev.pulp.sequencer/state.read@1
and dev.pulp.sequencer/state.edit@1 reach a live SequencerStateChannel in
a running instance and open nothing. See "Live sequencer control operations".Start with project_open or seq validate when the source is unfamiliar.
MCP project_open returns a bounded process-local session_id; use that
identifier for apply, diff, undo, and redo. A session keeps the real
DocumentSession undo stack and latest canonical DirtySet; session handles
expire when that server process exits and may expire after it reaches its
bounded session capacity, so preserve the returned project snapshot as the
durable handoff.
Apply edits as one expected-revision transaction, validate the result, use
explain to inspect playback lowering/PDC, then render only when an audio
artifact is needed. Never modify canonical project JSON text directly.
A render ends at the sequence end unless you ask for more. pulp render's
--tail-frames <n> and pulp_timeline_render's tail_frames render n frames
after the transport stops; both default to zero, which is the length every
render produced before the option existed. The default is the trap, not the
option: a program whose last event feeds a delay, reverb, or release envelope
renders with that tail cut at the last note, and nothing reports it — the file
is well-formed and the JSON says ok. If a bounce sounds like it ends abruptly,
suspect the missing tail before suspecting the DSP. The tail is charged against
the same in-memory render budget as the sequence and is refused with its own
message when it does not fit, so a tail is never silently truncated to make one.
command_apply carries both halves of that sentence as optional arguments,
and both are session-only — a stateless apply opens its own document and
keeps no retry record, so it refuses them rather than accepting and ignoring
them. expected_revision is the revision you last read; supply it and an
interleaved write is reported as stale_revision instead of being
overwritten. idempotency_key names the write itself, for the case where the
response was lost rather than the write: retrying under the same token
re-submits the identities the first attempt allocated, so a still-cached
result comes back verbatim and one that has aged out is refused as
already_applied_result_expired. That refusal means the write landed and the
result is no longer readable — it does not mean the write failed, and
re-issuing the commands under a fresh token would apply them twice.
A retry token is only honoured for the request it first named. Reusing one
with different commands, or with a different expected_revision, is refused
as transaction_id_collision, because the alternative is answering a
different request with an earlier result.
A running host's step grid is reachable through the same unified control platform as every other Pulp capability -- no bespoke sequencer verb, no new transport. Four typed operations are registered, each gated on its own capability and all bound to the host-main executor:
| Operation | Capability | Result | Profiles |
|---|---|---|---|
dev.pulp.sequencer/state.read@1 | sequencer.state.read | response | observe, develop |
dev.pulp.sequencer/state.edit@1 | sequencer.state.edit | receipt | develop |
dev.pulp.sequencer/transport.loop.read@1 | sequencer.transport.loop.read | response | observe, develop |
dev.pulp.sequencer/transport.loop.write@1 | sequencer.transport.loop.write | receipt | develop |
state.read copies the UI-side published snapshot and the seqlock playhead out
of the channel; pattern, include_snapshot, and include_playhead bound what
comes back, and the response carries epoch, engine_sequence, and
resync_required_epoch so a client can tell a fresh read from a stale one.
state.edit encodes exactly one typed step-grid command -- set-cell, clear
(scoped cell/lane/pattern/all), randomize-lane, set-pattern-length,
or switch-pattern -- and submits it to the single-producer command FIFO,
returning receipt_id, applied, and client_sequence. gesture_phase groups
a drag into one undoable gesture the way a parameter gesture does.
transport.loop.read@1 takes no parameters and returns the whole loop cell at
once -- enabled, start_tick, end_tick, playing, and the monotonic
sequence that stamps it. transport.loop.write@1 carries exactly one
action: set-range moves the boundaries, set-enabled toggles the loop and
requires an expected_sequence so a toggle raced against another writer is
refused rather than applied to a cell the caller never saw. Both actions require
an idempotency_key, and the receipt echoes the resulting cell alongside
receipt_id and applied, so a replayed key is answerable without a second
read.
Three things about these operations are not obvious from their schemas:
SequencerStateChannel
is strictly single-producer/single-consumer per side and exactly one UI-side
consumer may own the applied-echo queue. Called off the host main thread both
operations refuse with HostUnavailable rather than racing that cursor, and
the refused edit never reaches the FIFO. A background binding would compile
and pass every functional test.state.edit returns
ResourceExhausted with an after-backoff retry hint when the queue is full;
draining a slot makes the next submission succeed. Treat it as backpressure,
not as failure.expected_revision
concurrency token -- the epoch/engine_sequence pair is the staleness
instrument instead. Nothing here is persisted by pulp seq.Reaching them needs no live instance to discover: pulp control capabilities
prints the frozen registry offline, and --json emits the canonical
dev.pulp.control/registry@1 projection with both JSON Schema bodies. Listing
an operation is never a grant. To call one, use pulp control call --instance ID dev.pulp.sequencer/state.read@1 --params JSON; through MCP the registry derives
one tool per row -- pulp_control_sequencer_state_read,
pulp_control_sequencer_state_edit,
pulp_control_sequencer_transport_loop_read, and
pulp_control_sequencer_transport_loop_write -- so Forge Sequencer and
Forge Modular reach the grid and its loop with no bespoke surface. Grants and consent are
broker authority.
Adding a sequencer control operation means updating this section too:
tools/scripts/sequencer_control_skill_check.py derives every
dev.pulp.sequencer/ operation from the frozen registry and fails when one is
missing here or carries the wrong result kind.
Project, Sequence, Track, and Clip are immutable snapshots. Validate
once in their create() factories; reads must not repair, sort, or rebuild
indexes.Project owns its sample-rate-independent TempoMap and MeterMap. Every
path-copy rebuild, ID remap, journal comparison, and replay must preserve
both maps.UINT64_MAX; the latter is the
allocator's explicit exhausted sentinel. A project may store that sentinel
after owning UINT64_MAX - 1; otherwise next_item_id is strictly larger
than every owned ID. Allocation is monotonic and IDs are never reused.ItemLocation ownership is exactly (kind, parent_id), where parent_id is
the immediate owner. sequence_id, track_id, and clip_id are retained
ancestor-navigation caches and must not become additional ownership keys.
Add new item kinds by extending immediate_parent_id() rather than adding a
new owner-specific field. Legacy identity records without parent_id derive
it from their validated navigation fields during decode.(anchor, start, ItemId). Timeline and ID indexes are persistent AVL trees;
replace_clip() path-copies only search paths and shares untouched subtrees.Track::create, Project::create, and identity restoration must
validate and sort complete input sets, then bulk-build balanced persistent
AVL indexes with exactly one node per final entry. Do not feed bulk state
through the per-edit insertion path: its transient path copies turn initial
construction into allocator-heavy O(n log n) work. Ordinary edits still use
path-copy insertion/replacement so prior snapshots share untouched subtrees.DevicePlacement chain split into pre-fader and
post-fader stages. Each placement carries a format-neutral DeviceKind and
binding key, a typed event-to-event/event-to-audio/audio-to-audio slot,
bypass, canonical finite wet/dry bits, and an optional content-addressed
state reference. Pre-fader placements must precede post-fader placements;
post-fader slots are audio-to-audio, and adjacent signal domains must match.
Runtime instances, graph nodes, plugin formats, paths, inline state bytes,
and platform metadata do not belong in Timeline. InsertDevice,
RemoveDevice, MoveDevice, RetargetDevice, and SetDeviceState use exact
optimistic positions/values and participate in ordinary inverse undo/redo.
Removing a placement still referenced by automation or modulation fails
closed; it never silently cascades.docs/policies/event-stream-pdc.md: latency is samples, discovered once on
the control thread, and compensation shifts the scheduling window rather than
the event data. Event-to-event device execution is still open, so every
chain the runtime admits today resolves to a zero shift. Never put a latency
field in the Timeline document; the shift is a host fact and belongs to the
binding.ClipTimeAnchor::Musical follows tempo in ticks. Absolute uses
SamplePosition, an integer sample count, and a normalized RationalRate,
remaining fixed as tempo changes. Phase 1 rejects mixed anchors within one
Track until a context-owned tempo/rate projection can compare them safely.TimeConform is clip-level document intent: None is the default and keeps
legacy behavior, Resample requests pitch-coupled varispeed, and Stretch
requests tempo-preserving stretch. Non-default intent is valid only on a
musical MediaRef; absolute clips and every non-media content alternative
fail with InvalidTimeConform. Clip schema v2 persists the required lowercase
spelling; v1 loads as None, and v2→v1 refuses either non-default value.
Playback consumes Resample as pitch-coupled varispeed by mapping source
phase across the authored musical tick interval, including tempo ramps and
precise host beat mapping. None retains native-rate playback. Stretch
compiles a timeline-rate immutable artifact off the audio thread with exactly
the authored frame count, then plays it 1:1. A missing, over-capacity, or
length-mismatched Stretch artifact fails compilation; it never degrades to
native-rate playback.MidiContent is a flat POD array sorted by (start, ItemId). Note durations
are positive, pitch is MIDI 0-127, and channel is 0-15. Beside the notes it
carries MidiExpressionLane controller streams, each an owned identity with
points in (position, id) order and at most one lane per address. The document
side is complete — authoring, persistence, id remap, and copy all carry lanes —
but playback refuses to compile a lane-bearing clip rather than dropping the
lanes silently, so a document that authors one cannot be played until the note
program can carry controller values. See the playback skill for the two refusal
codes and which of them the renderer is allowed to delete.SequenceRef makes a musical clip a non-owning placement of another
sequence. Its source window begins at source_start; project construction
rejects missing targets, cycles, and nesting deeper than eight reference
edges. Sequence
identity remains project-owned, so removing a referenced sequence fails.
Playback expands references off the audio thread into immutable root-track
programs. Stage 1 accepts child note/audio clips and rejects child devices,
automation, takes, freeze, record-arm state, absolute clips, and non-neutral
reference gain/fades. A source window that cuts into a leaf clip's own
fade shortens that fade to the new clip edge rather than refusing — the
answer an unnested clip gives when it is dragged shorter — and a trim that
swallows a fade whole leaves none. A fade authored on the SequenceRef
placement itself is a different mechanism: flattening records that ramp as a
window of fade progress in owner-timeline ticks, and every leaf the window
reaches evaluates its own position inside it, so one ramp composes across the
leaves flattening cut it into and multiplies with each leaf's own fade. It
refuses only when a ramp actually reaches a leaf whose content no renderer
scales by clip gain, because dropping that ramp would be silently wrong. A complete
nested media clip preserves its TimeConform intent. A source window that
trims a Resample clip maps onto the matching sub-span of the source under
the same conform function, so it lowers; one that trims a Stretch clip
lowers as well, by keeping the artifact keyed to the authored tick range and
reading back only the frames of that render the window covers. Nothing
refuses a trimmed conforming leaf any more, so NestedConformedTrimUnsupported
is no longer raised. A nested child track
carrying a device chain fails with NestedDeviceChainUnsupported; one
automating its pan fails with NestedAutomationPanUnsupported, and one
automating its gain with NestedAutomationGainEventLeafUnsupported or
NestedAutomationGainMediaUnsupported according to whether the leaf that
curve reaches consumes clip gain. An
absolute-anchored leaf inside a nested sequence fails with
NestedAbsoluteChildUnsupported; each names its own cause rather than
sharing one umbrella code. Expansion
is bounded by ProgramCompileRequest::max_expanded_note_events and
ProgramCompileRequest::max_expanded_clips across materialized clips,
reference traversal, and reused track programs. The independent
audio_limits.max_clips ceiling counts compiled audio regions only.build_diverge_transaction() for
eager copy-on-edit: it emits a complete-ID CloneSequence followed by
SetClipSequenceRef. Pass two command IDs allocated from the session
WriterToken; the helper consumes item IDs from Project::next_item_id
before publication but never synthesizes writer-scoped IDs.ProgramCompileRequest::invalidation
from the shared context registry and exact CommitResult; submit()
builds and resolves the snapshot-scoped index against that same request. It
maps direct edits, child dirtiness, built-in MIDI groove reads, and nested
context readers to root tracks. The input pins that result's snapshot,
revision, exact predecessor snapshot, and an immutable registry copy. If the
predecessor is not the currently published project, sparse reuse is refused
and the cumulative target snapshot is rebuilt in full. A later registry
generation also forces a full compile without fabricating a document revision.AutomationCurve is a position-ordered immutable point sequence. Point IDs
and positions are unique within a curve; values are finite; curvature is in
[-1, 1]. Continuous segments use a monotonic quadratic blend, while Hold
segments retain the left value until the next point. value_at() is for
control-thread or compile-time queries, never the audio-thread scheduler.AutomationLane is an immutable value that binds one curve to a
format-neutral device-placement ItemId and opaque 32-bit parameter ID. Its
standalone factory validates only the value identities. Once attached, Track
owns lanes in canonical identity order, requires their target placements to
exist in its device chain, and permits only one lane per placement/parameter
pair. Lane and point IDs are Project identities owned by that Track; host
delivery remains a separate contract.Sequence owns two annotation lists: SequenceMarker (a named point) and
SequenceRegion (a named span). They are sequence-owned, not
project-owned: a Project holds many sequences, so a project-level list could
not say which timeline it annotates. Both are canonical-ticks values, carry an
optional packed 0xRRGGBBAA colour (a float colour type would live outside
this module's dependency floor, and exact bytes are what a document model
needs), share one identity space (a marker may not reuse a region's ItemId in
the same sequence), and are stored sorted — markers by (position, id), regions by
(position, duration, id). Regions may overlap and nest by design: named
sections contain sub-sections, so disjointness is deliberately not an
invariant. What Sequence::create does enforce is a positive region length, a
non-negative position, and containment inside the sequence's musical duration
when it declares one — an absolute-only sequence bounds nothing above.Sequence is built through create(), not aggregate init. Existing
partial overloads stay source-compatible; the full-fidelity path takes
SequenceInput, so new owned collections extend a named input rather than an
unbounded chain of positional overloads. Sequence remains pimpl'd behind
shared_ptr<const Data>.pulp.timeline.sequence and pulp.timeline.project schemas are both
versioned; the encoder must not hard-code either version.
sequence_schema_policy and project_schema_policy (mirroring
track_schema_policy) own the type name, current version, oldest readable
version, and the predicates — requires_annotations(version),
requires_scenes(version), and supports_session_start(version) — that
decode and preflight both consult. A
literal version in write_sequence, walk_sequence, walk_project, or
structural_registry_validation is how these drift apart — route every one
through the policy. pulp.timeline.project being versioned at all is easy to
miss: it sat at v1 long enough that several call sites reached for the
fixed-version data_for() helper instead of data_for_versions().[] in at the
canonical position and v2→v1 refuses when either is non-empty. The project's
session_start is optional, so its migration pair only moves the version
number — nothing is inserted — and the downgrade refuses only when the member
is actually present. Copy the shape that matches the field, not the nearest
migration.Project::Data is brace-initialized positionally in append_asset and
remove_asset. Appending a field to the struct there fails open: those
sites keep compiling and silently leave the new field default, dropping
document state on any asset edit. Those two sites now use designated
initializers; keep them that way, and put any new field where a stale
positional init cannot type-check.InsertMarker / RemoveMarker /
InsertRegion / RemoveRegion reduce through
transaction_marker_internal, which plans an ItemKind::Marker or
ItemKind::Region identity parented by the sequence (not a track), so
DirtyItem::owner_track is legitimately zero for these commands. They emit
inverse commands, so undo, redo, and journal replay restore the annotation and
its tombstone ownership exactly.sequence_scene_internal.cpp. Ordinary scene/slot edits
path-copy only affected AVL paths; unrelated Sequence edits must retain the
launcher store unchanged. Never replace this with scene-vector rebuilding or
validate deletions by scanning every scene.
InsertScene / RemoveScene and InsertSlot / RemoveSlot reduce through
transaction_scene_internal with exact inverse and tombstone ownership.InsertTrack / RemoveTrack reduce
through transaction_track_internal. plan_identity_deactivate validates
nothing — it emits one Deactivate per identity handed to it — so a missed
kind leaks an identity that stays active with its owner gone, and only
surfaces later as an unrelated IdentityNotAvailable, or as undo failing
because tombstone restore requires each id to exist and be inactive. The two
that get missed are the lane-parented pair, AutomationPoint and Take.
Never hand-write the list: visit_track_owned_identities() in
owned_identity_traversal.hpp is the single enumeration, and
visit_sequence_owned_identities() calls it, so the two cannot diverge.
has_same_owner compares only kind and parent while target_error compares
all four coordinates, so right ids with a wrong coordinate cache survive both
undo and redo and reject the next command two edits later — assert the
complete ItemLocation of every level, not just active.
RemoveTrack's inverse is InsertTrack{sequence_id, removed, following};
following is what restores authored position exactly instead of appending.InsertAutomationLane /
RemoveAutomationLane reduce through the shared transaction pipeline
(transaction_reduction_support + transaction_automation_internal),
validating the target sequence/track/placement, allocating lane and point
identities as owned Project identities, and emitting inverse commands so undo,
redo, and journal replay restore the lane and its tombstone ownership exactly.
Command equivalence compares lane payloads bit-exactly (float bits), so a
re-authored point differing only in a signed zero is not treated as equal.automation_curve.*, logical target binding belongs in automation_lane.*,
RT cursor/coalescing belongs in core/playback, and graph delivery belongs in
core/host.Take is one recorded region referencing a sealed media asset, anchored to
absolute sample time (its timeline length is the media frame count). A
TakeLane is an immutable, identity-ordered set of takes owned by a Track,
and a Track carries a record_armed document-intent flag the capture engine
reads but never mutates here. A take's parent is its lane — the second
lane-owned exception alongside AutomationPoint, so immediate_parent_id()
returns the supplied lane_id for ItemKind::Take and it is excluded from
coordinate-based parent recompute; a lane's parent is its Track. Take
identities must be disjoint from every other track-owned id, and a take whose
MediaRef asset is missing or out of range is rejected at Project::create,
exactly like a clip MediaRef.InsertTakeLane /
RemoveTakeLane / SetRecordArm reduce through the shared pipeline
(transaction_reduction_support + transaction_take_internal, dispatched like
automation), allocating lane+take identities as owned Project identities and
emitting inverse commands so undo/redo/journal-replay restore lane and
tombstone ownership exactly. InsertTakeLane re-validates each take's asset
reference against the project (the recorder emits CreateAsset first, so the
asset already exists when the take command reduces); SetRecordArm is an
optimistic expected/replacement gate on a non-identity flag. InsertTake /
RemoveTake edit one lane-owned take and preserve its tombstone parent.
SetActiveTakeLane optimistically selects one existing lane as the active
playlist/comp; zero selects the arrangement. Removing an active lane is
rejected, so clearing selection and removing the lane must be one explicit
transaction. SetTakeComp carries exact expected/replacement segment lists.
Each segment names a take and an in-bounds, normalized absolute sample range;
lane construction canonicalizes by timeline start and rejects missing takes,
mixed/wrong rates, empty or overlapping ranges. Removing a take selected by
the comp fails closed. Playback may flatten this source data into a derived
cache, but the cache is never document truth.TrackFreeze is an optional immutable selection of one sealed media
artifact plus its absolute placement/rate and a ContentHash fingerprint of
the exact render plan. It does not remove or mutate authored clips, takes,
automation, or device placements. Publish with one transaction ordered as
CreateAsset then SetTrackFreeze; the latter is an exact
expected/replacement gate dispatched through
transaction_track_state_internal. Undo clears the selection before
removing the artifact, asset removal fails while selected, and replay selects
the sealed artifact without re-rendering. Construction and mutation validate
that the asset exists, the media range is in bounds, and the artifact rate
matches. ID remap fixes the external artifact reference through
ExternalIdFixup; the render-plan hash is content metadata, not an owned
identity.Project::Data and Track::Data mutations rebuild by copy-and-modify
(auto next = *data_; next.field = ...; make_shared<const Data>(move(next))),
never positional brace-init — adding a field must not silently shift an
unrelated mutation site. create() factories build from input with designated
initializers.MediaRef ranges are checked locally for overflow and against their asset at
project construction.ContentHash is its durable identity. Locators are
optional late-resolution hints; representations have distinct hashes and
unique roles. Missing local media is valid document state.AudioLoopInfo is optional typed metadata on a sealed media asset: musical
length and meter, one-shot intent, MIDI root note, half-open frame markers,
manual or analyzer-suggested loop points, and canonical tags. Derive tempo
from musical length, asset frame count, and sample rate; do not persist a
duplicate BPM value that can disagree. This is descriptive authoring state,
not clip repetition, sample traversal, or a comp-selection model.data, type_name, and
integer version. All 64-bit IDs, positions, counts, durations, and rate
components are canonical decimal JSON strings; never encode them as JSON
numbers or floating point.tempo_map and meter_map
arrays. BPM is stored by exact IEEE-754 bits; older v1 snapshots without map
fields remain readable as 120 BPM and 4/4, then canonicalize on save.take_lanes array and
record_armed flag; v5 adds the required active_take_lane_id ("0" means
arrangement). Adjacent downgrades succeed only when the field being removed
is empty/default (v5→v4 requires zero selection; v4→v3 requires empty takes
and record_armed false), so
neither placement, automation, nor take identity can be discarded. Placements,
lanes, lane targets, take lanes, and takes remain separately versioned
structural envelopes. Take-lane schema v2 adds required comp_segments; its
v1 upgrade adds an empty comp, while v2→v1 succeeds only for an empty comp.
Track schema v6 adds optional freeze; v5→v6 is version-only because absence
means unfrozen, while v6→v5 succeeds only when freeze is absent. Never
silently discard a selected artifact during downgrade.time_conform. Its v1 upgrade inserts none;
its v2 downgrade succeeds only for none, and a v1 envelope that illegally
carries the field is rejected rather than normalized.loop_info. Its v2 to v1 downgrade succeeds
only when that field is absent, and a v1 envelope that illegally contains
the field is rejected rather than silently normalized.upgrades /
downgrades chains, but decode_command gates on exact version equality and
has no upgrade hook, and no command schema declares a migration edge. Raising
a command's version therefore rejects every envelope already written with
UnsupportedSchemaVersion. Declare the new field required = false in
schema_registry.cpp, read it with JsonValue::find in
serialize_command_decode.cpp, and make absence decode to what the payload
meant before the field existed (replace_note_content's modifier arrays and
set_clip_playback_properties's fade_shape both do this). Command decode
never validates a payload against schema->fields, so the registry entry is
documentation and generated-artifact input, not the gate — the decoder is.
Widening a command payload also means updating equivalent() (the
idempotency cache answers a repeated transaction id with its first result, so
a field it ignores lets a retry apply one payload and report another's
outcome) and retained_size() (it falls through to sizeof(T), so a field it
forgets is under-counted rather than refused).schema_release.hpp records exact shipped structural type/version sets,
including v0.736.0 (Track v1), v0.744.0 (Track v2), v0.748.0
(Track v3), and v0.750.0 (Track v4, before SequenceRef content and sequence
mutation commands).
serialize_project_for_release() applies the registry's
downgrade callbacks parent-first, then rewrites reachable child envelopes.
It fails closed when a removed feature is populated, an encountered
extension has no explicit target, or the target map names a type/version the
supplied registry cannot provide. Do not infer release compatibility from
the current schema version or preserve an opaque extension in an older
release export.next_item_id, which preserves the no-reuse boundary an older reader will
carry forward.SchemaRegistry explicitly with SchemaRegistryBuilder; there is no
global mutable registry. Registered content codecs are typed, noexcept, and
own no hidden ItemIds in Phase 1. Migration callbacks must return and verify
each complete intermediate envelope.has_opaque_objects; ID remapping must fail closed for any opaque subtree.serialize_encode.cpp /
serialize_project_decode.cpp you must also update the schema policy header
(current_version plus an <field>_introduced_version predicate),
schema_registry.cpp (declare the field, register BOTH migrations),
structural_registry_validation.cpp (its own expected-field list, or the
registry self-check fails), sequence_schema_migrations.{hpp,cpp} (the
vN_members list plus BOTH raw-splice migrations), and
schema_json_preflight.cpp. Then two
more that no gate points at: id_remap.cpp, or every copy/paste/import
quietly resets the field to its default, and snapshot_equivalence.cpp, or
the journal-replay checkpoint guard treats documents differing only in that
field as identical — and it is also the round-trip oracle, so a round-trip test
asserted through equivalent() passes even when the field was never persisted.
Grow the oracle in the same change, and prove a round-trip test fails with the
encode disabled before trusting it.DynamicsLane shipped with validation, interpolation, compile
resolution, and id-remap tests all green while the encoder, every decoder,
the preflight, and the schema registry knew nothing about it — a save
silently dropped an authored lane. The lane now rides sequence schema v8 as
dynamics_lane (between chord_scale_lane and groove), each event as
{"intensity_bits","interpolation","position"} with the intensity spelled
as its IEEE bit pattern the way an automation point spells value_bits, so
a reload is bit-exact rather than nearest-decimal. The v8→v7 downgrade
refuses a lane with any authored event, exactly as the scene, track-order,
and chord-detail downgrades refuse. When adding a lane like it, the
round-trip test is the one test the feature cannot ship without: assert the
reloaded lane == the authored one (float bits included) and that a re-save
reproduces the first save, then prove that test fails with the encode line
removed.track_order sorts before tracks (_ < s), which moved
tracks from member index 9 to 10 in the preflight walk. A wrong index
compiles and silently reads the neighbouring member. Re-derive every index
after inserting a field rather than appending to the end of the list.Sequence::create turns an empty track_order into identity order, so
the v5→v6 upgrade writes [] and every upgraded document loads correctly
without bloating. The downgrade is the asymmetric half — it must fail closed
with MigrationFailed when the value is not equivalent to the default, exactly
as the v5→v4 scenes downgrade refuses a non-empty scene list.test/fixtures/timeline/vN/ and
remain permanent compatibility inputs. Exercise unknown envelopes from those
files instead of rebuilding equivalent JSON inside a test so whitespace,
escapes, and member order cover the exact-byte re-save contract.vN directory names the pulp.timeline.sequence schema version its
fixtures were authored at (nested envelopes carry their own contemporaneous
versions), and every version in the migration chain must carry at least one
indexed document fixture — a schema bump that lands without one leaves a
version the corpus can never exercise. tools/scripts/timeline_fixture_coverage_check.py
enforces that: registered as the timeline-fixture-coverage ctest beside a
-selftest that proves it reddens on a synthetic gap, and as a job in
timeline-hardening.yml. Coverage reads corpus.index, not the tree — a
version dir whose fixtures are not indexed as documents does not count..json under test/fixtures/timeline/ is a project. The corpus
holds three shapes and nothing in the files distinguishes them: complete
pulp.timeline.project envelopes; single-entity fragments such as
v4/sequence-before-scenes.json, a bare pulp.timeline.sequence at v4 used to
drive registry.migrate() directly; and raw payloads such as
v1/unknown-content-envelope.json, which is never parsed as timeline JSON at
all — it is embedded as OpaqueContent to prove unknown bytes survive a round
trip. Decoding a fragment or a payload as a project fails InvalidSchema, and
that is correct refusal, not a broken fixture. test/fixtures/timeline/corpus.index
declares each entry's kind so the distinction is stated rather than guessed;
a new fixture must be listed there with its kind.pulp-fixture-runner validates every document entry against a sibling
<path>.expect manifest: schema envelope version, identity, structural counts
from peek_project_summary(), the interchange concept census, and the ordered
identities of every collection in the arrangement spine. Regenerate
manifests with pulp-fixture-runner --corpus test/fixtures/timeline --update;
generation is deterministic, so a regeneration that dirties the tree means a
document actually changed. The manifest is checked in both directions — an
entry declared but not observed fails too, because a document that lost an
entity would otherwise pass with every observed value still matching.test/fixtures/timeline/ is exhaustively indexed: every file must appear in
corpus.index, and a host-side sweep enforces it. Adding a fixture without an
index line reddens that sweep on a file your diff never mentions. Two
consequences worth knowing before you merge anything touching that tree. First,
a .expect manifest is excluded from the sweep, so an unindexed fixture with a
manifest is dead weight no gate can see. Second, and the one that actually bites:
any branch cut before the index existed cannot index its own fixture, so the
breakage appears only when the two branches meet on main — neither PR's CI can
see it alone. Check corpus.index covers the tree before merging a
fixture-adding branch.core/interchange/wasm/CMakeLists.txt is an Emscripten-only root that builds
the runner from the portable sources, and tools/ci/wasm-fixture-lane.sh
drives it (job Timeline fixture corpus (WASM) in web-plugins.yml). Two
things follow. The wasm root hand-lists its sources, because linking
pulp::timeline would drag in pulp::runtime's mbedTLS/HTTP — so a source
the desktop build gains is one the wasm build can silently miss; the root
fails its configure when core/interchange/src drifts from its list, but the
timeline list it borrows from PulpTimelineSources.cmake is shared and stays
honest on its own. And the lane deliberately runs the corpus a second time
against a broken copy and requires red, so a wasm build that validated
nothing cannot pass. Run it locally with
source ~/emsdk/emsdk_env.sh && tools/ci/wasm-fixture-lane.sh <build-dir> 6.ProjectSnapshotCounts field is asserted by the corpus only if it is
also emitted by collect_summary() in
core/interchange/tools/fixture_runner_main.cpp, which lists the counts one by
one and is not generated. Add the count and skip that list and every manifest
regenerates clean while the new entity goes uncounted in every fixture — the
corpus reports green on a document whose new structure it never looked at.collect_identity_orders() too — same file, same hazard as the counts list
above. The order.* manifest keys exist because counts plus idempotence are
jointly blind to a lost order: dropping a sequence's authored track_order
leaves counts.tracks intact, and an empty order re-serializes consistently,
so a round trip agrees with itself on the wrong answer. Two classes are worth
recording — authored orders (track_order, scenes, device_chain),
which exist only in the document, and value-derived orders (markers,
regions, clips), whose sort makes identity order a proxy for the positions
behind it. Leaf content below a track stays on counts by design.Sequence::track_order() presents the identity order of tracks()
for a sequence that never recorded one, so a manifest cannot distinguish "no
authored order" from "authored order equals identity order" — a fixture in
either state stays green when the order is dropped.
v6/sequence-track-order.json is deliberately built with a non-identity order
so the check can fail at all, and a case in test/test_fixture_runner_cli.cpp
asserts its two orders still differ. Do not "fix" a red order assertion by
rerunning --update; that regenerates from observed output without comparing
and bakes the regression in as the new baseline.pulp::interchange::census(), which lives in
core/interchange, not core/timeline. Anything reaching for it takes an
interchange dependency; that is on the portable floor, but it is a dependency
edge worth knowing before adding one. That call is also why the runner binary
is owned by core/interchange/CMakeLists.txt rather than by the test tree —
see the placement convention below.DecodeLimits. Keep input size, depth, value/member/array and
domain object limits enforced before growth. Duplicate object keys, malformed
UTF-8/surrogates, noncanonical wide integers, and non-normalized rates fail.peek_project_summary() for project browsers and admission checks that
need identity, name, root, or structural counts without constructing the
immutable document. Pass the same SchemaRegistry intended for load so
registered content is distinguished from opaque content. The peek still
scans the complete structural envelope and enforces every DecodeLimits
quota, including take lanes and takes, but does not resolve item or media
references.serialize_project() and deserialize_project() do not implement a ZIP or
package container. Asset locators describe possible package-relative bytes.
Use pulp::project-package to hash-verify, fence, and no-replace publish
content-addressed blobs before atomically replacing the stable package root's
validated project.json generation. Generic file and directory publication
is also no-replace, and unpublished staging remains unreachable; archive
formats and interchange policy stay in their format/tooling layers.MediaRef::asset_id is external to
Clip/Track/Sequence remaps and is translated by ExternalIdFixup; failure is
atomic and does not advance the caller's allocator. Preflight the complete
owned subtree for duplicate IDs before allocating; this includes parent IDs,
cross-track collisions, clips, note events, automation lanes, and automation
points. Lane and point IDs remap as owned identities, target placement IDs
remap as internal references, and opaque parameter IDs remain unchanged.pulp::runtime::Result; do not throw.pulp::timeline_agent_view::AgentView is created from one non-null
DocumentView and never follows a live DocumentSession. Every read therefore
requires the pin's exact revision; a caller that needs freshness must pin the
session again after a commit. outline() returns deterministic sequence,
track, and clip rows plus the complete ProjectSnapshotCounts census. Bounded
details are fail-closed commitments, not silent truncation: each omitted row
set carries a count and SHA-256, and the outline carries a commitment to the
canonical project snapshot.
region() pages clips in canonical (start, ItemId) order over one half-open
start-position window [start, end). A continuation cursor is valid only for
the exact version, revision, sequence, anchor, and original window that issued
it; changing either bound while retaining an in-range cursor key is still
InvalidCursor. The request limit must be non-zero and no larger than
Limits::max_page_items.
diff() projects an already-produced DirtySet into deterministic outline
changes. Its DirtyRevisionRange must be exactly one adjacent transition ending
at the pin (after != 0, before == after - 1); stale, non-adjacent, and
underflow-shaped ranges fail with InvalidProvenance. This adjacency check does
not authenticate the DirtySet: the public type has no session-issued origin
token, so callers must pair it with the exact CommitResult that produced it.
Do not present AgentView as an arbitrary since-revision diff or as a substitute
for session provenance.
AgentView reaches CLI and MCP through one shared encoder in
tools/timeline/src/timeline_agent_view.cpp, so pulp seq view and the
pulp_timeline_view_* tools emit byte-identical payloads by construction
rather than by review. A Forge consumer therefore has a single shape to pin,
and every payload carries a version field so it can pin it explicitly.
The MCP registration deliberately does not extend the generated catalog.
tools/mcp/CMakeLists.txt raises FATAL_ERROR unless the generated timeline
tool JSON holds exactly ten tools, and mcp_timeline_tools.cpp carries a
matching static_assert(bindings.size() == kTimelineMcpToolNames.size()).
Adding a read verb there would mean widening a cap that exists to keep the
editing catalog honest against its schema. So the view tools follow the
control_mcp_tools_json_fragment() precedent instead: a hand-written
descriptor fragment plus a separate binding array, both appended alongside the
generated ten. Because that fragment is a hand-built string, its
well-formedness is asserted rather than assumed — test_mcp_timeline_sessions.cpp
parses it and the whole tools/list catalog, since a stray comma there would
break tool discovery for every client at once.
Note the input asymmetry, which is intentional. The MCP tools take a
session_id, like every other MCP timeline tool, and read the live session's
current revision — that is the Forge-facing live read. The CLI takes a project
path, because a one-shot CLI invocation has no session. view diff on either
surface applies the commands to an in-memory copy and writes nothing, but that
copy is a real transaction, so the diff carries the same authority apply
does: a proposal writer is refused a removal by name rather than reporting a
change it would not admit.
ClipContent is guarded, and the two guards are not interchangeableClipContent decides what a clip is, so nearly every consumer dispatches on
it — and the default failure of a new alternative is silence, not an error. A
consumer written as an if/if constexpr chain keeps compiling and treats the
new kind as absent: a clip that renders nothing, an export manifest that reports
no loss while dropping data, a remap that carries stale ItemIds into a copy. No
test catches that, because nothing wrote a test for a kind that did not exist.
So the variant carries two guards, and which one a site gets is a judgement, not a style preference:
ClipContentCases when the site is genuinely dispatching —
the encoder, content equality, the journal's retained-size accounting, the
interchange census, the id-remap walk, and the playback compiler's content
classifier. The overload set has no generic fallback, so widening the variant
fails overload resolution right there.static_assert(kClipContentAlternativeCount == N) when the site cannot
be a visit but is only correct for today's alternatives — the decoder, which
dispatches on envelope type names rather than on the variant, and the two
asset referential-integrity scans, which reach assets through MediaRef
alone. Each message names the decision that site owes.A site that reads one alternative and is correct for every other one (a note
lookup, a MediaRef range check at construction) needs neither; do not add
noise there. And note that -fno-exceptions makes a bare std::get on a
mismatched alternative call std::terminate rather than throw, so a fallthrough
std::get is a process abort, not a caught error — that is why the encoder is a
visit and not a chain ending in std::get<OpaqueContent>.
core/midi to name themMidiContent carries notes, their deterministic modifiers, and the clip's
controller/expression lanes. It is tempting — and specs sometimes ask — to type
a lane's controller family against core/midi's UMP/MPE/RPN declarations so the
document model and the wire cannot disagree. core/timeline cannot include
pulp/midi/* at all. MODULE_FLOORS in
tools/scripts/timeline_engine_dependency_floor_check.py gives timeline the
floor {timeline, timebase, platform, runtime}; midi belongs to playback's
floor, one layer up. The check scans every include under core/timeline/ and
fails the build gate, so this is discovered late if it is discovered by
compiling.
The resolution is not a parallel enum either — it is to store the wire's own
numeric domain and name nothing. MidiLaneAddress is five raw bytes (UMP group,
channel, status nibble, controller bank, controller index) and a lane point's
value is the full 32-bit channel-voice width that 7-bit and 14-bit MIDI 1.0
values scale into. NoteEvent set this precedent already with bare pitch /
channel / velocity integers. Only bounds the wire itself imposes are
validated here (group, channel, and status are 4-bit fields); which addresses
carry meaning is a playback question and does not belong in the document model.
The per-stream layout is also load-bearing rather than incidental. Lanes are
sorted by (address, id) and each lane's points by (position, id), because
the question asked on every seek is "what did this one stream last say at or
before t" — two binary searches against that layout, versus a scan over every
event of every stream if lanes were flattened into one interleaved list.
Flattening them is the change that quietly makes seeking O(n).
id_remap.cpp enumerates what a clip, a track, and a sequence own only
through owned_identity_traversal.hpp. Both passes each level runs go through
it: owned_ids() collects for preflight's validity/duplicate check, and
allocate_owned_subtree() issues the destination identities. The same traversal
also feeds the identity index that Project::create and serialization build,
and the size check in the carried-id remap_ids(Sequence, carried_ids, fixups)
overload. So a kind added to the traversal reaches every one of those at once,
and the compiler is not what keeps them in step — not restating the list is.
Do not hand-write an owned-set walk at a call site, even when the level you are
adding to already has an obvious loop. Both ways of getting it wrong are quiet
and land far from the cause: an allocation walk that misses a kind returns a
copy without those objects, and a collection walk that misses one lets the new
identities skip validation entirely and then fails a later carried-id transfer
with InvalidIdentityTransition naming a size mismatch, which names no kind
at all.
Three cases pin this down, one per level, and each asserts a hand-counted
identity total — a distinctness or agreement check alone passes when a walk
silently emits fewer identities:
Copying a clip issues fresh identities for its lanes and points and
A sequence copy and its carried-id transfer agree on the whole owned set
(test_timeline_midi_content.cpp), and
A track copy issues a fresh identity for every kind a track owns
(test_timeline_take_comp.cpp), which carries every kind a track can own at
once because a per-kind case passes while a sibling kind goes missing.
One sharp edge remains: rebuild_*() dereferences table.find(id) for every id
it rewrites, assuming the allocation walk covered it. A kind dropped from the
traversal therefore reaches an empty-optional dereference — undefined behaviour,
not a checked error. In practice the garbage id it reads is refused by the next
create() and the remap fails, which is what the cases above observe, but the
diagnostic points at the rebuilt object and never at the walk.
Two more places a new ItemKind must land, neither of which the compiler will
point at: restore_identities() in model.cpp recomputes parent_id from
(sequence, track, clip) for every kind except an explicit
AutomationPoint / Take / Slot list, so any kind whose parent is a lane has to
join that list or every document carrying it fails to deserialize with
ModelRejected at /data/identities — an error that names no kind at all. And
item_kind_name() / the decode parser are two hand-maintained tables that must
gain the same spelling; the encoder's switch is exhaustive and will complain,
but the decoder's if-chain silently returns a failure for the unknown name.
Command-domain verbs of
core/timeline/schema/timeline_cli_verbs.json — 64 of them, catalogued in
full under Command catalog below with the wire type each one carries. A
hand-kept subset drifts from the model as soon as a command lands, so the
catalog is derived from that artifact and the timeline-command-doc-coverage
ctest fails when a declared command is missing from it. Automation commands
attach or tombstone complete Track-owned lanes; map commands carry exact
expected/replacement document values and participate in the same transaction,
journal, undo, and replay machinery. reduce_transaction() is pure: it
returns a new snapshot, exact canonical dirty set, and reverse-ordered inverse
commands.NoteTransformRegistry is the control-thread apply-time extension point for
pure (note span, canonical params JSON, seed) -> note array functions.
ApplyNoteTransform is a typed preparation request, not a durable Command:
preview() invokes extension code once, assigns fresh IDs only to outputs
whose ID is invalid, and lowers the result to one ReplaceNoteContent
transaction. The returned snapshot is speculative and the authoritative
session is unchanged. Commit by submitting the exact returned transaction;
a changed revision rejects it as stale instead of rerunning the transform.
The journal therefore contains only canonical note data, never a callback,
and undo/redo use the ordinary expected/replacement inverse while preserving
note identity tombstones. A transform may retain an input ID, but a foreign
or duplicate output ID is refused. Parameters must be a JSON object, are
parsed under a 1 MiB bound, and are canonicalized before callback invocation.
The expected plus output arrays share the durable command's five-million-note
quota.CreateAsset/RemoveAsset are the asset-table mirror pair (shaped like
InsertClip/RemoveClip). CreateAsset carries the whole MediaAsset by
value — the ContentHash is the sealed durable identity. The reducer plans
the ItemKind::Asset identity and appends the asset by reference to that hash
through Project::append_asset; replay never re-captures or re-hashes media
bytes, so the same checkpoint plus journal reproduce a byte-identical asset
table (the sealed-content contract). An invalid/empty ContentHash is
rejected before the asset can enter the document. RemoveAsset fails closed
while any clip's MediaRef still points at the asset, tombstones the identity
like a clip removal, and its inverse re-creates the sealed asset — so undo/redo
stays whole. Asset validation and identity-mutation application live in shared
model.cpp helpers so construction, sequence replacement, and asset mutation
enforce one sealed-identity and one identity-transition path.DocumentSession is the sole authoritative writer. Multiple control-thread
callers serialize through it; readers atomically pin immutable snapshots.
Every transaction declares its expected revision. Stale revisions and typed
value/owner preconditions reject the whole transaction without publication.UndoGroupId is the separate, explicit gesture-coalescing identity; different
writers never coalesce.WriterToken is a move-only, session-bound capability. Its ID allocators are
thread-safe and saturate permanently at exhaustion; never copy or synthesize
writer-local ID streams.Begin opens a
writer/group, only matching Update/End may follow, and other writers plus
undo/redo receive GestureState until the group closes.timeline_editor::EditGestureIdentityAllocator for construction-safe
continuous editor input. It owns one group and one opaque pending ticket,
binds tickets to the real session/writer provenance, lowers the issued phase
internally for both clip and validated note intents, and derives transitions only from its own call to
DocumentSession::submit(). Validation/lowering errors preserve the ticket;
an actual submission consumes it while a rejected transaction preserves the
confirmed state for a fresh-ID retry. Keep it on one control thread and route
every submission for its writer/group through it; concurrent direct
same-group submission is outside the contract. If a pending ticket is
abandoned without submission, discard that allocator instance.CommitResult with
DocumentSession::is_current_publication() and, on mismatch, asks the session
whether its opaque writer/group still owns the authoritative open gesture.
An intervening Update keeps the allocator Open so End/Cancel remains
possible; an intervening End/Cancel returns it to AwaitingBegin. Never scan
the journal, reconstruct this from numeric writer IDs, or accept
caller-declared acknowledgement state.checkpoint() truncates only a caller-confirmed durable prefix.JournalSink. It publishes a transaction only after
append_batch() reports the complete batch durable, and truncates a
checkpoint only after the sink installs its reconstructed snapshot. A sink
error is ambiguous, so it permanently poisons new durable writes for that
session; already-cached idempotent results retain their normal semantics.
Both callbacks run under the session writer lock and must not call
lock-taking APIs on the originating DocumentSession.FileJournal is the native crash-consistent sink. Its frames contain
canonical snapshots, a revision, and checksums; append success follows the
platform durability fence. Recovery truncates only a torn final frame and
fails closed on corruption earlier in the file. Checkpointing the current
revision uses a synced temporary sibling plus atomic rename, while
checkpointing an older prefix leaves newer durable frames intact. Restored
sessions attach only after an exact, read-only canonical-bytes/revision
validation; restoration never rewrites or truncates the recovered journal.
Symlink paths canonicalize to one lock identity; multiply linked journal
files are rejected because atomic checkpoint replacement cannot preserve
hard-link identity.reduce_transaction() never revives tombstones, and replay rejects a
checkpoint snapshot/revision mismatch or cross-entry writer-ID reuse.Every durable mutation the document model accepts, with the exact type string
a caller writes. The wire type is the operative half: the C++ spelling is what
an agent guesses from the model, while the wire type is what
pulp seq apply, the pulp_timeline_command_apply MCP tool, and
DocumentSession actually decode, and a type the manifest does not carry is
refused before it reaches a reducer.
Rows are derived from core/timeline/schema/timeline_cli_verbs.json and their
descriptions from the declarations in
core/timeline/include/pulp/timeline/command.hpp. Regenerate the artifact after
a manifest change, then add the row here — timeline-command-doc-coverage
fails a command that exists in the artifact and not in this table.
| Command | Wire type | What it does |
|---|---|---|
CloneSequence | pulp.timeline.command.clone_sequence | Clones a sequence using an explicit, complete owned-identity mapping. |
CreateAsset | pulp.timeline.command.create_asset | Adds one sealed recorded or imported media asset. |
InsertAutomationLane | pulp.timeline.command.insert_automation_lane | Inserts an automation lane into a track. |
InsertClip | pulp.timeline.command.insert_clip | Inserts an identity-bearing clip into a track. |
InsertDevice | pulp.timeline.command.insert_device | Inserts a typed device declaration into a track's authored chain. |
InsertMacro | pulp.timeline.command.insert_macro | Inserts a track-owned macro control. |
InsertMarker | pulp.timeline.command.insert_marker | Inserts a sequence-owned marker identity. |
InsertMidiExpressionLane | pulp.timeline.command.insert_midi_expression_lane | Inserts a controller/expression lane into a MIDI clip. |
InsertModulationRoute | pulp.timeline.command.insert_modulation_route | Inserts one authored source-to-parameter connection. |
InsertModulator | pulp.timeline.command.insert_modulator | Inserts a track-owned modulation source. |
InsertNotes | pulp.timeline.command.insert_notes | Inserts a set of identity-bearing notes into one MIDI clip. |
InsertRegion | pulp.timeline.command.insert_region | Inserts a sequence-owned region identity. |
InsertScene | pulp.timeline.command.insert_scene | Inserts a scene at an authored position in a sequence. |
InsertSequence | pulp.timeline.command.insert_sequence | Inserts a complete sequence and its owned identity subtree. |
InsertSlot | pulp.timeline.command.insert_slot | Inserts a slot at an authored position in a scene. |
InsertTake | pulp.timeline.command.insert_take | Inserts one take into an existing take lane. |
InsertTakeLane | pulp.timeline.command.insert_take_lane | Inserts one take lane and its owned take-identity subtree. |
InsertTrack | pulp.timeline.command.insert_track | Inserts a track and its complete owned identity subtree at an authored position. |
MoveClip | pulp.timeline.command.move_clip | Replaces a clip's time range under an exact optimistic-value gate. |
MoveDevice | pulp.timeline.command.move_device | Moves a device under an exact optimistic authored-position gate. |
MoveTrack | pulp.timeline.command.move_track | Moves a track in authored order under an exact optimistic-position gate. |
RemoveAsset | pulp.timeline.command.remove_asset | Removes a project-owned media asset by identity. |
RemoveAutomationLane | pulp.timeline.command.remove_automation_lane | Removes an automation lane by identity. |
RemoveClip | pulp.timeline.command.remove_clip | Removes a clip by its owning coordinates and identity. |
RemoveDevice | pulp.timeline.command.remove_device | Removes a device declaration by identity. |
RemoveMacro | pulp.timeline.command.remove_macro | Removes a track-owned macro control by identity. |
RemoveMarker | pulp.timeline.command.remove_marker | Removes a sequence-owned marker by identity. |
RemoveMidiExpressionLane | pulp.timeline.command.remove_midi_expression_lane | Removes a controller/expression lane from a MIDI clip by identity. |
RemoveModulationRoute | pulp.timeline.command.remove_modulation_route | Removes one authored connection by identity. |
RemoveModulator | pulp.timeline.command.remove_modulator | Removes a track-owned modulation source by identity. |
RemoveNotes | pulp.timeline.command.remove_notes | Removes a named set of notes under an exact optimistic-value gate. |
RemoveRegion | pulp.timeline.command.remove_region | Removes a sequence-owned region by identity. |
RemoveScene | pulp.timeline.command.remove_scene | Removes a scene and its owned slots by identity. |
RemoveSequence | pulp.timeline.command.remove_sequence | Removes a sequence and its owned identity subtree. |
RemoveSlot | pulp.timeline.command.remove_slot | Removes a slot from a scene by identity. |
RemoveTake | pulp.timeline.command.remove_take | Removes one take from an existing take lane. |
RemoveTakeLane | pulp.timeline.command.remove_take_lane | Removes a take lane and its owned take identities. |
RemoveTrack | pulp.timeline.command.remove_track | Removes a track and its complete owned identity subtree by identity. |
ReplaceNoteContent | pulp.timeline.command.replace_note_content | Replaces the complete note event set of one note clip. |
RetargetDevice | pulp.timeline.command.retarget_device | Replaces device kind, binding, slot, stage, bypass, and wet/dry atomically. |
SetActiveTakeLane | pulp.timeline.command.set_active_take_lane | Selects the arrangement or an existing take lane under an exact value gate. |
SetChordScaleLane | pulp.timeline.command.set_chord_scale_lane | Replaces a sequence's complete chord/scale lane under an exact value gate. |
SetClipPlaybackProperties | pulp.timeline.command.set_clip_playback_properties | Replaces clip-level gain and fade controls under an exact value gate. |
SetClipSequenceRef | pulp.timeline.command.set_clip_sequence_ref | Retargets a sequence-reference clip under an exact optimistic-value gate. |
SetDeviceState | pulp.timeline.command.set_device_state | Replaces the optional content-addressed opaque state reference. |
SetDynamicsLane | pulp.timeline.command.set_dynamics_lane | Replaces a sequence's complete dynamics lane under an exact value gate. |
SetGroove | pulp.timeline.command.set_groove | Replaces a sequence's complete groove under an exact value gate. |
SetMacro | pulp.timeline.command.set_macro | Replaces a macro control's declaration under an exact value gate. |
SetMacroValue | pulp.timeline.command.set_macro_value | Replaces only a macro's authored position under an exact value gate. |
SetMeterMap | pulp.timeline.command.set_meter_map | Replaces the complete project meter map under an exact value gate. |
SetMidiExpressionLanePoints | pulp.timeline.command.set_midi_expression_lane_points | Replaces one lane's authored points under an exact optimistic-value gate. |
SetModulationRoute | pulp.timeline.command.set_modulation_route | Replaces a route's source, target, depth, and bypass under an exact gate. |
SetModulator | pulp.timeline.command.set_modulator | Replaces a modulation source's declaration under an exact value gate. |
SetNoteEvents | pulp.timeline.command.set_note_events | Replaces the values of a named subset of one note clip's notes. |
SetNoteVelocity | pulp.timeline.command.set_note_velocity | Replaces one note velocity under an exact optimistic-value gate. |
SetProjectTuning | pulp.timeline.command.set_project_tuning | Replaces the project-wide tuning statement under an exact value gate. |
SetRecordArm | pulp.timeline.command.set_record_arm | Replaces record-arm document intent under an exact optimistic-value gate. |
SetRegion | pulp.timeline.command.set_region | Replaces one sequence-owned region under an exact value gate. |
SetTakeComp | pulp.timeline.command.set_take_comp | Replaces a take lane's canonical comp segments under an exact value gate. |
SetTempoMap | pulp.timeline.command.set_tempo_map | Replaces the complete project tempo map under an exact value gate. |
SetTrackFreeze | pulp.timeline.command.set_track_freeze | Publishes or clears a pre-rendered track artifact under an exact value gate. |
SetTrackMixer | pulp.timeline.command.set_track_mixer | Replaces track gain and pan under an exact optimistic-value gate. |
SetTrackName | pulp.timeline.command.set_track_name | Replaces a track's authored name under an exact optimistic-value gate. |
SetTrackTuning | pulp.timeline.command.set_track_tuning | Replaces one track's tuning override under an exact value gate. |
A track carries three modulation members, and they are inserted rather than
minted: InsertModulator
(pulp.timeline.command.insert_modulator), InsertMacro
(pulp.timeline.command.insert_macro), and InsertModulationRoute
(pulp.timeline.command.insert_modulation_route) each carry a complete
declaration bearing its own identity, so a source and the route that reads it
can be stated in one transaction instead of requiring a round trip to learn
what identity the model chose.
Removal is refused by the model rather than by the command. A source a route
still reads cannot leave: RemoveModulator
(pulp.timeline.command.remove_modulator) and RemoveMacro
(pulp.timeline.command.remove_macro) produce a track whose routes name a
member it does not hold, and the model refuses that track — so the failure
arrives as a rejected transaction, not as a document that quietly loses its
routing. RemoveModulationRoute
(pulp.timeline.command.remove_modulation_route) is the one modulation removal
nothing can refuse, because no other member reads a route.
The three Set forms pin identity. SetModulator
(pulp.timeline.command.set_modulator), SetMacro
(pulp.timeline.command.set_macro), and SetModulationRoute
(pulp.timeline.command.set_modulation_route) each require the addressed id,
expected.id, and replacement.id to be equal. An unpinned identity would let
a Modify swap one member for another — a removal and a creation wearing a
signature that declares neither — which hands a writer holding only Modify the
operation its capability mask refuses. SetModulationRoute gates the whole
route including enabled, because a bypassed route keeps its depth and target
so re-enabling restores what was there.
SetMacroValue (pulp.timeline.command.set_macro_value) is the narrow command
beside the broad one, the same shape SetNoteVelocity has beside
SetNoteEvents. It gates the normalized position alone, so a performer moving
a macro need not also supply its current name and a concurrent rename cannot
abort an edit that did not conflict with it. The float compares exactly rather
than within a tolerance, which is safe because the persisted spelling is the
IEEE-754 bit pattern. The overlap with SetMacro is deliberate: an edit that
rewrites the whole macro should gate on the whole macro.
InsertMidiExpressionLane (pulp.timeline.command.insert_midi_expression_lane)
delivers a lane whole — identity, MidiLaneAddress, and every authored point —
and MidiContent::create is the single authority on whether it may join the
clip, enforcing identity distinctness across notes, points, and lanes plus one
lane per address. RemoveMidiExpressionLane
(pulp.timeline.command.remove_midi_expression_lane) is separate because
abandoning a stream is the destructive intent a capability mask denies by
default: a writer that may edit a lane's values does not thereby gain the right
to discard it.
SetMidiExpressionLanePoints
(pulp.timeline.command.set_midi_expression_lane_points) changes what a stream
says, never which stream it is — the lane keeps both its identity and its
address, and the gate compares the full point array in canonical order.
Re-addressing a lane is a remove and an insert, because the two things a caller
means by it carry different authority.
InsertSequence (pulp.timeline.command.insert_sequence) and RemoveSequence
(pulp.timeline.command.remove_sequence) carry a complete sequence and its
owned identity subtree, the sequence-level pair beside InsertTrack /
RemoveTrack. CloneSequence is the third member and the one that needs an
explicit complete old-to-new id mapping.
SetRegion (pulp.timeline.command.set_region) completes the region trio
beside InsertRegion and RemoveRegion, and pins identity the way the
modulation Set commands do: expected.id and replacement.id must be equal
and must name a region the sequence owns. That pinning is what makes correcting
a region's SectionRole reachable for a writer profile that may modify but may
not remove.
MidiContent from its notes alone silently drops everything elseA MidiContent carries four things, not one: the note array, a sparse
NoteModifier companion array keyed by note identity (probability, every-Nth /
first / fill condition, ratchet count), the modifier_seed those probability
draws are derived from, and the clip's controller/expression lanes.
MidiContent::create is overloaded, and the shorter overloads default away
exactly the state a rebuild means to keep — they compile wherever the
four-argument overload does. So any path that rebuilds a clip's content by
handing the notes back to create erases authored document state with no error
and no diagnostic. Reach for the four-argument overload on every rebuild path.
Re-attachment is not uniform across the three companions, and making it uniform is its own bug:
note_id, and create rejects one that names a note the content does not
carry (MissingItem), so a blind pass-through converts an ordinary note
deletion into a hard model failure. Dropping the orphan is the right answer,
not an error: the modifier has no identity left to key to, and the same edit
already tombstones that note's identity.MidiExpressionLane keys on a
MidiLaneAddress — {group, channel, status, bank, index}, a channel-voice
stream address that references no note at all. Applying the surviving-note-id
filter to lanes as well is the reflexive "keep these consistent" edit, and
because no lane identity is ever a note identity it deletes the clip's
controller streams the moment an edit removes a note. Only a test that
authors lanes and shrinks the note set catches it.The rebuild paths that must each handle all three independently are
reduce_replace_note_content (transaction_note_internal.cpp), rebuild_clip
(id_remap.cpp, which additionally rewrites each note_id, lane id, and point
id through the remap table while leaving the address alone), and
finish_pending_leaf (core/playback/src/sequence_content_lowerer.cpp, where a
nested clip trimmed to its audible window filters modifiers to the retained
notes and refuses a clip with lanes outright — trimming has no defined answer
for a point that sits before the retained window yet still sounds inside it).
ReplaceNoteContent carries the modifiers as well as the notes, in optional
expected_modifiers / replacement_modifiers arrays. An authoring caller leaves
both empty and the reducer derives the surviving set from the clip; a
reducer-built inverse fills them in, which is what makes undo exact for an edit
that removes a modifier-bearing note — the dropped modifier is gone from the
content the inverse reduces against, so no filter over live state can recover it.
Lanes need no such treatment: they never leave the clip.
SetNoteEvents, InsertNotes, RemoveNotes, and ReplaceNoteContent rewrite
note content, and the difference is what each one gates on.
SetNoteEvents names a subset and cannot change the note set.
replacement[i] must name the same note as expected[i], so the reduction
allocates no identity and tombstones none. Reach for it for any edit that moves,
resizes, or retunes notes that already exist — a drag, a nudge, a velocity
sweep. It carries only the notes under the gesture, so its journal cost tracks
the selection rather than the clip.InsertNotes adds an identity-bearing subset. Every note identity must be
available. Its optional modifier payload may reference only notes inserted by
that same command; reducer-built undo uses it to restore complete authored
behavior after a removal.RemoveNotes removes a subset under an exact whole-note CAS. Each expected
note must match the current note with the same identity in every field. The
reducer captures attached modifiers in the generated InsertNotes inverse,
preserves controller lanes and the clip modifier seed, and tombstones only
the removed note identities.ReplaceNoteContent gates on the clip's entire current note array and is
the legacy whole-set replacement. Its expected is rejected unless it equals
the whole note set, so a one-note edit in a 10,000-note clip still costs
10,000 notes twice over.All four emit exactly one command per transaction regardless of how many notes
they touch. JournalLimits::max_commands is a count ceiling, so a per-note
command shape would exhaust it far sooner than the byte ceiling it would
relieve — which is why the subset commands are plural.
ReplaceNoteContent carries both note arrays, so DocumentSession charges one
edit retained_size(forward) + retained_size(inverse) — roughly 128 * N bytes
for an N-note clip against an 8 MiB UndoLimits default. That number is what
makes "a note editor cannot use this command" look obvious, and it is only true
for one shape: an open gesture group.
candidate.closed is set for Single, End and Cancel, and the eviction loop
in document_session.cpp advances only while the oldest group is closed. So:
Single-phase edit is charged once, closes on admission, and is
immediately evictable. Any number of commit-on-release edits succeed; the only
cost is undo depth (8 MiB / 128N groups). A single edit larger than the whole
budget — past roughly 65k notes at the default — is still refused outright,
because nothing can be evicted to make room for it.Begin/Update/.../End drag coalesces every step into one group that
stays open, and an open group is not evictable by anything. The charge
accumulates per frame and the gesture dies partway through with
ConflictCode::UndoFull — an in-progress drag that stops responding.So a piano roll that commits on release persists through this command today; one
that streams Update per frame needs granular note commands first. Test the
distinction as a pair — the same command at the same size against the same
budget, reaching opposite outcomes — since either case alone passes against a
session with no budget at all
(test_timeline_undo.cpp).
Sizing a session's real ceiling, note that the journal binds before the undo
stack: JournalLimits defaults to 16 MiB / 1024 transactions and has no
automatic eviction at all, only an explicit checkpoint(). A test that means
to exercise the undo budget must widen the journal explicitly or it will measure
JournalFull instead.
remap_ids is the copy / paste / import path: it rewrites every owned
ItemId and carries authored value state across untouched. rebuild_track
used to express that as a designated-initializer TrackInput{...} naming every
field. A designated initializer does not warn on an omitted member — unlike
positional aggregate init, which -Wmissing-field-initializers catches — so the
omitted field takes its default and the rebuild compiles clean. That is how a
track's authored mixer came to be reset to unity gain and centre pan on every
copy, paste, and import, with no error and no diagnostic.
The shape that fails closed is copy-and-mutate over the source's own input:
detail::track_input_of(track) (track_input_access.hpp, implemented beside
Track::Data in track.cpp) returns the complete authored TrackInput, and
the rewrite then assigns only the identity-bearing fields over it. A newly
authored value field is carried by construction; the one place that must stay
exhaustive sits next to the storage it reads. Enumerate identity, inherit value.
The same reasoning applies to any rebuild of a model struct from a source
value. SequenceInput and ProjectInput in id_remap.cpp are still
enumerated in full — audit them against model.hpp whenever either struct
grows, because nothing in the compiler will.
A Sequence owns a ChordScaleLane — an ordered set of ChordScaleEvents
(position, chord root + quality, scale root + mode) that other items read while
compiling. That cross-entity read is what the compile-context subscription
contract exists for, and the contract is what keeps the compiler's dirty set
exact:
CompileContextKind (compile_context.hpp) is the vocabulary; a renderer
declares the kinds it reads as a CompileContextSubscriptions set.CompileContextView, constructed with that declaration.
An undeclared kind reads as null. Do not add an accessor that bypasses the
declaration — the whole point is that a hook cannot depend on context the
compiler does not know to invalidate it for.core/playback (see the playback skill):
CompileInvalidationIndex bundles the nested dependency and context-reader
reverse indices, and resolve_dirty_tracks() turns a DirtySet into an
exact DirtyTrackSet.RegisteredContent value is valid only under its exact schema identity and
codec provenance. Build one immutable SchemaRegistry with built-ins plus
the application's content schemas, use it to create or load the payload, and
pass it when declaring the matching ContentRendererRegistration in
playback. The declaration and its hook are process-local capabilities, not
serialized Timeline state. An exact content value without an exact renderer
must fail compilation as UnresolvedRegisteredContent; it must not become
opaque silence.DirtyContext{sequence, kind} (which
names what changed) and a companion DirtyItem flagged DirtyFlags::Context
with no owning track (so an item-scanning consumer still sees the transaction
changed something rather than silently seeing an empty dirty set). A
trackless item that is not Context-flagged means a structural sequence edit.Adding a context kind is a data change here plus a reverse-index case in the compiler. It is never a reason to widen an invalidation.
The runnable cross-module contract is
examples/timeline-sdk-consumer/registered_chord_renderer.cpp. It registers the
chord-pattern schema and renderer, establishes a baseline compile, commits a
SetChordScaleLane, constructs CompileInvalidationInput from that exact
CommitResult, waits for the submission epoch, and proves that only the
context-reading generated track changes while an ordinary MIDI track reuses its
compiled owner. It also pins deterministic values and hash, unresolved and
bounded quota diagnostics, and weakest production aggregation. Update and run
that installed consumer whenever schema identity, registered content, context
dirty semantics, or playback hook declarations change.
The current compiler contract is notes-only, reset-state-only, and capped at
4096 fragment notes per clip. A nested SequenceRef that trims registered
content compiles: the hook generates over the authored clip and the compiler
windows the fragment to the retained span. Renderer production declarations live with the process;
ProgramWire refuses nondefault declarations instead of transporting a claim
without its trusted hook.
pulp.timeline.sequence touches two silent mirrorsBeyond the documented recipe (model → registry → version + both migrations → encode/decode → regenerate codegen → web source closure → tests), two files mirror the registry with no reference pointing at them from it, and both fail with an error that does not name them:
structural_registry_validation.cpp carries an exact expected field list,
order, kind, required-ness, and version range per structural type. Miss it and
serialize_project() returns a bare InvalidSchema before writing a byte.schema_json_preflight.cpp's walk_* functions re-validate the envelope
independently of the decoder, pinning [oldest_readable, current] versions per
type. Miss it and every v2 document fails to load even though the decoder
handles it. New optional/versioned array fields also need their own
governed_array count so a hostile document cannot allocate unbounded.The paired version policy header (sequence_schema_policy.hpp, alongside
track_schema_policy.hpp and asset_schema_policy.hpp) is what keeps those
three call sites agreeing about which version introduced which field. Add one
rather than spelling version numbers inline.
GrooveTemplate composes two transforms that behave differentlyA groove is a timebase swing warp plus a repeating offset table. The warp is
continuous and monotone (its contract and its round-trip bound live in the
timebase skill); the table is a per-step displacement and can reorder
material where adjacent steps lean opposite ways. Offsets are bounded to less
than a step, which limits that but does not forbid it — so assert monotonicity
of the swing half only, never of the composition.
The table is indexed by the authored position, not the swung one, so changing the swing setting never re-assigns notes to different steps. A test for that has to pick a position swing carries across a step boundary; most positions land in the same step under either order and a test using one of those passes whichever way the code is written.
Playback applies this context to built-in MIDI at compile time. The owning sequence's groove moves onset and release by one shared delta, scales velocity at the original onset, and is inherited unchanged by ratchets. Nested MIDI reads the child groove exactly once rather than composing it with the parent. A trimmed nested MIDI leaf with authored groove is currently refused because the source-window chase rule for displaced notes is intentionally undefined.
More than one stage moves a sequenced note, and the ordering is a contract:
docs/policies/event-stream-timing-transform.md.
Read it before adding anything that displaces a note. The split that matters:
authored groove and the tempo-map conversion are compile time and bake into
the immutable PlaybackProgram, so a displacement there survives save, bounce
and re-open. The humaniser device and delay compensation are render time and
never rewrite program data, so their displacement is a property of this playback
only. Each coordinate gets exactly one transform stage — one in ticks, one in
samples — which is what keeps two engines from becoming two competing global
timing engines.
Putting the humaniser in a chain at depth 0 is not the same as leaving it
out. The kernel is attack-only. It delays each attack by
minimum_timing_samples, which at depth 0 is the whole
kEventHumaniserWindowSamples (512) window and exactly cancels the compensated
early read — so attacks land tuple-identically, velocity included. A release is
forwarded unchanged (humanize.hpp), so nothing delays it back and it lands a
full window early. The net effect is that every note is 512 samples shorter
(10.7 ms at 48 kHz) merely because the device is present. Zero depth is a
deterministic control setting, not render identity; a caller wanting true bypass
must omit the device rather than zero its depths.
Two further deviations are declared in that contract rather than fixed, so do
not "repair" either without deciding to change what every existing render
sounds like: GrooveTemplate performs no joint order validation across adjacent
steps (the order-preserving kernel that does is unwired), and the humaniser
device keys its draw on a device-local frame counter rather than document
position — partition-invariant, but the same note draws differently depending on
where playback started and how many times it looped.
Ticks resolve far finer than frames. kTicksPerQuarter is 705'600, which at
120 BPM and 48 kHz is about 29.4 ticks to a frame, so a document can author a
placement trim that the frame grid cannot represent: the clip's tick window
genuinely narrows while the frames it selects do not move at all. Both readings
are correct at their own resolution, and nothing downstream is entitled to treat
the disagreement as a contradiction.
That matters whenever a document edit is checked against something measured in frames. Write the check as an implication in the direction that survives the gap -- a narrowed frame window implies a narrowed tick window, never the reverse -- and pick fixture numbers deliberately: every trim expressed as a fraction of a quarter note lands exactly on a frame boundary at that tempo and rate, so a table built from them is blind to the case entirely. The playback skill carries the render-side statement of the same fact.
The recipe says a downgrade must refuse rather than lie. The narrower trap is
deciding what "would lose data" means. migrate_sequence_v2_to_v1 refuses on a
non-empty chord lane, which is the whole of that type. A struct-shaped field
(the groove) has several members that a downgrade would drop, and only some of
them change what the document sounds like — a strength setting is inert while
the feel it attenuates is absent, and a name is never audible at all. Refuse on
every departure from the default value anyway. They are still data the user
authored, and a downgrade that silently discards them is the same failure as one
that silently retimes the music, just quieter.
Check the members field by field rather than comparing the object's bytes against the canonical default: a hand-written document may carry them in any order and still say exactly the same thing. Write one refusal test per member — a single "a populated groove refuses" case passes even when the predicate only looks at one field, which is how a weakened refusal gets through review.
ClipSchemaVersionPolicy (clip_schema_policy.hpp) is not bookkeeping — it is
the only thing that stops the readers of a clip envelope from disagreeing about
which version must carry which field. A field introduced at version N needs a
requires_<field>(version) predicate on that struct, plus a static_assert that
it is false at N-1 and true at N, and then every reader asks the predicate rather
than testing a literal:
schema_json_preflight.cpp — require the shape when the predicate holds,
reject the field's presence when it does not. Omitting the second half lets a
document claim a field at a version whose readers ignore it.serialize_project_decode.cpp — the same two-sided gate, producing the model
value.structural_registry_validation.cpp and the registry entry, whose required
flags must match each other exactly or the registry self-check fails.The downgrade refuses on anything but the field's default, for the reason in Downgrade refusals above: a shape a v(N-1) reader cannot express is not an annotation it can drop, it changes what the document sounds like.
Two fields introduced by the same schema version can land on opposite sides of the refusal rule, and the version number tells you nothing about which. Ask what an older reader that silently discarded the field would then believe:
C/E into C; the older reader states a different chord,
not a less annotated one.So one migration pair can refuse over one member and drop another in the same pass. Say which and why in the migration's own comment — the next reader cannot recover the reasoning from the code, and "it entered at the same version" is the wrong reason to make them match.
dataEvery earlier sequence migration inserts or erases one member of the top-level
data object, so the recipe reads as "find the neighbouring member's span and
splice". A member that lives on a chord event or inside a region
envelope's data is not reachable that way: each element needs its own edit,
and the count varies with the document.
apply_edits already takes a sorted span<RawEdit>, so a std::vector<RawEdit>
built by walking the array works — sort order is established inside
apply_edits, and overlapping or out-of-order edits fail closed there. Two
details bite:
begin/end bracket its braces, so an insert at the head goes at
begin + 1 and at the tail at end - 1. Check end > begin + 1 first, or an
empty object produces an inverted edit.JsonValue does not store —
only value spans. Locate it with source.find("\"<key>\"", <previous value>.end)
for a leading member, or source.find(',', <previous value>.end) for a
trailing one, and assert the offset lands before the value's span before
trusting it.Prove the pair round-trips by asserting upgrade(downgrade(x)) == x on the raw
bytes, not just that both calls succeeded.
These nested types are written with write_envelope(..., 1, ...) and appear in
the registry with current_version 1, which reads like an independent version
axis. It is not one: they only ever exist inside a sequence, and the sequence
version is what decides their shape. Gate a new member on
sequence_schema_policy, leave the nested envelope's version alone, and say so
in a comment — bumping it instead makes "sequence v7 with region v1" a
representable state that means nothing, and forces two numbers to be kept in
agreement forever.
A document's schema version decides exactly whether a member is present, so the
decoder's natural parameter is a bool requires_x. But some entity decoders are
shared with the command path (decode_region via insert_region,
decode_chord_scale_lane via set_chord_scale_lane), and a command payload is
authored input with no migration path of its own. Forcing the member there
breaks every hand-written and previously-journalled command; forbidding it drops
the data silently.
The shape that works is a tri-state (MemberPolicy { Forbidden, Required, Optional }): documents pass member_policy_for(requires_x), commands pass
Optional. When a version introduces several members together, Optional
must still reject a payload carrying only some of them — half the detail is
neither spelling, and filling in the rest invents data.
Fields land on entities, and entities have their own schemas. A tuning reference
at project scope plus an override at instrument scope is pulp.timeline.project
and pulp.timeline.track, each with its own policy header, both migration
directions, and its own registry entry — plus a shared nested type if the value
is a struct. Size the work by the entities touched, not by the number of fields.
Two consequences downstream:
ItemId. A
ContentHash needs no remapping, so a copy, paste, or import carries it with
no id_remap.cpp change; an identity reference would need one."type_name":"pulp.timeline.sequence","version":N appears in several suites,
in both raw-string and escaped-quote spellings — grep for both. Worse is the
migrate(domain, type, N, N - 1, saved, ...) idiom, where saved is a fresh
serialization: after a bump it starts from a version the payload no longer has
and fails for a reason unrelated to what the test is about. A refusal test
written that way passes for the wrong reason and stays green.Sequence grows through its named input, and each new owned field needs a version predicateSequence is pimpl'd behind shared_ptr<const Data> and built through
create(). Add full-fidelity owned state to SequenceInput; keep the existing
partial overloads source-compatible by having them construct the named input
with the new field's default. Do not extend the positional overload chain for
new durable state.
What does need care is sequence_schema_policy.hpp: each owned field gets its
own <field>_introduced_version plus a requires_<field>(version) predicate,
because the decoder and the preflight both have to know which document versions
carry it and which must not. Both sides are checked — a field present in a
version that predates it is as much a rejection as one missing from a version
that requires it — so reusing another field's predicate silently accepts
malformed documents on one of the two paths.
Sequence::Data successor by copying and naming, never positionallyEvery Sequence edit but create() produces its successor with
auto next = *data_;, assignment to the fields it changes, and
make_shared<const Data>(std::move(next)). This is not style. Data carries
fourteen fields, two of which — track_order and outgoing_sequence_refs —
are both std::vector<ItemId>, so a positional brace-initializer that
transposes them compiles silently and corrupts authored order. The positional
form also made every new field a mechanical edit at every construction site,
which is how a field gets dropped from one of them.
Mutate the copy in place (next.tracks.push_back(...)) rather than building a
new vector and assigning it, so a copy-and-mutate site costs the same single
deep copy the positional form did.
Sequence::move_track rewrites track_order and nothing else. Reaching for
erase_track + insert_track instead is wrong for a reorder because it:
tracks, track_id_index, and outgoing_sequence_refs — a whole
subtree rewrite for an edit that permutes one vector<ItemId>;Project::replace_sequence bumps
sequence_compile_structure_token() and invalidates a compiled program that
never observed display order;erase_track refuses to strand a
launcher slot that sources one of the track's clips, so drag-reordering a
track that carries a launcher clip would be rejected for a non-reason.The same shape applies to any future authored-order edit. Authored position is
encoded as "the item this one stands before", with an empty value meaning last —
one encoding serves InsertTrack::before_track_id, RemoveTrack's inverse, and
MoveTrack's optimistic gate, and swapping expected/replacement is the exact
inverse. A destination that names the moved item itself must be refused: the
item is lifted out before the destination is located, so the request would
otherwise land silently at the end.
Command retained_size() must account for heap the alternative ownsretained_size() has a chain of if constexpr arms and a sizeof(T) fallback.
A new alternative that owns a vector or a string falls into the fallback and
reports only its inline size, so the journal's memory accounting silently
under-counts and the bound it enforces stops meaning what it says. This does not
fail to compile and no test notices unless one is written for it.
Command alternative is checked in three places, all fail-closedCommand has no exhaustive-visitor guard of the ClipContentCases kind, so the
guards are assembled rather than inherent. Three of them fire, and it is worth
knowing which, because they fail in different ways and one used to not fire at
all:
command.cpp's equivalent() is an if constexpr chain ending in a generic
else that reads .track_id/.clip_id. A new alternative without those
fields is a compile error. Note this fires first and can mask the others:
an alternative that happens to carry those fields sails past it.transaction.cpp carries a static_assert that every alternative is claimed
by exactly one reduce dispatch branch, reading the lists in
transaction_dispatch_internal.hpp. Each family predicate (is_track_command
and friends) is derived from its list by std::visit rather than repeating it,
so the predicate and the claim cannot drift. Exactly-one, not at-least-one:
requiring one claim also catches an alternative two families both handle, which
branch order would otherwise resolve silently.retained_size() has a sizeof(T) fallback and so fails open — see the
section above.static_assert(!is_X_command_type<T>, …) in
the else of its std::visit, so a command claimed by the family with no arm
in the reducer is a compile error. This closes the rung below the second
guard: transaction.cpp proves which family claims an alternative, but the
arms inside that family were a second statement of the same list in a
different file, tied to it by nothing. Add a command to is_note_command_type,
forget the arm, and it used to compile, route, fall off the end and be
rejected at runtime as ModelInvariant — a command the document should have
applied.The reason the second guard exists: pulp-timeline builds -fno-exceptions, so
an alternative that reaches the end of the dispatch chain is not a
bad_variant_access and not a ConflictCode — it is a process abort() inside
a DAW. The chain's tail is now a rejection (ConflictCode::ModelInvariant)
rather than a bare std::get, so the abort is gone even if the assertion is
ever removed; verified by unwiring an alternative from its family, which aborts
with SIGABRT (exit 134) against the old bare std::get and returns a clean
ModelInvariant rejection against the current tail.
A count-based check is not enough here, and this is the trap. Asserting
variant_size_v<Command> against the sum of the family sizes passes when one
alternative is claimed twice and another not at all — the two errors cancel.
Verified: with MoveTrack claimed by both the scene and track families and
SetTrackName claimed by none, the claim total is still 39 and a count check
passes while the identity check fails. Compare identities, not counts.
Two lists that must agree is the shape worth recognising here. Every guard
above exists because one fact is written down twice — the claim list and the
arms, the variant and the type-name array, the variant and the envelope batch —
and nothing forces the copies to match. When you find a runtime rejection
guarding a pair of lists, the fix is to state the list once and let the compiler
check it, not to add a test that notices the drift later: a lint over two lists
can be skipped or can rot, while a static_assert in the same translation unit
cannot. A sweep comparing every family's claim list against its handled arms
reports zero discrepancies today, so the reducer guard above is regression
insurance rather than a fix for a live defect.
The distinction that decides whether this generalises: a branch guarding a relationship between two lists is enumerable, so it can be made a compile error. A branch guarding a value invariant — an overflow test, a range check — is not enumerable and stays review discipline. Do not go looking for a tool for the second kind.
Also extend the two coverage guards that pin the vocabulary, and note that neither is ordered the way you would guess:
test_timeline_schema_registry.cpp, sized by a
static_assert against variant_size_v<Command> and compared elementwise
against the registry, which sorts by type name — so the array is alphabetical
by schema type name, not variant order. Insert in the right alphabetical
slot; appending fails the elementwise compare.test_timeline_command_persistence.cpp. Its real
invariant is one decoded command per alternative — commands.size() == variant_size_v<Command> plus one holds_alternative assertion per index,
naming each alternative exactly once. It is not in variant order: the batch
carries InsertTake, RemoveTake, SetRecordArm at indices 14-16 where the
variant declares SetRecordArm, InsertTake, RemoveTake. That divergence is
long-standing and harmless — do not "fix" it, and do not renumber the batch to
match the variant. Appending a new envelope and asserting it at the final index
is correct.Every guard above is a compile error inside pulp-timeline. Two repo gates read
the header as text instead, fire much later, and fail in ways that do not name
the command you added.
Every public member needs its own /// brief. timeline_api_docs_check.py
counts a member as documented iff its Doxygen XML carries a non-empty
briefdescription or detaileddescription, so one brief above the struct
documents the struct and none of its fields. Symbols listed in
docs/doxygen/sequencer-api-contract-legacy-baseline.json are grandfathered, and
a symbol you just added is not in it. Do not resolve this by adding the new
symbol to that baseline: the baseline records contracts that predate the gate,
so widening it retires the gate instead of satisfying it. Copy the brief style
from the nearest structural analogue — SetDeviceState for a gated replace.
This one bites late, because api-contracts is not a required check. The PR
that adds an undocumented member merges green and main goes red on every commit
after it until somebody goes looking. SetDynamicsLane landed that way and left
the check red for days. Run tools/build-api-docs.sh --contract-only before
shipping a header change; it needs no build.
The sequencer-exposure ledger gate is purely path-based, and it lives inside
the required "Enforce version & skill sync" check. Any change to a path a
ledger row owns — a comment-only change included — must be recorded by a row that
is pending and materially changed. Material is exactly delivery_state,
claim_id, owned_paths, classification, evidence, surfaces
(_material_row in sequencer_exposure_check.py); editing a row's title does
nothing. There is no doc-only carve-out and no skip trailer, so shipyard pr
reports skill-sync and version-bump green and the PR still goes red.
Write a new row as its own file: docs/status/sequencer-exposure/rows/<row-id>.json,
containing just that row object, named for its id. The checker assembles the
ledger from docs/status/sequencer-exposure.json plus every file in that
directory, so both forms are one ledger and a row lives in exactly one of them.
The directory exists because the single document has one append point: two
branches that each append a row rewrite the same bytes and conflict with each
other even when each merges cleanly against main — which is also why the merge
queue cannot batch them. Two row files conflict with nothing. Edit a row that is
still in the single document in place; do not move it while amending it, because
a move plus an edit reads as neither.
Amending the existing pending row is the honest move when that row already claims
the path and its delivery is unfinished — validate_transition's contract is
omission prevention, its own wording is "an added or materially changed
pending row", and rows are routinely extended while pending. Evidence needles are
substrings re-verified against the file on every run, so a needle is a falsifiable
claim rather than a hash-mover, and prose is allowed: existing rows cite test
names. Adding a brand-new row to describe a comment fix would be the dishonest
shape, not the amendment.
Read the receipt's comparison_mode before trusting a local pass. The anchor
is base_tip (main's tip) when the base is already an ancestor of your head, and
falls back to merge_base when it is not. CI checks out a synthetic merge commit,
so CI is always base_tip; a branch that has not been rebased compares locally
against the older merge_base. The two disagree exactly when another PR has
materially changed your row on main since you branched — which can make a change
that is material locally non-material under CI.
ConflictCode is a wire ordinal, and adding one changes nothing outside the processtools/mcp/timeline_session_store.cpp emits static_cast<unsigned>(error.code)
verbatim as the numeric_code field of every transaction-failure envelope, so
the ordinals are observable to MCP clients. Nothing persists them —
core/timeline/native/ has zero ConflictCode hits, so the file journal does
not encode one — but the wire is enough. Verified by inserting one enumerator
above JournalDurability: the tree builds clean and JournalDurability silently
moves from 20 to 21. test_timeline_transactions.cpp pins the ordinals for this
reason; extend it when you append.conflict_code_name() is an exhaustive switch with no default:, so a new
code IS a compile-time event. It lives in
tools/timeline/src/writer_profile.cpp and is the single mapping both offline
boundaries emit through; adding an enumerator without a case fails the build on
-Wswitch rather than reaching clients under a generic string. Keep it that
way: a default: label would restore the silent fallthrough this replaced,
where every unhandled code arrived as "transaction_conflict" and a client had
no way to tell a capability denial from a journal failure. The trailing
return after the switch is for an out-of-range cast only, not a catch-all for
a forgotten enumerator. Every other consumer is still a two-way ==, so a
client that must distinguish a new cause needs its own update as well.CommandJournal::replay must relabel a reducer failure, not propagate it.
Replay re-reduces each journaled entry; returning the reducer's error unchanged
makes "this entry stopped reducing" byte-for-byte identical to "the model
refused your live edit" — same ModelInvariant, and same populated
model_error, which is the one field that otherwise discriminates the two.
Overwrite code with ReplayDivergence and keep item, related_item, and
model_error as the explanation. The general rule for any code path that
re-runs recorded work: name the frame that failed, not its callee.TransactionError::code defaults to Unspecified, and no producer may rely
on that default. Every site assigns code on the next statement or through a
code-taking helper (journal_error(), error(), reduction_error()). The
default exists only so that a forgotten assignment surfaces an obviously wrong
value instead of a plausible real cause; removing it entirely is worse, because
TransactionError error; would then leave a scalar indeterminate rather than
fail the build.view" is not whyEditIntent (core/timeline_editor/include/pulp/timeline_editor/edit_intent.hpp)
is device-neutral because the module cannot link view, so the header cannot name
a pointer type. True — but that fact does not choose where the type lives, and
reasoning from it is the trap. Check MODULE_FLOORS in
tools/scripts/timeline_engine_dependency_floor_check.py: the timeline_editor
row is a strict superset of the timeline row, and neither admits view. The
neutrality guarantee is identical at both addresses.
The argument that does discriminate runs the other way. core/timeline's floor
excludes timeline_editor, so with the verbs at the editor rung the gate rejects a
reducer, migration, or serializer that reaches for one — an edge it simply does not
have while the verbs are in the model, where every file may include them and no
gate can object. Draw/Erase/Move/Resize are hit-test verbs: Move and
Resize lower to the same command and are distinct only because a front-end
tells a clip body from its edge. A headless importer, a .pulpgraph loader, and a
plugin that wants only commands should not carry that distinction.
Both directions are pinned by --selftest, so neither can be relaxed silently.
timebase::next_grid_boundary(double, double) is a convenience for finite beat-domain
calculations, not an authoritative editor snapper. It has no meter input, and near the signed
tick endpoints one double ULP spans more than a thousand ticks. Converting a pointer's target
tick through it can therefore make two exact document positions collapse onto the same grid
answer.
Keep sequencer snapping in integer ticks. Use CompiledMeterMap::tick_to_bar() to obtain the
bar-local phase, generate the neighboring straight-grid candidates exactly, and only then pass
those candidates through swing_position(). Restarting at each bar prevents a time-signature
change from inheriting the previous signature's grid phase. Treat the authored bar end as a
candidate even when a custom interval leaves a partial final cell, and pin the nearest-tie
policy explicitly (the editor kernel chooses the later tick). Tests need both a meter change
whose new bar starts off the tick-zero grid and the signed endpoints; an all-4/4 fixture near
zero proves neither property.
Consequences worth knowing before you touch this:
pulp-timeline-editor is not header-only. It carries src/edit_intent.cpp
and is built -fno-exceptions -fno-rtti to match pulp-timeline. Those flags
are the target's own exception-free proof — the rung sits outside
pulp-test-timeline-no-exceptions, which covers only the portable timeline
list, so a TU added here that needs exceptions must fail at its own build.PulpTimelineSources.cmake's portable list directly and do not link the editor
rung. A browser build that wants to lower intents adds the rung; it does not add
the file back to the timeline manifest.GesturePhase belongs in core/timeline/command.hpp by the same test that
places the verbs: an undo group opens and closes on a bracket whether or not an
editor produced it, so it is transaction-level vocabulary, not a tool verb.EditIntentHost (= SequencerUiHostT<EditIntent>) is declared beside the
vocabulary. SequencerUiHostT's parameter exists so the playback seam and the
intent vocabulary can evolve apart; the alias is what keeps that parameter bound
to something real instead of only ever meeting a test stand-in.NoteEditIntent and
NoteEditIntentHost. Insert carries only replacement, erase carries only
expected, and move/resize/velocity carry both with one identity;
ValidatedNoteEditIntent::create rejects malformed or ambiguous shapes, and
NoteEditIntentHost accepts only that wrapper so invalid raw values cannot
cross the host seam. lower_note_edit_intent maps Insert to InsertNotes,
Erase to RemoveNotes, and move/resize/velocity to SetNoteEvents; never
regress these subset edits to the O(clip) ReplaceNoteContent command.The corollary for anyone extending this: a front-end resolves device differences
before it builds an intent, and hands the kernel only resolved scalars. Hit
tolerance is the worked example — HitMetrics lives in core/view and projects a
pointer type onto one number; the kernel takes the number and never learns what
produced it.
Two things not to do here:
GesturePhase. There are already three
(core/timeline/command.hpp, core/view/input_events.hpp,
core/state/sequencer_state_channel.hpp). Intents reuse the command.hpp one.
A second spelling of an existing concept is a defect, not a feature.lower_edit_intent and lower_track_edit_intent are pure and hold no Project,
so the only things they can check are properties of the gesture: identity
agreement between the transaction and command ids, the undo-group bracket a
non-Single phase requires, and ids that are structurally invalid. Everything
that needs the document — does the destination exist, is the track in this
sequence, does the optimistic gate still hold — belongs to the reducer.
Resist re-checking a model rule in the lowerer even when it looks cheap.
Sequence::move_track refuses a track named as its own destination, and says why
(the track is lifted out before the destination is located, so the request would
silently land at the end). Copying that check up into the lowerer would put the
same rule in two places that can drift, and the editing paths enforce the model's
copy. Pin where the refusal comes from with a test that lowers successfully and
asserts the session rejects it — otherwise a later reader adds the duplicate
"for a better error message."
The line worth drawing: a neighbour id that is present but structurally invalid
is a malformed gesture (the front-end never resolved it) and belongs in the
lowerer; an id that is well-formed but absent from the document is the
reducer's MissingItem. An std::optional destination left empty is neither —
it is a request for last position.
Clip::create re-validates the fades against the duration it is givenvalid_playback_properties rejects a fade longer than the clip's duration, and
Clip::create runs it, so rebuilding an existing clip with a shorter duration
fails with InvalidStructure even though every field was copied verbatim from a
clip the document already accepted. Trimming code that carries
playback_properties() across unchanged is the shape that hits this: the
failure names the structure, not the fade, so it reads like a malformed clip.
Clamp or zero the fade durations before create when the new duration is
smaller, and keep the ramp's real extent somewhere else if a caller still needs
it — a trimmed placement should enter its fade part way up, not restart it.
Disabling one disjunct of an if (A || B) guard and seeing the suite stay green
does not mean the guard is untested — it may mean your case only ever
exercised B. This bit here for real: a control rewritten as
if (false && (expected && !expected->valid()) || (replacement && !replacement->valid()))
parses as (false && A) || B, because && binds tighter than ||. The
replacement half still fired, the suite passed, and the control looked like a
false alarm. It was not — it had found a genuine gap, because the test asserted
only the destination neighbour and never the gate neighbour.
Two rules from it: delete the whole condition rather than negating one operand, so a surviving disjunct cannot answer for the one you meant to disable; and assert every disjunct separately, so the two halves fail at different lines. A control that passes is either a blind test or a malformed mutation, and the two are indistinguishable until you read the mutated source.
undo_gesture_budget
(core/timeline_editor/include/pulp/timeline_editor/gesture_budget.hpp) predicts
how many steps one open gesture can commit, and the obvious way to test it is a
self-controlling pair: size a session's budget for N steps, assert N commit and
the N+1th comes back ConflictCode::UndoFull. Same command, same size, same
budget, one variable, opposite outcomes — which is the right shape and is still
not enough.
A prediction that ignores its inputs and returns the literal N passes that pair
perfectly. The budget was built from N, so a hardcoded N sits exactly on the
boundary and both halves agree with it. Confirmed by mutation, not by argument:
replacing the whole computation with return 4 failed only the payload-growth
case and passed both halves of the pair.
The fix is to run the pair at two budget sizes (test_timeline_gesture_budget.cpp
uses 4 and 7). A constant then fails at whichever one it is not. Generally: a pair
pins a boundary, but only a boundary that moves pins the rule that places it —
so any threshold test that exercises one threshold is satisfiable by that
threshold as a literal. This applies well beyond this function: quota, limit and
capacity assertions across SessionLimits, JournalLimits and UndoLimits all
have the same shape.
Two further traps this function's tests exist to avoid:
JournalLimits wide, explicitly. It binds the same gesture
independently, defaults to 16 MiB / 1024 transactions, and has no automatic
eviction — only checkpoint(). Left at its defaults it is what a test aiming
at the undo budget ends up measuring, and JournalFull is not UndoFull.The registry entry, the migration pair, and the encode/decode sites are the obvious edits. Two more are hand-maintained, are not generated, and produce no compile error when they go stale:
core/timeline/src/structural_registry_validation.cpp holds a literal
ExpectedField[] per structural type plus its {current_version, oldest_readable_version} pair, and rejects a registry whose field list or
version does not match exactly. Miss it and serialize_project fails on a
document you just built in memory, with InvalidSchema /
UnsupportedSchemaVersion and no path — it reads like an encoder bug.core/timeline/src/schema_json_preflight.cpp gates the structural scan on a
literal version (content_type != "…" || version != 1). A version bump that
leaves it pinned sends every new document down the opaque-passthrough branch
and skips its validation entirely — a silent weakening, not a failure.Both must accept the whole readable range, not just the newest version: a v1 document is preflighted before migration runs, so the older shape has to pass too. Field lists in the validator are ordered, and the registry lists fields alphabetically, so a new field goes in its sorted position, not at the end.
schema_json_preflight.cpp has a second, sharper trap inside it. Each structural
scan declares its wanted members as a std::array of JsonSpanMember and then
indexes the results positionally, even though the lookup itself matches by
name. The arrays are kept alphabetical, so a new field inserted in sorted order
renumbers every index after it — and the result still compiles, still runs, and
quietly shape-checks the wrong member. Renumber the whole block by hand whenever
a field lands anywhere but the end.
A new Track-owned collection has a fourth hand-written table on top of those
two: valid_track_data_shape in core/timeline/src/track_schema_migrations.cpp.
Every track migration calls it, and it rejects any member it does not know, so a
field added to the registry and the encoder but not here makes the migration
fail rather than the encode — a different symptom from the same omission. The
order the four bite in is worth knowing, because only the first one you hit
tells you anything: structural_registry_validation.cpp fails the ENCODER at
path / with InvalidSchema on a document just built in memory, which reads
like an encoder bug and gives no hint that two more tables exist behind it.
An optional collection is far cheaper to add than a required one, and the
mixer v6→v7 pair is the pattern: write absence for the empty value, make the
upgrade a version stamp and nothing else, and make the downgrade refuse when
the member is present rather than dropping it. Nothing else in the migration
needs to move bytes.
validate_device_chain in core/timeline/src/track.cpp refuses the shapes a
chain cannot have at all — an identity transition between adjacent slot kinds,
and an out-of-order chain — at Track::create, before any host sees the
document. Graph admission in core/host/ refuses a second, narrower class:
a shape the model accepts but the resolver will not build, reported as a
TimelineGraphAdmissionCode.
The practical consequence is that a host-level refusal for a shape the model
already rejects is unreachable, and a test that tries to construct one
aborts rather than failing an assertion, because Track::create returns an
error Result and take() on it is a contract violation. Assert such a case
at the model layer, and keep a separate standalone-shape assertion for the host
refusal so narrowing the model's reach does not silently retire it.
The device catalog (tools/timeline/src/device_catalog.cpp) publishes what a
chain may name — binding key, domain, reported latency, stable parameter IDs,
plain ranges, defaults, units and behavior flags, and the two bounds admission
enforces. Built-in humaniser controls are direct runtime controls; the catalog
marks them non-automatable, non-rampable and non-modulatable, and Timeline
placement state does not persist them. The catalog lives in tools/timeline
rather than in either boundary because pulp-cli and pulp-mcp-core link
pulp::tool-timeline publicly but not pulp::host; putting the encoder anywhere
else widens a target's link surface to pull the host in.
Track::create moves its input partway through, so late validation reads an empty collectionTrack::create hands input.device_chain to a shared_ptr about two thirds of
the way down, and input.automation_lanes right after it. Validation added
below that point must read *device_chain, not input.device_chain — the
moved-from vector is empty, every reference check against it fails, and the
result is a model that rejects every document that uses the feature while the
unit tests for the collection itself still pass. The compiler says nothing: a
moved-from std::vector is a valid object.
Version-gating a field in the preflight also changes the error a caller sees.
The preflight runs before the decoder, so an omitted version-gated field is
rejected there as InvalidSchema (that is require_shape's default
missing_code), and the decoder's own MissingField branch for the same field
becomes unreachable through deserialize_project. Keep the decoder check — it
still guards the decoder driven directly — but assert InvalidSchema in a
document-level test, or the test is describing a layer it is not exercising.
A bump also invalidates any test that pins a "future version" sentinel —
test_timeline_persistence_limits.cpp asserts that a known built-in type name at
an unknown version stays opaque and quota-terminal, using a literal version one
past the current one. When the schema catches up to that literal the case still
passes trivially while no longer testing the opaque path at all, so raise the
sentinel in the same change.
The SchemaRegistry is the single generative source for the timeline's agent
surfaces (JS facade, TypeScript definitions, MCP tool definitions, CLI verbs):
they are generated from it, never hand-maintained, so they cannot drift.
emit_schema_manifest() (schema_codegen.cpp) projects the built-in registry
into one canonical JSON-Schema document — a lossless view of every type's
domain, current version, fields, required set, and migration edges — round-
tripped through canonicalize_json so the same registry always yields
byte-identical output regardless of registration order.
The committed artifact is core/timeline/schema/timeline_schema.json; the
pulp-timeline-schema-emit binary regenerates it. After any change to
register_builtin_timeline_schemas (adding/removing a type, a field, a version,
or a migration edge), regenerate the artifact or the drift gate fails:
python3 tools/scripts/schema_drift_check.py --update # regenerate
python3 tools/scripts/schema_drift_check.py # verify in sync
schema_drift_check.py is the standalone gate logic (regenerate → byte-diff →
nonzero on drift), wired as the timeline-schema-drift ctest; the
timeline-schema-drift-selftest ctest confirms it catches a stale artifact.
Wiring it as a standalone GitHub-workflow required check is separate and owned by
the CI layer.
Placement convention (repo-wide): a subsystem-local generator binary lives
under core/<subsystem>/tools/ (here, schema_emit_main.cpp), while a
repo-wide gate script lives under tools/scripts/ with the other checks
(schema_drift_check.py, alongside timeline_engine_dependency_floor_check.py).
Don't invent a per-subsystem tools/ dir for a gate script.
A tool that claims to be portable belongs under core/, not under test/,
even when its inputs live in test/. pulp-fixture-runner is the worked
example: its source is core/interchange/tools/fixture_runner_main.cpp while its
corpus stays at test/fixtures/timeline/, and test/cmake/timeline_tests.cmake
holds only the two ctest registrations. Two things break if such a tool lives in
test/. First, add_subdirectory(test) is gated on
PULP_BUILD_TESTS AND NOT ANDROID AND NOT IOS, so the binary cannot be
configured at all on the mobile lanes it exists to serve. Second — and this is
the one that stays silent — timeline_engine_dependency_floor_check.py walks
core/<module>/ and nothing else, so a #include <pulp/view/…> added to a
runner under test/ passes every gate while the file's own comment still claims
a portable floor. Relocating into an owning module puts the file inside the
existing scan with no new MODULE_FLOORS row. Pick the module at the top of
what the tool links (interchange, not timeline, since it calls census()).
schema_drift_check.py is generic — it takes --artifact and --emit-cmd and
byte-compares. A new generated artifact anywhere in the repo reuses it as-is
rather than growing its own gate; core/interchange registers three drift ctests
against it (vocabulary header, capability tables, docs page) from one emitter.
A module added under core/ that should have an enforced dependency floor
registers itself in MODULE_FLOORS in
tools/scripts/timeline_engine_dependency_floor_check.py. The check's selftest
iterates MODULE_FLOORS generically, so a new entry gets include-scan and
link-scan coverage plus selftest proof without touching the selftest. Adding an
entry is not the same as widening timeline's own floor — a module that sits
above timeline gets its own row and must not appear in timeline's set.
Three things bite when adding a row:
verify() reports missing required engine module when a row names a
directory that does not exist. A row and its target therefore land in the
same change, always — you cannot declare a floor ahead of the code it
constrains. That is the intended discipline, not an obstacle to work around:
it is what stops a floor from being written around a violation that already
shipped.timeline_editor), but LINK_RE reads a CMake alias verbatim, so
pulp::timeline-editor yields the token timeline-editor. A row carrying
only the underscore spelling reads a helper target's self-link as an
outside-floor violation.pulp/render, which is in
no floor at all. When a row's defining rule is that it cannot reach a module
that is in the table — timeline_editor and playback — assert that pair by
name too, or the rule survives someone widening the other row.target_link_libraries through core/<module>/CMakeLists.txt
to a fixed point, so a row is only honest if every module it reaches
transitively is in the set. Measure before declaring: a row that names one
in-floor dependency can still be breached three links down, and the error names
the chain (playback -> audio -> state) rather than only the destination.
Where the closure genuinely exceeds the floor, record the surplus in
LINK_CLOSURE_DEBT instead of widening the row — the row also governs
includes, and folding a link fact into it silently grants a header permission
nobody argued for.Two rules keep the walk honest and are easy to break by accident:
pulp-timeline-schema-emit, pulp-fixture-runner)
must not raise the floors of everything above it. Its links are still policed
at depth zero by the direct scan of its own module's build file — that is the
half the selftest's helper-target assertions cover.core/ directory is not a module.
pulp-tracing (defined in tools/cmake/PulpTracing.cmake) and
pulp-cpp-httplib (an INTERFACE shim inside core/runtime/CMakeLists.txt) are
build plumbing reachable from every row. They are skipped transitively rather
than added to five floors; a module's own build file naming one is still caught
at depth zero.A core/ module that links a declared engine module but owns no row is the
other half of the contract. The intuitive rule — flag an engine module that
links something undeclared — is useless: it fires on platform, runtime,
audio and midi, which are floor primitives by design. The rule that bites is
the inverse, and ENGINE_CONSUMERS carries the ones that exist, each with a
reason. format and host are the sanctioned upper layers; sequence, smf
and dawproject sit above or beside the engine and have not been given floors.
The list rejects an entry with no reason and an entry whose subject no longer
links the engine, so it can neither grow silently nor rot.
A new core/<module> directory also drifts codecov.yml, whose flags and
components mirror core/*. Add the flag and the component alongside the target;
tools/scripts/gates.sh catches the omission before CI does.
A new rung takes a new row — never widen an existing one. timeline_editor
carries no view and no canvas, which is correct for the editor kernel and
will look like a gap the first time a view lands beside it. It is not. Widening
that row to admit view makes every consumer of the kernel pay for core/view,
which is the exact coupling the rung split exists to prevent. A view target gets
its own directory and its own row, sitting above this one.
A type two rungs both need goes in their floors' intersection, not in either
rung. playback and timeline_editor exclude each other, and timebase is
in both rows — so it is where a shared value type lives, and moving one there is
legal with no floor change at all. timebase::LoopRegion is the worked case: the
editor's UiLoopRegion and playback's LoopRegion had been the same three
fields in the same order. Check MODULE_FLOORS for the intersection before
placing anything; if the rows do not admit the home you want, the placement
argument is wrong and widening a row is not the repair.
The same reasoning bounds what may not move down. A converter between two
rungs' types names both, so it belongs above both — not in either rung, and not
in timebase, which may name neither. Until an engine above both exists there is
no legal home for one, and adding it anywhere reachable would mean widening a row.
UiPlayhead speaks the editor's nouns rather than mirroring the transport's:
UiTransportState in place of is_playing/scrubbing, and continuity_epoch
in place of playback_epoch — the rung's floor excludes playback, and a host
backed by a scripted value or a plugin's own engine has a continuity guarantee
without having a playback epoch. continuity_epoch is what a view checks before
smoothing motion between two readings; program_generation cannot substitute,
because a loop wrap breaks continuity without recompiling anything.
timeline_engine_dependency_floor_check.py is outbound: for each engine module,
does it reach up? tools/cmake/PulpLinkFloor.cmake is the inbound counterpart:
given a consumer — a plugin, an app — what does linking it actually cost, and
did it say so? pulp_assert_link_floor(<target> TIER <name>) gates,
pulp_report_link_closure(<target>) measures and writes
${CMAKE_BINARY_DIR}/link-floor/<target>.txt.
Reaching for the Python checker to answer the inbound question does not work, and the reasons are properties of CMake rather than of taste:
$<LINK_ONLY:dep> in INTERFACE_LINK_LIBRARIES, because a static archive
cannot resolve its own dependencies. Flipping a keyword from PUBLIC to
PRIVATE leaves the consumer's link line byte-identical. A checker reading
source text sees the keyword and has to model that rule; one reading the
resolved property observes it. Modelling it wrongly under-reports, which is
the one failure mode that makes a floor check worthless.pulp_add_plugin(X FORMATS CLAP) creates X_CLAP inside a function, links
${_PULP_VIEW_TARGET} — a variable _pulp_pick_target chooses — and only
when PULP_HAS_CLAP. Following that from text means evaluating CMake
variables, functions and conditionals. The engine check gets away with text
only because it reads core/<module>/CMakeLists.txt, where links are literals.Gotchas once you are reading the resolved graph:
SOURCE_DIR, never from the target name. pulp-view,
pulp-view-core and pulp-view-script are all core/view, and there is no
naming convention that stays true on its own.INTERFACE_LINK_LIBRARIES, not LINK_LIBRARIES.
Only the root target's own direct links come from LINK_LIBRARIES. Reading a
dependency's would invent edges: a shared library resolves its PRIVATE links
inside its own artifact and charges the consumer nothing.core/host links
pulp::format while format reaches back through view, so a walk without a
visited set hangs on the real repo rather than in a fixture.StepSequencer_CLAP against
CMakeFiles/<t>.dir/link.txt shows the two agree on every archive and differ
by exactly the header-only libraries: pulp-signal is an INTERFACE target,
so it is a real dependency that costs headers and produces no .a. Do not
"fix" the walk to match the archive list — the archive list is the narrower
instrument.Every plugin links the view stack, drawing or not. VST3, CLAP and AU each
link ${_PULP_VIEW_TARGET} unconditionally in PulpPluginFormats.cmake and
FATAL_ERROR if it is absent, so the closure runs
<plugin> -> pulp-view -> pulp-view-script -> pulp-view-core -> pulp-host -> pulp-playback. Two consequences worth knowing before reading a report as a
statement about the plugin's own code: a plugin acquires a transport it never
asked for, and a sequencer plugin's reach to core/timeline today arrives
through that chain rather than through its own engine. A red reading here is
usually the format packaging's bill, not the plugin's doing.
Tier versus debt. A tier is a bound several targets share, declared centrally
so no single target can widen it alone; PULP_LINK_FLOOR_DEBT_<target> records
what that target's closure drags in beyond the tier. Keep measured-but-unearned
reach in debt, never in the tier — an entry is a fact to pay down, and deleting
it once the edge is cut tightens the gate with no other edit. The check rejects a
debt entry that is no longer linked and one that duplicates its tier, so the list
cannot outlive its subject.
Debt is declared per target but measured per CONFIGURE, and that asymmetry
bites. A closure is whatever this configure links, and the project does not
have one: core/render is behind PULP_ENABLE_GPU, core/host is behind
NOT IOS. Under a narrower configure the modules those guards remove are absent
by construction — and the plain debt list reads that absence as rot, failing with
"debt entry 'render' is no longer linked. Delete it to tighten the bound". The
gate is asking you to delete an entry the wider configure genuinely needs, so
taking the advice literally trades a false failure on GPU-less trees for a
false pass on GPU-enabled ones. Declare such entries in
the entry under that same condition instead — if(PULP_ENABLE_GPU) list(APPEND PULP_LINK_FLOOR_DEBT_<target> render) — so where the condition
holds the entry is an ordinary debt entry and is still rot-checked, and only the
configure that cannot have the edge stops asking. Guard on the condition that
decides whether the module is built, never on one edge: render has two
independent edges (pulp_add_plugin under PULP_HAS_SKIA, and core/view's
if(TARGET pulp-render)), so guarding either leaves it unfalsifiable from one
side. playback and timeline are guarded on the same NOT IOS for a
different reason worth stating wherever it is written: both are built on
iOS and are guarded because the target's only route to them runs through host.
Establish that by configuring both ways — not from the closure report, which
records one shortest chain per module (PATHS_OUT, BFS first-arrival), so a
second longer edge is invisible in it. Note the
blast radius before dismissing this as a test failure — the assertion runs at
configure time from the plugin's CMakeLists.txt, so with
PULP_BUILD_EXAMPLES=ON a mismatch kills cmake --build at
cmake_check_build_system, and a headers-only external/skia-build (an ordinary
fresh-worktree state) forces GPU=OFF on its own.
Two readings that cost real time here: the same assertion text covers different
failures — an iOS Simulator configure loses host, playback, render and
timeline (the NOT IOS guard severs view-core -> host and takes the whole
chain), while a desktop GPU=OFF configure loses only render — so match the
literal entry list, not the first line. And cmake-link-floor-selftest passing
says nothing about this: its battery configures its own fixture project, so it is
green on a desktop tree while the real gate is broken on two narrower ones.
A tier is an upper bound and proves only absence. TIER says nothing outside
it is reached; it cannot say anything inside it is. "Reaches nothing extra" is
satisfied most easily by reaching nothing at all, so a tier naming a module the
target never links stays green while reading, to anyone scanning the row, as a
proven link. Do not answer "does the piano roll ship inside the plugin?" from a
tier — that question needs the other bound, and a tier that has been widened to
look like an answer is worse than no answer, because it is a false one.
REQUIRE <modules...> is the lower bound. Optional, listed at the call site
next to TIER, and every module named must appear in the measured closure or the
configure fails naming the ones that do not:
pulp_assert_link_floor(MyPlugin_CLAP
TIER sequencer-plugin
REQUIRE format state)
REQUIRE grants no reach of its own — a required module must also be declared in
the tier or the debt list, or no closure could satisfy both bounds at once, and
the check reports that contradiction rather than letting REQUIRE become a third
permission list. Pair the two whenever the criterion is about what the artifact
contains: the upper bound stops the editing stack leaking in, the lower bound
stops the claim being satisfied by the module quietly disappearing.
What the two sequencer plugins prove. Measured on a macOS
configure, it reaches eighteen modules, and timeline_editor is not among them —
pulp-timeline-editor is a live target in that same configure and this plugin
does not link it. timeline it reaches only through
pulp-view -> … -> pulp-host -> pulp-playback -> pulp-timeline, with no
pulp/timeline include anywhere in the example's own sources, so timeline is
recorded as debt rather than claimed by the tier. Its REQUIRE format state is
correspondingly narrow: this plugin's own code contributes no module edge beyond
the adapter it is packaged as. So the honest reading of a green run here is "a
step sequencer packaged as a CLAP, carrying no editing stack" — not "a piano
roll inside a plugin".
TimelinePluginProof_CLAP is the positive counterpart. Its processor owns a
Project and DocumentSession, implements NoteEditIntentHost, returns a
native PianoRollView from create_view(), and stores canonical Timeline JSON
in plugin-owned state. It lowers insert, move, and resize gestures against the
current MIDI snapshot. One EditGestureIdentityAllocator is retained from
Begin through Update to End or Cancel, so move and resize repaint
continuously while one undo restores the pre-Begin bytes. Terminal phases and a
successful atomic state replacement discard that gesture provenance. The
processor rebinds and repaints every live view after accepted or rejected
submissions, undo, and state restore. State restore also recognizes
the prior four-quarter empty-clip proof shape and migrates it to the MIDI proof
while preserving its clip start and all other authored state. It claims
sequencer-plugin-editor and
requires format timeline timeline_editor timeline_view, so configure fails if
any of those four disappears. The direct timeline_view link and lower bound
are the proof that the piano-roll implementation ships inside the plugin rather
than merely existing elsewhere in the build. The tier includes the base view
and canvas rungs because those are mandatory closure of the concrete view,
not target-specific debt.
Know where the verdict runs. The assertion lives in the consumer's own
CMakeLists.txt, so it is evaluated only where that consumer is configured. For
an example plugin that means the Shipyard mac/windows lanes
(PULP_BUILD_EXAMPLES=ON) and ordinary dev builds — not the GitHub-hosted legs
of build.yml, which configure PULP_BUILD_EXAMPLES=OFF. It also reports one
configuration: a link that only exists under WIN32 is invisible to a macOS
configure. tools/scripts/link_floor_selftest.py --mutate is what runs
everywhere; it weakens the checker eleven ways — including one that stops
checking REQUIRE at all — and requires each to be caught.
Every downstream agent surface is a pure function of the committed
timeline_schema.json, not a second reader of the registry. Each is guarded by
the same shared schema_drift_check.py (its own artifact, its own ctest), so the
chain is registry → manifest → surface: the JSON gate guards the first edge, a
per-surface gate guards the second. A surface generator never links the timeline
library — it consumes the JSON.
The TypeScript-type surface is the first such projection:
core/timeline/tools/schema_ts_emit.py reads the manifest and emits
core/timeline/schema/timeline_types.d.ts — one export interface per schema
type, plus a TimelineSchemaTypeName union and a TimelineSchemaTypeMap. Kinds
map by x-pulp-kind (Boolean→boolean; U32/I64String/U64String→
number | string, the union covering both the string wire form of the 64-bit
kinds and a numeric runtime value; String→string; Object→
Record<string, unknown>; Array→readonly unknown[]), and a field $ref
overrides its kind with the referenced interface. After regenerating
timeline_schema.json, regenerate the .d.ts too or its gate fails:
python3 core/timeline/tools/schema_ts_emit.py --out core/timeline/schema/timeline_types.d.ts
The timeline-schema-ts-drift ctest byte-checks the committed .d.ts against a
fresh emission; timeline-schema-ts-selftest
(core/timeline/tools/test_schema_ts_emit.py) proves determinism, complete
projection, kind mapping, and that the gate catches a mutated artifact. Note the
generator is Python (a pure JSON projection needs no build), so it sits beside
the C++ emitter under core/timeline/tools/ but reuses the shared gate rather
than a bespoke drift script.
The CLI-verb surface is the same shape:
core/timeline/tools/schema_cli_emit.py reads the manifest and emits
core/timeline/schema/timeline_cli_verbs.json — one verb per schema type,
each with its domain, version, and a flag per field. The flag value type maps by
x-pulp-kind (Boolean→bool; U32/U64String→uint; I64String→int;
String→string; Object/Array→json), and a field $ref becomes a json
flag that records the referenced schema type. Verb tokens drop the pulp. prefix,
join the hierarchy with :, and kebab-case each segment
(pulp.timeline.automation_target.device_parameter →
timeline:automation-target:device-parameter). This artifact is the
manifest-derived definition of the verbs; wiring them into the pulp CLI binary
is a separate downstream integration. After regenerating the manifest,
regenerate this too or its gate fails:
python3 core/timeline/tools/schema_cli_emit.py --out core/timeline/schema/timeline_cli_verbs.json
The timeline-schema-cli-drift ctest byte-checks it; timeline-schema-cli-selftest
(core/timeline/tools/test_schema_cli_emit.py) proves determinism, complete
projection, value-type mapping, and confirm-the-failure.
The JS-facade surface is the runtime-JS counterpart to the .d.ts:
core/timeline/tools/schema_js_emit.py reads the manifest and emits
core/timeline/schema/timeline_facade.js — a frozen ES module exporting
timelineSchema (a descriptor per type: domain, version, and fields), a
timelineSchemaTypeNames list, and timelineSchemaManifestVersion. The JS
engine imports it directly (no JSON parse). Field jsType reports the actual
runtime type — unlike the .d.ts, which widens the numeric kinds to
number | string, the facade reports U32→number and the 64-bit string kinds
(I64String/U64String)→string (carried as strings to keep precision);
Object→object, Array→array, and a $ref field records the referenced
type. After regenerating the manifest, regenerate this too or its gate fails:
python3 core/timeline/tools/schema_js_emit.py --out core/timeline/schema/timeline_facade.js
The timeline-schema-js-drift ctest byte-checks it; timeline-schema-js-selftest
(core/timeline/tools/test_schema_js_emit.py) proves determinism, complete
projection, jsType mapping, confirm-the-failure, and — when node is present —
that the emitted module parses, imports, and is deeply frozen (skipped, not
failed, without node).
The MCP tool-definition surface is another manifest projection:
core/timeline/tools/schema_mcp_emit.py emits the fixed ten operations
(project open, command apply, diff, undo, redo, validate, explain, render,
export, and import) into
core/timeline/schema/timeline_mcp_tools.json. The operation set is an API
decision rather than a copy of the schema CLI-verb table. Its type vocabularies
remain manifest-derived: project open lists every Document type, command apply
constrains its envelope to the Command types, and validate lists the Diagnostic
types. An empty Command domain emits the object-valued reject-all schema
{"type":"string","not":{}} for type_name, rejecting every command name until
the registry defines one. JSON Schema forbids an empty enum, and the released
MCP Tool wire contract requires property schemas to be objects rather than
boolean schemas; omitting the enum would accidentally accept an unbounded
string. The live MCP server consumes this generated artifact for both
advertisement and exact-ten operation dispatch. Export's accepted-loss enum is
projected from the committed interchange concept authority, excluding
unknown; never hand-copy or broaden that vocabulary.
python3 core/timeline/tools/schema_mcp_emit.py \
--out core/timeline/schema/timeline_mcp_tools.json
The timeline-mcp-drift ctest byte-checks the artifact;
timeline-mcp-selftest (core/timeline/tools/test_schema_mcp_emit.py) proves
determinism, exact operation membership, complete domain projection,
fail-closed empty command behavior, and confirm-the-failure.
Two ways to believe a generated tree is in sync when it is not.
A bare schema_drift_check.py guards only its own DEFAULT_ARTIFACT
(timeline_schema.json). It is a reusable gate, not a whole-repo check, so its
exit 0 says nothing about the four sibling projections or the three interchange
artifacts. The enforced set is eight registrations, each naming its own
--artifact/--emit-cmd: five in test/cmake/timeline_tests.cmake (the
manifest plus .d.ts, CLI verbs, JS facade, MCP tools) and three in
test/cmake/interchange_tests.cmake (concepts.hpp, capability_tables.hpp,
docs/reference/interchange-matrix.md). Verify the set — ctest -R 'drift' —
rather than a single hand run. Note the interchange three come from
capability_emit.py over core/interchange/capabilities/*.json, a different
generator with different inputs; --update on the schema gate does not touch
them.
After a merge that touches any generator's inputs, regenerate every artifact
that generator produces — whether or not git reported a conflict. These
artifacts are single-line or densely minified, so git will often auto-merge them
cleanly and be wrong, with no conflict to alert you. A merge bringing in schema
changes from both sides can leave .d.ts, CLI verbs, and the JS facade silently
stale while the manifest's own gate passes. "Never resolve a generated artifact
as text" covers only the conflicting case; the set that matters is every output
of every generator whose inputs the merge touched.
Two adjacent invariants the drift gates do not cover, both fail after a merge
looks fine: tools/mcp/CMakeLists.txt FATAL_ERRORs at configure time unless
timeline_mcp_tools.json carries exactly ten tools in an exact name order, and
core/interchange/capabilities/concepts.json is append-only and
order-significant because position fixes the generated enum ordinal. For
concepts.json, check that the other side's entries survived at their
original ordinals — confirming only your own additions passes a resolution that
silently dropped theirs, and both wrong resolutions compile.
pulp::tool-timeline is the shared headless implementation for agent-facing
project operations. It loads either canonical inline JSON or a project path,
uses the built-in registry for persistence and command decoding, submits edits
through DocumentSession, compiles the root sequence through
PlaybackProgramCompiler, and renders arrangement audio through
ArrangementAudioRenderer.
External asset locators are URI hints, not filesystem paths by definition.
The headless render lane accepts bare local paths and canonical file:// URIs,
percent-decodes local file URIs (including file://localhost/...), and skips
unsupported or non-local schemes before constructing a filesystem path. It
still verifies the resolved bytes against the asset's ContentHash.
PackageRelative locators remain a separate contained-path contract beneath
the canonical project directory; do not route them through the external-URI
resolver.
The installed CLI keeps this operational layer thin:
pulp seq schema
pulp seq validate <project.json>
pulp seq explain <project.json> [--sample-rate <hz>]
pulp seq apply <project.json> <commands.json> [--out <project.json>]
pulp seq export <project.json> --format <smf|dawproject> --plan
pulp seq export <project.json> --format smf --out <new-directory> \
pulp seq export <project.json> --format dawproject --out <new-file.dawproject> \
[--accept-loss <concept-id>]...
pulp seq import <file.mid|file.dawproject> --format <smf|dawproject> \
--out <new-directory>
pulp render <project.json> --out <file.wav> [--sample-rate <hz>]
Do not add hand-authored mutation verbs to cmd_seq.cpp; apply consumes the
registry-derived typed command envelopes. render emits Float32 WAV and does
not silently instantiate hosted devices or invent plugin delay compensation.
The headless explain result reports unknown PDC offsets as JSON null.
Import and export refuse every existing destination, stage into a private
sibling directory, and publish the complete directory atomically. Never add a
force, overwrite, or accept-all path. Export requires separate consent for
every planned lossy concept so a newly introduced loss stops an unattended
pipeline. Run --plan first: it returns the canonical manifest and
required_consent without writing anything, even when the project is lossless.
Planning rejects --out and --accept-loss; it does not invent a destination.
Publishing requires --out. MCP uses the equivalent outputless
plan_only: true input and rejects output or accept_losses in that mode.
Refusal and successful export
results carry the same manifest object. SMF exports contain project.mid;
DAWproject export publishes one standard .dawproject ZIP containing a root
project.xml, the manifest, and referenced media entries. DAWproject import
requires a .dawproject ZIP, rejects unsafe or unsupported archive entries,
confines media resolution to safe package-relative entries, and publishes
canonical project.json plus sealed sibling artifacts into a new directory.
seq validate compiles, so a schema-valid project can still be refusedDecoding is not validation. A document can satisfy the registry schema and
still describe something the program compiler will not lower — the compiler's
refusal vocabulary exists precisely for shapes the model permits and playback
cannot honour. So validate compiles the project, reports each refusal in a
diagnostics array, and exits non-zero when it emits one. A validator that
reports a refusal and then claims success has validated nothing.
Two details of that wire shape are contracts, and one deliberately is not:
code is the PascalCase enumerator name, never the numeric value.
CompileErrorCode is appended to, so its numbering is a process-internal
detail no caller may key off. code_id rides alongside as a debugging aid and
carries no contract.default:, so appending an enumerator is a
-Wswitch diagnostic at that switch rather than a silently wrong wire name
reaching a caller. Do not add a default: to quiet it — that is the entire
mechanism.stage
and no diagnostics key at all, so a caller cannot read an unreadable file as
a project with nothing wrong with it.MCP inherits this for free: pulp_timeline_validate already routes through the
shared pulp::tools::timeline::validate entry point, and timeline_result
already marks a non-zero result isError. Inheriting it is still a claim about
a call rather than an observation, so test_mcp_timeline_tools.cpp asserts the
refusal over MCP directly. The MCP surface is the one Forge consumes; do not
leave it proven only by the CLI test.
The negative control is what makes the refusal test mean anything. Test the
same nested fixture twice, differing only in the leaf: a note leaf is refused
NestedGainSinkUnsupported because gain composes by multiplying into the
flattened leaf's own clip gain and note events carry none, while a media leaf
composes and must return exit 0 with "diagnostics":[]. Without that second
case the test also passes against a validate that refuses everything, which is
exactly as useless as one that accepts everything.
emit() routes a failing result to stderr, so a CLI test asserting a refusal
must redirect 2>&1 or it will read an empty file and fail for the wrong
reason.
The live MCP server embeds timeline_mcp_tools.json at configure time and
dispatches exactly ten operations. Seven operations retain stateless
pulp::tool-timeline entry points; diff, undo, and redo retain an actual
DocumentSession in the bounded MCP process. The CLI has no pulp seq diff,
undo, or redo session verbs. The production store admits at most 32 sessions
and applies a 64 MiB aggregate admission charge equal to twice each session's
canonical JSON size plus its fixed history reservation. This deterministic charge
is a resource proxy, not a direct heap measurement. Each complete encoded MCP
result is independently capped at 64 MiB. The store evicts the oldest session
first when a new or changed session would exceed the count or aggregate charge.
With the default limits, each session reserves half of the aggregate charge
divided across the session cap for journal and undo history; a sufficiently long
uncheckpointed session can therefore refuse a later edit without changing its
state. Sessions are process-local and expire on eviction or server restart.
diff describes only the latest successful apply, undo, or redo transition and
returns its exact dirty set plus before_revision and after_revision; it is not
an arbitrary since-revision query. Do not copy their input schemas into
pulp_mcp.cpp; regenerate the artifact from the
timeline manifest and let the server consume it. The MCP render result can be
fed to pulp_audio_compare for an advisory before/after judgment when the
opt-in Audio Quality Lab tool is installed.
Generated live-event batches use monotonic half-open tick spans plus playback epoch. Keep producer-owned revisable staging physically separate from the immutable committed SPSC ring; publish a complete batch with one release cursor. Starvation advances the requested span, counts lag, emits zero events, and requests an active-note flush so a missed note-off cannot hang. Seek/restart must quiescently begin a new playback epoch, invalidating pending work. Validate each UMP packet's word count from its message-type nibble. Deadline degradation selects only a producer-supplied fallback policy; it never invents thinning.
production_mode.hpp declares ProductionMode (Synchronous / Buffered) and
ReproducibilityClass (Deterministic / Tolerance / Materialized /
BestEffort). Three rules that are easy to get wrong:
production_mode_from_name /
reproducibility_class_from_name return nullopt on an unknown name rather
than defaulting, so a document from a newer build never silently reads as the
strongest claim. Aggregate several classes with weakest, never by picking the
first.A Track owns a TrackMixer — a linear gain_linear and a stereo balance
pan — and AutomationTarget has a TrackMixerTarget alternative naming one of
those controls. Sends, mute, solo, and routing are deliberately absent.
Things that are easy to get wrong here:
write_track emits the mixer
member only when the value differs from TrackMixer{}, so a document that
never touched a fader stays byte-identical to its pre-mixer form and existing
golden renders do not shift. The v6→v7 upgrade is therefore a version stamp
and nothing else; the v7→v6 downgrade refuses outright when a mixer member
is present, because a v6 track has nowhere to put a gain and dropping one
silently changes how the document sounds.validate_attached_automation), the insert reduction must
not prove one live, and the remap must return it unchanged. The
one-lane-per-control rule still applies: duplicate detection compares a
normalized key whose leading discriminator keeps a mixer target from colliding
with a device target that shares its zeroed placement ID.TrackInput has to bring it
across — see "An identity rewrite must copy the source input, not
re-enumerate it" for why the remap dropped it silently and what shape stops
the next field from going the same way.AutomationTarget reaches four consumers. serialize_encode.cpp,
automation_document_internal.cpp, transaction_automation_internal.cpp, and
core/interchange/src/census.cpp. Dispatch through AutomationTargetCases
(no generic fallback) at every one so a future alternative is a compile error
rather than a std::terminate under -fno-exceptions or a silent omission
from a census.structural_registry_validation.cpp too.
That table is an exact field-by-field comparison against the registry, so a
new field or a new registered type there fails serialization with
InvalidSchema at path / until the table matches — an error that names
nothing useful if you do not know to look.TimelineGraphPlaybackBinding owns a
stable mixer node per track. A hosted device chain with a nontransparent mixer
must provide post_device_audio_source and
post_mixer_audio_destination; the binding transactionally replaces that
exact direct audio edge and restores it when the route or binding goes away.
Program adoption fails closed if a hosted mixer becomes nontransparent
without that route. Keep stopped automation parked, and evaluate precise
host-mapped ticks without round-tripping through integer samples.core/timeline_view sits above core/timeline_editor and is the first production consumer of
that kernel — everything else referencing it is build files, the floor script, docs and tests.
The convention that keeps it composable: a view takes resolved scalars, never a projection
object. The arranger is handed an origin tick and a px_per_tick, not a ViewportProjection;
hit-testing takes a resolved tolerance_px, not a device-pixel-ratio to interpret. Two consequences
worth keeping:
The consumption chain, which is what makes a view worth shipping rather than deferring:
arranger view -> EditIntent -> SequencerUiHost::submit_intent
-> lower_edit_intent -> timeline::Transaction -> reducer -> serialize_project
Every link existed before the arranger and every link except the arranger was exercised only by tests. When adding to this stack, check the chain more than one level up: this codebase has a long history of capabilities whose caller had no caller.
Acceptance for an editing surface is a serialize_project round trip with values asserted —
drive it with simulate_click / simulate_drag and assert the document's values survive, not that
the view's internal state changed.
Read literally the rule above would bar TickProjection and PitchProjection, and the piano roll
consumes both. The line is not between a struct of floats and a class: it is between resolved
values and viewport policy. A type that owns zoom, scroll position, or a device-pixel ratio — and
therefore has to be kept in sync with the shell — is what a view must not hold. A TickProjection
is a visible tick range plus a pixel span, and a PitchProjection is an inclusive pitch range plus
a pixel span; neither decides anything, so handing one over is the same act as handing over
origin_tick + px_per_tick, with the arithmetic named once instead of twice.
Prefer consuming them. The arranger minted its own scalars and left both projections with no consumer outside their own test, which is how a capability ends up shipped and unused.
lower_note_edit_intent carries only the note subset a gesture changes. Insert lowers to
InsertNotes, erase to RemoveNotes, and move/resize/velocity to SetNoteEvents. A
GesturePhase::Single edit remains a closed commit-on-release transaction. A continuous
Begin/Update/.../End stream preserves those exact phases and must reuse one valid
writer-owned UndoGroupId; the session then undoes and redoes the complete drag as one group.
This avoids the old O(clip) ReplaceNoteContent charge on every update while keeping exact
optimistic-value semantics at note granularity.
The lowering takes the clip's current note array as a parameter rather than looking a project
up. That keeps it pure for the same reason the clip lowering is pure, and it turns a stale view into
a named refusal (ExpectedNoteMismatch) instead of a reducer conflict the caller has to decode.
project.next_item_id(). plan_identity_insert
rejects anything below it as IdentityNotAvailable, even for an id nothing has ever used. This is
why an insert gesture takes its identity from a caller-supplied factory: a view genuinely cannot
mint one, and the model enforces it rather than trusting the convention.TickProjection::tick_at clamps to the visible end, so a gesture that reads its result can
never produce a tick past the viewport. A trailing-edge resize therefore stops exactly at the
clip end and needs no bounds refusal, while a move still can leave the clip, because the grab
offset is subtracted after the clamp. A bounds check written against the resize path alone is
unreachable code that looks like safety.This subsystem owns authored take/comp state, durable launch scenes, slots, and
follow actions, the durable JournalSink ordering seam, and native
FileJournal, but not package/container I/O, publication, realtime playback,
launch scheduling or automation delivery, nesting, device implementations,
routing, audio, format adapters, or UI. core/project_package owns durable
publication: no-replace content-addressed blobs and generic artifacts, plus
validated atomic replacement of project.json within a stable package root.
It also owns bounded cleanup of its private staging files without moving
canonical Timeline serialization or archive-format semantics out of their
existing owners. Package-wide recovery and reachability GC remain a follow-on
layer. Add other concerns in their owning modules instead of widening the
command and persistence core opportunistically.
Slot, Scene, and FollowAction* in clip_launch.hpp are durable authored
values owned by Sequence; both structural types are registered schemas and
their IDs live in the Project identity directory. Sequence schema v5 introduced
the required scenes array after v4 introduced groove. The v4→v5 migration
inserts an empty array, while v5→v4 refuses to discard a non-empty one.
Quantization and follow-action choices round-trip canonically, but sample-accurate
launch progress remains runtime state in core/playback/clip_launch.*.
core/interchange treats clip.launch as model-detectable and records each
authored scene in the canonical census, so export loss manifests cannot omit
launcher state silently.
A random follow action (Any, Other, or a weighted candidate draw) must stay
a stateless hash of (session seed, slot id, draw index), never a stateful
RNG. Engine determinism requires that the same document plus journal plus
transport trace produce the same event stream, and a shared RNG breaks that in
a way no single-lane test catches: one lane's draw would depend on how many
other lanes happened to resolve earlier in the same block, so the result would
track evaluation order. Hashing the deciding slot's own id makes the draw
independent of every other lane. FollowDraw::value() is that hash; keep new
random behaviour derived from it rather than adding a second source of entropy.
A follow-action period is a bare TickDuration, not a LaunchQuantize — it is
measured from the launch, so there is no phase to author and a LaunchQuantize
there would carry a field nothing reads.
core/timeline/PulpTimelineSources.cmake is the canonical production source
inventory. Desktop targets consume its portable and native lists; WAM and
WebCLAP consume only the portable list. Add a new translation unit to that
manifest instead of duplicating source lists in platform CMake, and keep
web_timeline_source_closure_check.py green so an unclassified file cannot
silently disappear from a runtime.
Build and run pulp-test-timeline-model, the automation curve and lane suites,
the commands, transactions, journal, and undo suites, plus
pulp-test-timeline-schema-registry, pulp-test-timeline-schema-codegen, and
pulp-test-timeline-persistence in Release and UBSan configurations.
All but the journal suite (an RT-probe binary of its own) share the grouped
pulp-test-group-timeline executable (their CTest names are unchanged), so build that target and run them through
ctest -R, or run one suite with -# "[#<source stem>]".
Keep the 10k-clip edit test proving bounded node creation, subtree sharing, and
reclamation; a vector rebuild is not an acceptable persistent-index substitute.
Keep the 4k-scene/16k-slot launcher test proving bounded node creation, high
structural sharing, zero launcher allocation for annotation/context edits, and
zero sharing for an independently built equal launcher.
Keep pulp-test-timeline-replay-golden green: it applies real journaled gain,
fade, and note edits, replays from the checkpoint, and compares the resulting
audio/MIDI byte stream with both the committed snapshot and pinned fixture.
Also verify installed-header consumption, -fno-exceptions -fno-rtti, and that
timeline translation units do not include or link pulp::format, pulp::host,
or pulp::view.
test/cmake/timeline_tests.cmake is the manifest that registers the
pulp-test-playback-* suites alongside the document-model ones, so a new
playback-side suite is added there rather than in a new manifest — including
pulp-test-playback-program-wire, which covers the flat program wire the web
lane publishes generations over (pulp/playback/program_wire.hpp; the format's
own rules live in the playback skill). Sharing the manifest does not make the
program wire part of the document schema: it encodes a compiled program, and
a document-model change reaches it only through the compiler.
test/cmake/sampler_runtime_tests.cmake also registers sampler Heritage
runtime tests. That shared CMake inventory does not make profile JSON, capture
evidence, or sampler rendering part of the timeline document schema; keep those
contracts in pulp::audio unless a future version explicitly adds a document
reference type.
test/cmake/timeline_tests.cmake also owns the playback RT-safety suite
registrations, which carry a two-backend shape: a $<BOOL:${UNIX}> split
between native_components/rt_intercept_test_support.cpp and
harness/rt_allocation_probe.cpp, plus pulp::native-components,
${CMAKE_DL_LIBS}, and a PULP_NATIVE_CORE_PROCESS_RT_TRAP_TESTS=1 define.
Do not simplify that to a plain source list. Dropping the trap source while
keeping the define fails at link on RtNoAllocScope's out-of-line constructor,
which is the intended behavior — the playback skill explains why that guard
exists and what still needs a hand-run control.
A new bounded collection needs a DecodeLimits field, a tightened value in
DecodeLimits::web_defaults(), a counter on ProjectSnapshotCounts, a
governed_array call in the preflight walker, and a bounded_increment in the
decoder. Stop after the decoder and the quota exists but is never differentially
checked. test/fuzz/timeline_document_oracle.* closes it in two rows: the
StructureCensus field plus one quota_axes() entry binding the measured count
to its declared ceiling. That pairing is what makes the tightening sweep able to
fail — the census is walked off the decoded model while the counts come from an
independent scan of the source bytes, so an axis present in one and absent from
the other is a quota nothing enforces.
Proving a test fails without its implementation means editing production code,
rebuilding, and re-running. On a small target the whole cycle finishes inside
one filesystem timestamp tick, so cp + touch of the restored source leaves
make believing the object is current — and the next control runs against the
previous mutation's binary. The failure mode is not "no result": it is a
confident wrong verdict, in both directions, and it is indistinguishable from a
real one. Two independent fixes are needed together:
find build -name '<file>.o' -delete) rather than relying
on timestamps, so the rebuild is unconditional.Building CXX object.*<file> actually appears in the build log, and
report a harness error rather than a verdict when it does not.Add a no-op mutation that must read GREEN. A control set where every entry reads RED has not shown that the instrument can report anything else.
pulp-test-timeline-document-fuzz (registered under the fuzz ctest label)
drives deserialize_project, peek_project_summary, and
deserialize_commands over a mutated corpus seeded from
test/fixtures/timeline/corpus.index. The oracles live in
test/fuzz/timeline_document_oracle.* and are shared with the optional
libFuzzer target, so there is one definition of what a finding is.
Three things about it are easy to get wrong:
LimitExceeded that reports actual > limit — and admission,
which rejects a document accepted over a ceiling that was in force. A harness
whose only oracle is "did not crash" would pass with every structural quota
unenforced.Project; the scan path reports
ProjectSnapshotCounts from the source bytes. Comparing the two is what
detects a counter that is never incremented. Measuring a quota with the
counter that enforces it confirms itself.max_clips and its siblings are enforced twice — once in
schema_json_preflight.cpp and again in serialize_project_decode.cpp.
Weakening only the preflight leaves deserialize_project rejecting and
surfaces on peek_project_summary alone. Expect a finding to name one
surface and not the other, and do not read that as the oracle being flaky.Adding a structural ceiling to DecodeLimits means adding a row to
quota_axes(); the axis-count assertion fails otherwise, which is deliberate —
a ceiling with no axis is a quota the sweep silently never exercises.
PULP_ENABLE_FUZZING=ON builds the coverage-guided target and is off by
default. Every libFuzzer target gets its driver through
pulp_fuzz_instrument_target() (tools/cmake/PulpTestSuite.cmake), which also
probes the toolchain once per configure and fails with the cause named rather
than at link time. Apple's clang ships no -fsanitize=fuzzer driver, but it
accepts fuzzer-no-link, so on macOS set PULP_FUZZ_RUNTIME_ARCHIVE to
Homebrew LLVM's libclang_rt.fuzzer_osx.a (same LLVM major as the Xcode
clang) instead of switching compilers; Homebrew clang's libc++ does not
compile against current macOS SDK math headers. Under this option the whole
tree is compiled with fuzzer-no-link plus ASan, so a target's coverage
reaches the timeline decoders it calls, not only its own entry file. The
deterministic replay needs no special toolchain and is the lane that runs on
the PR path.
The same if(PULP_ENABLE_FUZZING) block in test/cmake/timeline_tests.cmake
also registers pulp-fuzz-smf (test/fuzz/smf_fuzz_target.cpp), the
coverage-guided lane over Standard MIDI File import: one input goes through
import_smf under the strict default policy and again under IgnoreNonNote
with ceilings small enough that the limit checks run on ordinary inputs. It has
no deterministic twin and no oracle beyond "no crash, no allocation past the
authorized ceilings", because a rejected import is the expected outcome for
most inputs. Its seeds are the two .mid files under test/fixtures/fuzz/smf/
and its bounded smoke is the pulp-fuzz-smf-smoke ctest (label libfuzzer),
registered through pulp_add_libfuzzer_target() in
tools/cmake/PulpTestSuite.cmake; the nightly fuzz workflow runs the long
budget.
A "gap-free during playback" test must distinguish two things that both look like silence at the head of the stream:
latency_samples() samples. Start the
continuity scan after that window, and say so in the test, or the assertion
reports a gap on every healthy run.PlaybackProgramStore::read() returns a non-copyable, non-assignable
ReadGuard. A render loop cannot reassign one guard as it swaps programs —
hold a separate guard per program and drive the blocks through a helper, which
also keeps the transport position continuous across the swap.
AutomationTarget is guarded, and the guard is load-bearingAutomationTarget is a std::variant, and core/timeline compiles
-fno-exceptions. That combination makes std::get<Alternative> on a
mismatched target call std::terminate rather than throw — so a consumer that
reads the target with std::get is a latent process abort the moment the
variant grows. Three encoder/transaction/document sites do exactly that, and
they carry a static_assert on kAutomationTargetAlternativeCount for it.
The opposite mistake is quieter and worse. A consumer that visits with a generic
lambda ([](const auto&), or an if constexpr chain with no else) keeps
compiling and silently ignores the new alternative. A target that exists in the
document but is missing from a census or an export loss manifest reads as
"nothing was there" — a manifest claiming no loss while dropping data is worse
than a refusal.
So visit through AutomationTargetCases, the overload set with no generic
fallback. Adding an alternative then fails the build at every call site until
someone decides what it means. When you do widen the variant, expect the
static_asserts to fire: that is the design, and each message names the
decision that site owes.
pulp_audio_compare is advisory and opt-inhandle_audio_compare delegates to the Audio Quality Lab, a managed Python
tool that is deliberately not installed by default and is resolved relative
to a Pulp project root. A test must not assume a measured judgment comes back:
when the lab is absent the handler still returns a well-formed typed envelope
carrying its install hint. Assert the typed envelope and the absence of an
argument refusal — that is what proves the loop reached the compare stage — and
leave the measurement to the tool's own suite.
std::int64_t is a different type on Linux and Darwin — never let CTAD see a bare LLstd::int64_t is long on LP64 Linux and long long on Darwin. A bare 0LL literal is
long long on both. So a sibling written with LL alongside a std::int64_t expression unifies
on macOS and diverges on Linux — and std::array class-template argument deduction requires every
element to have the same type, so it fails on exactly one platform:
// BROKEN on Linux, compiles on macOS. kTicksPerQuarter is std::int64_t.
const std::array windows{
std::pair{kTicksPerQuarter / 4, 3 * kTicksPerQuarter / 4}, // pair<long,long> on Linux
std::pair{0LL, 3 * kTicksPerQuarter / 4}, // pair<long long,long> <-- diverges
};
GCC reports no matching function for call to 'array(std::pair<long int, long int>…)' plus a
no type named 'type' in 'struct std::enable_if<false, …>' — which reads like a container problem
and is a type-identity problem.
Fix by spelling the element type, not by correcting the literal. Correcting 0LL leaves CTAD
deducing, so the next sibling reintroduces it:
using TrimWindow = std::pair<std::int64_t, std::int64_t>;
const std::array<TrimWindow, 3> windows{ TrimWindow{…}, TrimWindow{0, …}, TrimWindow{…} };
Why this class is dangerous here specifically: the required gate is macOS, and there is no macOS signal at all — the code compiles cleanly on the platform that gates the merge. Only the advisory Linux lane can see it.
Reproduce it without a Linux toolchain — a standalone TU with using i64 = long; in place of
std::int64_t gives the identical deduction error on Apple clang, so the diagnosis is
positive-controlled locally even though the confirming build is CI's.
Applies to any deduced aggregate over timebase quantities — ticks, frames, sample counts — since
those are std::int64_t throughout.
Read references/dawproject-import.md before changing the DAWproject importer or adding another foreign-format importer. It defines the native/web source boundary, parser constraints, fail-closed subset, sealed media identity, and pre-growth resource limits.
Read references/smf-interop.md before changing
Standard MIDI File import/export. It covers why the conversion stays in the
musical domain rather than resolving to seconds, which header divisions convert
exactly against kTicksPerQuarter, why the vendored choc::midi::File reader
cannot back this path, and the byte-stream traps (running-status cancellation,
system-exclusive framing, FIFO note matching) a hand-rolled decoder must get
right.
For a librarian that needs the complete message bytes, call
pulp::smf::extract_sysex on Pulp::smf-interop. It uses the same byte decoder
and exposes track/tick provenance without constructing a Timeline project.
The committed interchange capability data is the authority for both SMF and
DAWproject admission and loss accounting. Each format JSON carries a stable,
contiguous ordinal; never infer Format ABI order from filenames. Reader and
writer implementations keep compile-time lists of the concepts they actually
support, so widening a generated table row without matching code must fail the
build. When the model gains a detectable semantic distinction, add a concept,
teach the census to name it, and declare both formats' behavior in the same
change before claiming a lossless path.
SMF has two deliberately separate export surfaces. pulp::timeline::export_smf
strictly checks the clip, event, and time-grid shapes it visits, but does not
census unrelated project state. pulp::smf::writer() is a non-callable,
format-bound adapter for interchange::run_export(): it serializes the project
snapshot owned by the plan, and only the central runner appends
pulp-loss-manifest.json. Never capture or pass a second Project into an
interchange writer, and never add a direct adapter invocation path. The
deprecated dawproject::writer(project, options) compatibility overload is the
sole exception at the source boundary: it deliberately ignores project and
delegates to writer(options). Only the interchange adapter is the
project-wide consent surface.
capability_emit.py materializes a closed world, so a concept a format's JSON
omits still gets a row. It is not a hole, and it does not fail the build. But
the two directions are not symmetric, and only one of them is safe to leave
implicit:
ExportLevel::Drop, LossClass::Dropped, and a
generated sentence, "<display name> declares no support for <concept id>".
Truthful and specific enough to ship. clip.media-window on SMF is the
committed example.ImportLevel::None with an empty refusal
string. There is no generated fallback, so the refusal names nothing.So write the import row even when the level equals the default; the export row
is a refinement of an already-true sentence rather than a correction of a false
one. What is genuinely broken without any row at all is a concept that does not
exist: LossManifest is keyed by Concept, so a construct with no id cannot
appear in a manifest at any level, and the export reports a clean bill.
smf.json describes Pulp's bounded Standard MIDI File subset — its reader and
writer carry exactly the concepts listed in smf_import.cpp / smf_export.cpp
— not what a .mid file could theoretically hold. The distinction is invisible
until it bites: a Standard MIDI File carries control change natively, and Pulp's
writer does not, so a format-worded loss sentence ("Standard MIDI Files have no
…") would be false where the existing rows' phrasing is fine. When the format
can carry something the adapter cannot, word the loss after the writer.
core/interchangeconcepts.json is append-only and order-significant because position fixes the
generated enum ordinal. Three artifacts come from capability_emit.py, gated
separately in interchange_tests.cmake — run each individually and unpiped,
never as one ctest sweep whose exit code you read through a pipe:
python3 core/interchange/tools/capability_emit.py --emit concepts > core/interchange/include/pulp/interchange/generated/concepts.hpp
python3 core/interchange/tools/capability_emit.py --emit tables > core/interchange/include/pulp/interchange/generated/capability_tables.hpp
python3 core/interchange/tools/capability_emit.py --emit docs > docs/reference/interchange-matrix.md
The fourth has a different generator, in a different module, and it is the one
that breaks behavior rather than just drifting. core/timeline/tools/schema_mcp_emit.py
also reads capabilities/concepts.json, and projects the vocabulary into
pulp_timeline_export's accept_losses enum and its x-pulp-loss-concepts
list. Consent is per exact concept id with no blanket override, so a concept
missing from that enum is a loss no MCP client can ever accept — every
export of a document using it is permanently unauthorizable through that path.
Regenerate it in the same change:
python3 core/timeline/tools/schema_mcp_emit.py --manifest core/timeline/schema/timeline_schema.json > core/timeline/schema/timeline_mcp_tools.json
Gated by timeline-mcp-drift and timeline-mcp-selftest — the selftest
fails too, with committed artifact matches a fresh emission. Neither is run by
tools/scripts/gates.sh, so a fully green gates.sh proves nothing here.
A grep scoped to core/interchange/ will not find this generator.
There is also a fifth surface that is data rather than code: any
test/fixtures/timeline/**/*.json.expect whose document uses the new concept.
pulp-fixture-runner --corpus test/fixtures/timeline --update rewrites them,
and timeline-fixture-corpus fails with the concept name and observed value
until you do.
The interchange table only governs exports routed through interchange::run_export. The public
pulp::timeline::export_smf() entry point is a separate surface that fails closed on shapes it
cannot carry, and it does not consult the capability table at all. So a concept the table declares
drop is still silently discarded by the raw API until you also teach build_note_track to
refuse it. Adding a concept without that leaves an SDK caller receiving a successful .mid with the
content gone — no error, no manifest.
The seam is SmfExportLossPolicy in core/smf/src/smf_export_internal.hpp. Both edits are
required, and they defend opposite failure modes:
smf_export.cpp — refuse when the content is present and the policy flag is unset. This is
what makes the raw entry point fail closed.smf_interchange.cpp — set that flag from loses(plan, Concept::X). This is what lets the
adapter proceed after the loss is accepted by exact concept id.Ship only half and the tests can still be green. Verified by mutation: hardcoding the
smf_interchange.cpp flag to false — so consent can never clear the refusal and a lane-bearing
export becomes impossible through every path — left the whole SMF interchange suite passing,
because every existing test used a project without the new content. A refusal test alone does not
cover the clearing half; you need one export that succeeds with the loss accepted and asserts
the surviving content, or the second edit is unverified.
timeline-schema-drift's --emit-cmd is $<TARGET_FILE:pulp-timeline-schema-emit>,
not a script. In a build directory where you only built the targets you needed,
that binary does not exist and the gate fails with no diff and no useful
message — indistinguishable from real drift, and easy to misattribute to
whatever you just changed. Build the emit target before believing it:
cmake --build build --target pulp-timeline-schema-emit
The interchange gates do not have this failure mode; their emit-cmds are Python.
Measured, not assumed. Changing the census to record a lane concept against the
clip id instead of the lane id leaves the count unchanged, so
timeline-fixture-corpus passes (exit 0) while a unit test asserting
owners(...)[0] fails (exit 42). A census row that records per-item evidence
therefore needs a unit test asserting the owner values; the corpus fixture
alone will not defend it, and contains(...) or a bare count will not either.
A PackageRelative asset locator is checked twice, by checks with different
powers. Do not remove either on the grounds that the other covers it.
Model (core/timeline/src/model.cpp, valid_locator) — lexical only.
Project::create refuses a hint that is absolute or contains .., so an
escaping document cannot be constructed in memory, let alone serialized. This is
the layer that makes a bad locator unrepresentable rather than merely unusable.
Loader (tools/timeline/src/timeline_project_loader.cpp,
resolve_package_relative_asset) — resolves. It runs fs::canonical and then
path_is_beneath(canonical_base, candidate).
The case that shows why both exist: a hint like media/link.wav that is
lexically spotless but whose target is a symlink out of the package. The
model has no basis to refuse it — nothing about the string is wrong. Only
canonicalization sees where it actually lands. Conversely the loader cannot help
with a document that was never loaded through it, which is why the model check is
not just belt-and-braces.
When testing this, note that hostile documents can no longer be built through
the API — the model refuses them. Author them by splicing the hint into
serialized JSON, which is also more faithful: the constructor never runs on bytes
someone else wrote. A refusal on that path surfaces as "stage":"open", not
"stage":"render".
A model field, a command, or a schema property is not finished when it
round-trips. The playback compiler refuses several constructs this module lets a
user author — expression lanes on a clip, and six combinations reachable by
composing set_clip_sequence_ref with set_clip_playback_properties,
set_track_mixer, set_track_freeze, or the take, automation and device-chain
surfaces. Those documents save, reload, copy and round-trip; only playback says
no, and nothing at authoring time warns anyone.
tools/scripts/negative_capability_check.py (ctest
playback-negative-capability) is what makes that cost visible. It cross-refers
every refusal-shaped CompileErrorCode and TimelineGraphAdmissionCode
raise against this module's public headers and
core/timeline/schema/timeline_schema.json, and requires an owner and a written
reason for each refusal it can reach from here. The admission enum is in scope
because a device chain is authored here and refused at graph admission rather
than by the compiler, so a checker reading only the compiler's enum would call
that whole class of refusals invisible. The gate is
registered in test/cmake/timeline_tests.cmake beside the engine dependency
floor.
When adding to the authoring surface, check the compiler consumes it —
core/playback/src/program_compiler.cpp and
core/playback/src/sequence_content_lowerer.cpp are where a new field either
lowers or gets refused. Shipping the model half alone is how a negative
capability arrives. The check only sees refusals that name a code, so a field
the compiler silently drops or clamps passes it: that case needs a test, not a
gate.
It also does not read a case label as a raise. A tool that maps every
CompileErrorCode enumerator to its own name — tools/timeline/src/ has one
for diagnostics — is a string table, not a refusal site, and the enumerator in a
neighbouring arm is not evidence the mapping read a document. Adding a codes
switch does not owe the allowlist anything; raising a code inside an arm still
does.
core/timeline/include needs a contract or docs failtools/build-api-docs.sh runs tools/scripts/timeline_api_docs_check.py over
the Doxygen XML and exits non-zero for any public callable without an API
contract:
model.hpp:768: error: public callable lacks an API contract:
pulp::timeline::SequenceCompileStructureToken::valid
It is a real gate, not advisory, and it fires on pull_request via
docs-material.yml's core/**/include/** path filter. Add the contract in the
same commit as the API — a one-line /// summary is not enough if the callable
takes parameters or returns something whose meaning is not obvious from its type.
Run it locally before pushing a header change; it needs Doxygen but nothing else:
tools/build-api-docs.sh # exits 1 and names the symbol
A local pass does not guarantee CI passes. CI installs ubuntu's Doxygen (1.9.8) while a dev Mac usually has a much newer Homebrew build (1.17). They do not agree on every diagnostic. The one that has already bitten:
schema_json.hpp:221: error: argument 'json' of command @param is not found in
the argument list of pulp::timeline::ParsedJson::parse_json(std::string_view,
const DecodeLimits &)
Note the scope in that message — ParsedJson::parse_json, not the free
function. Doxygen attached the free function's @param block to the friend
declaration inside the class, and that declaration had unnamed parameters,
so the names were unresolvable. 1.17 does not error; 1.9.8 does.
The fix is to name the parameters in the friend declaration so it matches the
definition. The general rule: if a documented free function is also declared
friend somewhere, both declarations need parameter names.
build-api-docs.sh now prints the local Doxygen version for exactly this
reason — when CI is red and local is green, check the versions before assuming
the tree differs.
test_timeline_graph_binding_publication.cpp drives binding.prepare() on the
control thread while an audio thread renders, and asserts the audio thread
observed both routes (one_blocks > 0 and two_blocks > 0). Two traps
compound here.
First, the reprepare loop is an ordering budget that orders nothing: it can run to completion before the audio thread is ever scheduled, leaving both counters at zero.
Second — and this is the one a re-poll cannot fix — the loop alternates
routes and ends on route_one. A wait that only spins re-reading two_blocks
can never succeed, because route_two is never published again. The wait has to
keep alternating, not just keep looking.
Bound it, and make the pump cheap. Tearing down reprepared bindings costs superlinearly in their count: a full-rate 10s wait spent 10s waiting and then ~30s in teardown (6663 reprepares), long enough to present as a CTest timeout rather than the failure it is. A 1ms pump sleep with a 2s deadline holds the whole failing run under 3s.
CompileContextSubscriptions means changing three things, and missing one is silentThe subscription set stores one bit per CompileContextKind. Widening its
storage type is not one edit — it is bits_, mask(), and subscribe().
subscribe() casts the OR result back to the storage type, so leaving it at the
old narrow type compiles cleanly, passes every existing test, and silently
discards every bit past the old width. Nothing warns: the truncation happens in
a static_cast the author wrote on purpose.
The tell is that reads() returns false for a kind you just subscribed. If you
widen the storage, add a test that subscribes to a slot past the old ceiling
and asserts it reads back — asserting only the named kinds cannot catch this,
because they all still fit in the old width.
The bitset is in-memory only and never serialized, so widening is invisible to callers and safe to do early. Prefer widening when the vocabulary first grows rather than when it reaches the ceiling, so the person who adds the kind that would have tripped the limit is not the one who has to change the storage type.
ChordScale and Groove are read from a sequence the reader already sits
under, so compile order is a tree walk. Kinds that let a reader subscribe to
context a sibling track produces turn that order into a DAG which must stay
acyclic — two tracks each reading the other's context have no valid order and
will either deadlock a compile or silently resolve against a stale peer.
CompileContextSubscriptions cannot express this: it records what a reader
reads, never when it may be compiled. So acyclicity is owned by whoever
gives a peer-edge kind a producer, not by the subscription contract. Reserving
the enum slot is safe on its own; wiring a producer to one is the point where
the ordering proof becomes load-bearing.
A sequence-owned lane looks like a small addition — a struct, a field, an accessor. Adding it to the in-memory model really is that small. Adding it to the document is a different job, and the difference is invisible from the type system.
chord_scale_lane is the worked example. Persisting it required, beyond the
model:
sequence_schema_migrations.cpp
(v3_members[], v4_members[], …), because member order is canonical;RawEdit migration that injects ,"chord_scale_lane":[] into documents
written before the member existed;<member>_introduced_version in sequence_schema_policy.hpp, guarded by
static_asserts that check the boundary from both sides (the version before
it must not require the member; the version itself must);schema_registry.cpp, structural_registry_validation.cpp, and
schema_json_preflight.cpp;serialize_encode.cpp and serialize_project_decode.cpp;core/timeline/schema/timeline_types.d.ts, which is generated
and drift-checked in CI by tools/scripts/schema_drift_check.py — editing
it by hand fails, and forgetting it also fails.So budget a serialized member as a document-format change with a migration, and
expect roughly fifteen files before writing any feature logic. An in-memory-only
lane (model + compile context) is genuinely small and can land on its own;
DynamicsLane deliberately did exactly that, and its serialization is a separate
piece of work for this reason.
Command alternative has six fail-closed sites and two silent onesAppending an alternative to the Command variant will not compile, or will not
pass, until six places agree — which is the good half:
command_authority_of<T>() in document_session.hpp — its final else is a
static_assert(detail::unclassified_command_v<T>, …) that is unconditionally
false, so a missing entry is a hard error rather than a permissive default;is_*_command_type lists in transaction_dispatch_internal.hpp —
transaction.cpp asserts the lists claim every alternative exactly once, so
claiming none and claiming twice both fail (a count-only check could not see
the second case, because one double claim and one orphan cancel out);expected table in test_timeline_writer_capabilities.cpp,
together with its STATIC_REQUIRE(alternatives == N);command.cpp, which are two
separate if constexpr chains — a command added to one and not the other
compiles and misreports its own size;expected name list in test_timeline_schema_registry.cpp,
whose static_assert is against variant_size_v<Command> — so it binds even
though it is a hand-written list;encoded envelope list in test_timeline_command_persistence.cpp, which
decodes one fixture per alternative and is index-keyed: append only, or
every holds_alternative assertion after the insertion point renumbers.test_timeline_agent.cpp counts "x-pulp-domain":"Command" occurrences in the
emitted schema against the same variant_size_v<Command>, so it follows the
registry automatically and needs no edit — but it turns a missed registration
into a red test rather than a silent gap.
The two that fail silently are the decode arm in
serialize_command_decode.cpp and the registration in schema_registry.cpp.
Skip either and the command still builds, still applies in-process, and is
simply unreachable from every wire surface — the CLI and MCP verbs are
generated from the registry, so an unregistered command produces no verb and
no error.
Commands are tagged on the wire by string type tag, never by variant index, so appending at the end of the variant carries no compatibility obligation. Append anyway: it keeps the positional authority table a pure append.
pulp::tools::timeline::command_apply — the one entry point behind both the CLI
and the MCP tool — loads a project from JSON, applies the decoded commands, and
returns serialize_project(...) of the result. So a mutation whose target is
not carried by the encoder is destroyed by the same call that performed it:
the transaction succeeds, the gate passes, the response JSON simply lacks it.
DynamicsLane is the live example. The lane is a public model type, a sequence
owns it, a command mutates it under an exact-value gate, and none of that is
enough to call the CLI or MCP surface exposed, because the sequence document
schema carries no dynamics_lane member. When judging a command's reach, check
the encoder, not the command:
grep -c dynamics core/timeline/src/serialize_encode.cpp # the finding
grep -c chord_scale core/timeline/src/serialize_encode.cpp # the control
A zero with no control beside it is indistinguishable from a mis-aimed grep.
command_authority_of<T>() returns exactly one {CommandClass, CommandIntent}
per command type, so a struct cannot carry three intents. A single
{expected, replacement} command that admits an empty replacement therefore has
to declare one intent for create, modify, and delete — and if it declares
Modify, every writer holding that class's modify bit can delete, because
Remove is the axis a capability mask denies by default for an untrusted
writer.
The opposite shape has the mirror defect. An Insert + Remove pair with no
Modify — the shape Class::Automation still has — means every value edit has
to be spelled remove-then-insert, so a proposal-profile writer (every class,
no destructive intent) can create a lane and then never change a value in it.
A capability reachable only by granting the destructive axis is not reachable.
Clip expression lanes take the third shape for this reason: Insert/Create,
Remove/Remove, and a separate point-edit command at Modify whose payload
names the lane by identity and carries no address.
Splitting the command is half the job — the split protects the lane's
identity, not its contents. The point-edit command is itself an
{expected, replacement} pair that admits an empty replacement, so it carries
the very defect the first paragraph names one level down: the lane survives, and
every point in it is retired. A declared intent describes the command; the
authority a payload needs has to be read off the payload. So any command whose
reducer calls plan_identity_deactivate while declaring Modify must widen its
requirement in required_authorities, by set-differencing the identities in
expected against those in replacement — ReplaceNoteContent and
SetMidiExpressionLanePoints both do. The general rule: a reducer that retires
an identity belongs to a Remove-declared command, or its arm in
required_authorities earns the Remove bit from its payload. There is no third
option, and a Modify command that replaces a collection of identified items
is exactly where the miss hides.
The test that earns this cannot be a mask comparison. allows(proposal, edit)
is true by construction — that is the whole point of the third shape — so
asserting it proves the split and says nothing about what a payload may do.
Submit the command through a real DocumentSession under
non_destructive_capabilities() and assert ConflictCode::CapabilityDenied,
with an in-place value edit on the same lane as the control that the writer is
still admitted. Write it before the reducers: it is the only assertion that
fails under any of the wrong shapes.
chased is a derivation receipt, and only the command layer can refuse oneMidiLanePoint::chased is written by the nested-clip flattening path when the
value sounding on entry came from before the retained window. An authored
document never sets it — and nothing in the model enforces that, because the
model has no way to tell an authored point from a derived one. The project
encoder does not write the member and the project decoder does not read it, so a
stored document cannot carry one either.
That leaves the command layer as the only place a caller could forge provenance,
and it has two doors: serialize_command_decode.cpp for a caller on the wire
and the reducer for one in process. Both refuse, and the pair is not a duplicated
model check — there is no model check to duplicate. Refusing rather than silently
dropping the flag is the deliberate half: a caller who believes they authored a
derivation receipt and did not is worse off than one who is told the field is
not theirs.
plan_identity_insert refuses any identity below project.next_item_id() unless
allow_tombstone_restore is set, and the public reduce_transaction passes
false. So the inverse of any command that retires an identity — a lane
removal, or a point edit that drops a point — cannot be reduced through the
public entry point. Undo for those paths is a real DocumentSession, which
passes the flag; the public reducer covers only the inverses that retire nothing.
Two consequences for tests. A fixture inserting a lane must use identities at or
above the project's next_item_id, or the insert is refused as
IdentityNotAvailable and reads like a reducer bug. And "restored exactly"
cannot be asserted as byte-identical project JSON across an insert-then-remove:
the identity index keeps the tombstone and next_item_id stays advanced, which
is the document correctly refusing to reissue an identity. Compare the clip's
lane vector instead — it is stricter than a count on every axis that matters
(identity, address, order, per-point value) and blind to bookkeeping that is
supposed to change.
CommandIntent::Remove is the destructive axis a capability mask denies by
default, and the MCP default proposal profile holds every class with no
destructive intent. So a vocabulary that ships only Insert and Remove is not
"a bit inconvenient" for that profile — the only way to change a value is
remove-then-insert, and the remove is refused, so the capability is write-once
for the writer class it exists for. Regions had exactly this shape: a
proposal-profile writer could author a region carrying a SectionRole and never
correct it.
The fix is a third command at Modify whose payload pins identity. Two things
make it a real Modify rather than a laundered pair:
expected and replacement must carry the same identity, refused in the
reducer and in the decoder. A Modify that can swap identity is a removal and
a creation wearing a signature that declares neither, which is a way around the
denial the profile is built on.reduce_transaction unchanged — unlike a lane or
point removal, whose undo needs a real DocumentSession.InsertMarker/RemoveMarker and Class::Automation still have the defective
shape. Three instances is a pattern: any lane or annotation vocabulary shipping
Create and Remove without Modify is unreachable for the untrusted writer profile
Forge uses.
TrackInput's three modulation collections arrived complete on every axis but
mutation: registered document schemas, an encoder, a decoder, and
validate_attached_modulation, which already refuses an out-of-range macro
position, an undeclared modulator kind, a route whose depth leaves
[-kMaximumModulationDepth, +kMaximumModulationDepth], a route naming a source
the track does not hold, and a source removal that would orphan one.
A command family over such a collection should reach that validator rather than
restate any part of it. The cheap way is a whole-collection replace that revalidates
through Track::create, exactly as Track::with_device_chain already did:
auto input = detail::track_input_of(*this);
input.modulators = std::move(modulators);
auto validated = Track::create(std::move(input)); // the only validator
// ... then copy only the replaced storage into a copy of *data_
Copying only the one field back is the load-bearing half. Track::create rebuilds
the persistent clip index from scratch, so returning its result directly would
discard every shared index subtree and silently turn an O(log n) edit into an O(n)
one. Reach create for its refusal; keep your own snapshot for everything it did
not change.
The payoff is that "removing a modulation source a route still reads is refused"
needed no code in the command layer at all — the model was already the authority,
and the reducer surfaces its ModelError as ConflictCode::ModelInvariant.
An optimistic gate that compares a float with == is normally a trap: a value
that round-trips through a decimal encoding need not compare equal to itself, so
the gate refuses an edit nobody conflicted on.
It is not a trap when the persisted spelling is the IEEE-754 bit pattern.
macro_control.value_bits and modulation_route.depth_bits are U32, so a round
trip is bit-exact by construction and operator== holds across it. The naive
mitigation — gate with a tolerance — would have softened every modulation gate
for a hazard that does not exist, so a command gating one of those floats spells
its own operands the same way (expected_bits / replacement_bits), never as a
decimal.
Prove it rather than reasoning about it, and prove it with a negative control:
gate on a decoded 0.1f (a value no decimal spelling at float width preserves)
and show the neighbouring bit pattern is refused. Acceptance without the
neighbour test is a gate that might accept anything close.
One consequence for idempotency: equivalent() compares those operands as bit
patterns, not with ==. Idempotency asks whether the same authored command
arrived twice, which is a question about the bytes — and == answers "no" to two
identical NaN payloads.
The three modulation collections look symmetric and are not. A Modulator and a
MacroControl are referenced — validate_attached_modulation refuses a track
whose routes name a source it does not hold, so removing one while a route reads
it fails as a model invariant. A ModulationRoute is referenced by nothing, so
its removal always succeeds and takes only the connection with it.
That asymmetry is worth knowing before writing the tests, because the "a source a route still reads cannot be removed" shape has no route equivalent, and looking for one wastes a cycle. What a route command owes instead is the opposite proof: that removing a route leaves both of its sources standing.
Two further route-only refusals have no analogue on the source side, and both live in the model rather than the command layer:
ModulationSourceRef carries kind explicitly so a macro can never quietly
stand in for a modulator that shared its ID. A {id}-only reference would
have made this unrepresentable rather than refused.Both must be tested on Insert and on the Set, because the two reach the
model through different accessors and a reducer could refuse one and not the
other.
ModulationRoute::enabled is an authored bypass, and modulation.hpp is
explicit that a disabled route keeps its identity, depth, and target so that
re-enabling restores what was there. Two obligations follow, and both are easy
to miss because a bypass reads like presentation rather than content:
Remove's inverse must carry the route whole, bypass included. An
inverse that reconstructed a default would bring a silenced route back live.enabled along with the rest, so an edit that
believed a route was live cannot land on one an author had disabled.Neither is visible in a test that only varies depth. Vary every member of the
gated struct in turn — for a route that is source, target, depth, and bypass —
or the gate is only proved for the field the test author happened to think of.
Several routes may reach one parameter and their offsets sum, which is exactly what separates a route from an automation lane. What the model refuses is the same source reaching the same parameter twice, because that is one connection stated twice with two depths and no rule for which wins.
This matters for test construction rather than for the command vocabulary: a
control that inserts a second route from the seeded source to the seeded
parameter is refused for that reason, which makes a depth-range or
source-reference test pass for the wrong cause. Point the control's route at a
different parameter (Pan rather than Gain) so the only variable left is the
one under test.
equal_region in command.cpp named five of SequenceRegion's six members and
omitted role — so two regions differing only in the member a generator
dispatches on compared equal, in command idempotency and in whole-document
equivalence. Nothing failed, because nothing asked.
Every member of that struct is exactly comparable, so the comparison is now
operator<=>(…) = default on the type and equal_region forwards to it. Prefer
that wherever the members allow it: a partial restatement of "are these the same"
is a second authority that can silently disagree with the first, and the way it
fails is by admitting an edit it should have refused.
The exception is real — equal_marker and the clip/track comparisons stay
hand-written because they must skip derived or float members — but "the members
are all exactly comparable and I wrote it out anyway" is not that exception.
Class::Timing governs pitch as well as time, deliberatelySetProjectTuning and SetTrackTuning are both {Timing, Modify}, which makes
Timing the only class spanning project and track scope. That is the accepted
cost of two alternatives that were worse:
CommandClass renumbers capability_bit and silently repurposes every
persisted and transmitted writer mask. Never add one; kCommandClassCount is
11 and the bit literals are asserted in
test_timeline_tuning_region_commands.cpp so an inserted class fails loudly.Class::Track would mean a grant issued to rename
and reorder tracks silently becomes authority to retune them, and it splits the
retuning grant across two bits so no mask can say "may not retune" without also
forbidding renames.The class doc comment states what it governs, because a class whose doc does not is how the next author picks the wrong one.
Modify, not Removestd::optional<TuningReference> absence is a claim — "this document names no
tuning" — and it is a different claim from naming equal temperament. Clearing
it removes nothing the document owns; the project or track persists unchanged in
identity, exactly as SetChordScaleLane, SetGroove, SetTempoMap, and
SetMeterMap all replace a whole value including an empty one under Modify.
Routing the clear through Remove would be the hardening mistake: it is denied
by default, so a proposal-profile writer could set a tuning it could never
retract. And the gate compares absence as a value — expecting absence where a
value stands is refused rather than treated as "no opinion", or a writer would
overwrite an override it never saw.
SequenceInput is populated in several places that reconstruct a sequence rather
than copy it — id_remap.cpp most importantly, plus the decode path. Each names
its members explicitly, so a new lane is silently dropped by any site you do
not update: the code compiles, the tests that do not exercise that path pass, and
the loss only shows up as authored data vanishing after a remap or a load.
Grep every site that names an existing lane (chord_scale_lane is the reliable
probe) and make each one a deliberate decision. A test that round-trips the new
lane through remap_ids is the cheapest guard.
SequenceInput field breaks positional brace-inits you cannot grep forSequenceInput is normally built with designated initializers, but at least one
test builds it positionally across multiple lines. A new field shifts every
later argument, and the failure surfaces as a confusing conversion error far from
the change (no viable conversion from 'GrooveTemplate' to 'std::optional<DynamicsLane>').
A single-line grep for SequenceInput{ followed by a non-. character will
not find these — the brace is followed by a newline. Use a multiline-aware
search:
find core test tools examples -name '*.cpp' -o -name '*.hpp' | while read -r f; do
perl -0ne 'print "positional: $ARGV\n" if /SequenceInput\{\s*[^.}\s]/' "$f"
done
Note BSD grep has no -P, so a grep -P version of this check silently
reports nothing rather than erroring if stderr is suppressed. Run the full build
regardless: these fail closed at compile time, but only a build over all
targets surfaces them.
OfflineSignalGraphHost will not render a timeline slice. It drives the
no-transport SignalGraph::process() overload by design, so timeline nodes
never receive the transport that note scheduling, automation and PDC read.
It does not fail — it renders silence, which is the expensive way to learn
this.
Use render_timeline_offline() (pulp/host/timeline_offline_renderer.hpp).
Its loop is MasterTransport::begin_block() →
TimelineGraphPlaybackBinding::process(), and it takes a freshly built or
quiesced graph because it prepares the binding and drives its own transport — a
graph already bound to a live transport would be double-driven.
Two gotchas worth knowing before you debug an output that looks almost right:
CompiledTempoMap::ticks_to_samples() saturates rather than trapping,
which is correct for a real-time reader but would silently turn an absurd
region into a plausible bounce here, so the renderer rejects a saturated
derivation instead of using it.WriterCapabilityMask (document_session.hpp) fixes a writer's authority at
registration as a bitmask over (CommandClass, CommandIntent) pairs, and
DocumentSession admits against it inside submit — deliberately inside the
session rather than in a wrapper a caller could route around.
The mask itself is non-destructive by default. The legacy no-argument
register_writer() remains explicitly unrestricted for source-compatible
trusted callers; new agent-facing call sites must pass a mask.
The two offline boundaries no longer take that legacy overload. Both name a
profile from pulp/tools/timeline/writer_profile.hpp instead:
| Profile | Authority | Quota |
|---|---|---|
proposal | every class, no Remove | small, finite |
editor | every class and intent | finite |
trusted | every class and intent | none (SIZE_MAX) |
The MCP boundary defaults to proposal, the CLI to editor, and both accept a
by-name selector (writer_profile on pulp_timeline_project_open and
pulp_timeline_command_apply; --writer-profile on pulp seq apply). An
unrecognized name is a usage error and never falls back to a wider authority.
Two things about that boundary are load-bearing:
command_apply overloads, not
a defaulted one. The std::string_view overload forwards to the
ProjectSource one, so a default on only the latter would have let the
forwarding call supply an authority nobody chose. Requiring it makes the
bypass impossible to write rather than merely discouraged.capability_bit is class_index * kCommandIntentCount + intent, so inserting
a CommandClass renumbers every bit above it; a caller that learned an index
would silently start asserting a different authority. pulp seq capabilities
and the open response therefore report class/intent name pairs, and a refusal
names its conflict_code plus, for a denied authority, the class and intent
it required.A refusal names the command's own declared authority. A container removal also requires its children's classes, so for those the reported pair is the command's own axis and not the exhaustive set admission checked.
Authority follows effects, including effects nested in one command. Complete note replacement requires create/remove authority for its note-ID set difference. Clip, track, and sequence insertion/removal (including cloning and history inverses) also requires the authorities of every identity-bearing child in the carried or current subtree; checking only the aggregate's primary class would launder a denied child operation. Every aggregate removal after another command in the same atomic batch fails closed across its possible child classes, because admission otherwise inspects the pre-batch snapshot while reduction sees the earlier command's result. A granular writer can split the batch when it needs a precise current-subtree decision; an unrestricted trusted writer is unaffected.
The non-obvious half is that gating submit alone leaves the mask bypassable.
Undo applies the recorded inverse of a transaction, and the inverse of a
creation is a removal: a writer denied (Asset, Remove) that could still call
undo() on another writer's CreateAsset would reach exactly the effect the
mask forbids. undo and redo therefore run the same class check on the
history transaction they are about to commit, before touching the redo/undo
stacks so a refusal mutates nothing.
Quotas are the opposite case and are charged only on submit. A quota
bounds what a writer adds to the document; replaying history adds no new
content, and charging it there would let a writer that hit its ceiling become
unable to undo its own work.
Gesture admission must remain closable at the quota boundary. A commandless
End or Cancel is the one empty-transaction exception: after normal
writer/group/revision/transaction-ID validation it closes only the ephemeral
gesture lifecycle, returns the current publication, and is cached for exact
retry. It publishes and journals no document revision, consumes no command ID,
requires no command-class authority, and carries no retained-byte quota charge.
Every other empty transaction that passes the existing
identity/revision/gesture validation still reports EmptyTransaction.
Two smaller traps in the same area:
Transaction has no member retained_size(). The shipped accounting is the
free retained_size(const Transaction&) function in command.hpp; use that
complete envelope-aware estimate for writer budgets. Undo history separately
uses retained_size(std::span<const Command>) because it retains command
payloads without transaction identities or admission metadata.ConflictCode ordinals are a wire surface: tools/mcp emits them verbatim as
numeric_code, and a test pins the ordinal of every existing value. Append
new causes after Unspecified — appending anywhere else renumbers a
shipped code even though the enum still compiles.examples/timeline-sdk-consumer are exact, and Pulp::foundation is in every oneThat example is not a demo; it is the installed-SDK closure gate. Each
_expected_*_closure list is compared with STREQUAL against the closure walked
from the real exported targets, so a target ENTERING or LEAVING the closure fails
it, and the failure surfaces at the consumer's configure step rather than in a
Pulp build.
Pulp::foundation appears in all of them. It is an INTERFACE target over the
header-only Result and queue primitives that Pulp::timebase names in place of
Pulp::runtime, so it adds a name to the closure and no archive to the link.
Every root measured there reaches timebase, so every list carries it.
When a link edge changes anywhere under the engine, expect to update those lists
and the target table in docs/guides/timeline-sdk.md, whose stated counts are
part of the same claim.
Some edges are platform-dependent. Pulp::signal links the muFFT backend
(Pulp::signal-mufft) off Apple when muFFT compiles for the target, so the
engine and importer closures carry it on Linux and Windows and never on Apple
(vDSP). The example derives that one name from whether the installed package
exports it, and fails if an Apple package does; do not add it unconditionally.
MidiContent::create — not the compiler, not a consumer — owns lane-address
well-formedness and uniqueness. A lane whose address exceeds the wire's field
widths, or two lanes claiming one address, cannot be built at all. So a
consumer that re-checks those conditions is writing unreachable code, and a
test that asserts the refusal at the consumer will fail inside its own fixture
builder rather than at the point it thinks it is testing. Assert address
invariants against MidiContent::create and let downstream code assume a lane
it receives is already encodable and unambiguous.
MidiLanePoint::chased distinguishes a value the user placed from one
flattening derived at a retained-window boundary. An authored document never
sets it. It is appended last in the struct precisely so existing positional
brace initialisation keeps compiling — keep it last if you add more.
TrackMixer on a nested track is not equally composable field by fieldA Sequence reached through a SequenceRef is flattened onto the referring
track, so the child track object disappears and only its clips survive. That
makes the two TrackMixer fields behave differently, which is not obvious from
a struct whose members look symmetric:
gain_linear composes. It multiplies into each flattened leaf's
ClipPlaybackProperties::gain_linear, together with the placement clip's own
gain, so authoring a child fader is meaningful — but only over content whose
clip gain a renderer actually reads, which today means media.pan does not compose and cannot. ClipPlaybackProperties has no stereo
placement, and the parent track's single pan also serves whatever else lives
on that track, so a child balance has nowhere to go. Authoring one makes the
nesting refuse.Do not reason about a nested child's mixer as "the mixer either survives or it
does not". Check which field, and for gain check what the leaf content is.
docs/status/sequencer-exposure.json row nested-sequence-gain-composition
records the precedence model and the remaining gaps; the refusal codes live in
CompileErrorCode and each carries an entry in
tools/scripts/negative_capability_allowlist.json.
timeline render no longer calls playback::ArrangementAudioRenderer::process
directly. It builds a device-free graph
(build_device_free_timeline_graph()), prepares a
TimelineGraphPlaybackBinding, and feeds it a silent input block, so the CLI
reaches the same per-track renderer through the node that already wraps it.
What that buys is a path device chains can be added to. What it costs is a
standing obligation: the bounce must stay sample-identical to the direct
renderer. test/test_timeline_agent.cpp holds that oracle in its sample-exact
WithinAbs assertions on rendered PCM. If one of those moves, the render
path changed audio — treat it as a regression, not as a threshold to widen.
The block loop went the same way. The CLI hands the whole render to
render_timeline_offline() rather than driving its own MasterTransport, so
the frame budget it computes has to enter the renderer's tick domain. Carry it
to the smallest tick that covers the budget —
ceil(fractional_samples_to_ticks(frames)) — and reject a derivation that is
not finite or does not fit an int64_t rather than letting a saturating
conversion turn an absurd request into a plausible bounce. Rounding up can only
lengthen the region; rounding down silently shortens the bounce, which is the
one failure a bounce must not have. The in-memory budget check still speaks
frames, and the emitted JSON reports the frames actually rendered rather than
the frames requested.
Two things do not come across by default and have to be carried deliberately:
render_timeline_offline() refuses an empty route span as InvalidProgram,
which is the right answer for a library, so the verb keeps its own early path
that writes a zero-filled buffer. Do not relax the library to accommodate it.TimelineOfflineRenderConfig caps note events per track per block at 256
where TimelineGraphBindingConfig allows 1024, and the renderer copies its
own value into the binding config it builds. Pass the binding's value
explicitly, as the verb does; accepting the renderer's default turns a dense
arrangement into a BindingRejected on a project that used to render.TimelineOfflineRenderCode is the verb's failure vocabulary now, so map every
enumerator to its own message with no default: branch — a default: makes a
newly added code arrive as an existing sentence instead of as a compile error.
A SequenceRef that trims a grooved MIDI child selects over a window widened by
the groove's timing reach, so material just outside a retained edge can still be
chased back inside. Proving that from compiled output is easy to get wrong,
because most notes cannot see the pad at all: the lowerer measures a note's
start from the padded window and the compiler subtracts the pad back off, so
the arithmetic cancels. A note whose duration merely straddles the cut is
selected on overlap whether or not the window was widened, so it reads the same
either way and proves nothing about the pad.
The discriminating probe is a note lying wholly outside the cut — one the
window described by the cut excludes outright. It can reach the output only
through the widened selection, and can sound only if the groove then displaces
it back inside, so its mere presence is a direct reading of the pad. In
trimmed_groove_chase_project that is the note at 452..466 against a cut at
470, which appears under an authored groove and is absent under a feel-free one.
Two consequences for fixtures here. Vary the cut and assert the same sounding ticks across cuts: the useful case is the cut falling to the right of the chased note, since that is the only one where its presence depends on padding rather than on the cut having retained it anyway. And expect the feel-free cases to show the probe absent — a groove that displaces nothing cannot carry it back, and the sounding clamp drops it as zero-length. That absence is the correct reading, not a missing case to chase; see the playback skill's note on why the reach short-circuit cannot be covered.
A Track's four capture-related states divide by whether anything reads them to
replace the arrangement, not by whether they are set. freeze and a valid
active_take_lane_id substitute: the playback lowerer discards the clips and
emits the sealed artifact or the comp instead. record_armed and the
take_lanes list do not — arm is document intent the capture engine reads and
never acts on during lowering, and an unselected lane is inert document data.
So a nested child carrying arm or a dormant lane lowers to exactly the clips a
child without them lowers to, while a nested comped child refuses
(NestedActiveTakeUnsupported) and a nested frozen child refuses
(NestedFrozenTrackUnsupported) unless the nesting transforms nothing at all —
no tick offset, no trimmed window, no gain, fade, fader, pan, modulation,
tuning, groove, dynamics or chord lane, and no sample-rate conversion. Both are
anchored in absolute samples and cannot follow a nesting that moves or cuts the
child, so a transformation-free embedding is the only case where the sealed
artifact is provably still in the right place. The two refusals are narrowed by
one shared predicate and differ only in payload: a freeze lowers to a single
absolute leaf, a comp to one leaf per segment, each resolved against the take
that segment names. If you add a fifth state, the
question to answer is "does anything substitute on this?"
The fixture trap is in the other direction. TakeLane::create imposes no
non-empty-takes requirement, so a lane holding zero takes constructs happily —
and a test that proves dormancy with an empty lane has proved nothing, because
an empty lane is inert for reasons that have nothing to do with selection. Author
a lane with a real Take against a MediaAsset declared in ProjectInput::assets
(Project::create validates the reference exists), leave active_take_lane_id
unset, and the claim becomes real: this lane holds usable media and still changes
nothing. The take needs no decoded audio — nothing resolves a dormant lane to
media, which is precisely the property under test.
Prefer a named state struct over positional bools when a fixture starts
carrying several of these. nested_child_state_project(NestedChildState) reads
as the document it authors, and adding a state later cannot silently re-target
an existing call the way appending another bool parameter can.
test/test_timeline_scale.cpp runs the largest arrangements Pulp supports, so
it is the natural place to reach for a millisecond budget — and the wrong one.
An absolute ceiling measures work / host_throughput, so on a shared or
oversubscribed runner it reports how busy the host was. It is admissible only
where the ceiling sits far enough above the observed time that no plausible
host can reach it; a ceiling within a small multiple of the observed time is a
coin flip, and raising it until it stops flipping deletes the assertion in
slow motion.
test/timeline_perf_test_helpers.hpp carries the two alternatives, shared with
test_timeline_agent_view.cpp:
measure_growth / require_growth_within run one operation at two input
sizes in the same process and assert the exponent k in time ~ size^k.
Host throughput appears in both terms and cancels. This also catches
accidental O(N^2), which a fixed ceiling cannot distinguish from a slow
runner. Growth ceilings are source constants, not workflow env vars, so they
hold in every lane.PULP_PERF_STRICT.Measure growth in processor time, via cpu_now(), never wall time. Wall
time also counts the intervals the operation spent descheduled, and the larger
size is exposed to more of them, so contention biases the exponent upward —
the one direction the assertion cares about. Under heavy CPU contention the
same operations read 1.43-1.51 by wall clock against a 1.40 ceiling and
0.91-1.17 by processor time. Keep measure single-threaded and stateless
between calls, or process time stops being the operation's own time and a
later round measures a warmed cache.
The growth cases run each operation at two sizes for several rounds, so the
suite costs several times a single-size pass — timeline_tests.cmake gives
pulp-test-timeline-scale a correspondingly long TIMEOUT.
ConflictCode; it must never re-decide itdev.pulp.timeline/document-session@1 exposes a mutable DocumentSession
through the Pulp control broker, and the whole design rests on one rule: the
broker reads the authority verdict the session already reached and never reaches
its own. control_timeline_conflict_result_code is a total, one-directional
switch from timeline::ConflictCode onto ControlResultCode —
CapabilityDenied (the CommandAuthority axis) lands on PolicyDenied,
StaleRevision on StateConflict, the quota codes on ResourceExhausted. A
WriterCapabilityMask refusal therefore arrives at the live surface under the
same name the offline CLI and MCP boundaries use, and a test can assert one
verdict from both sides.
The failure mode this forbids is quiet: a broker that consults the mask itself,
or maps a conflict by category rather than by member, becomes a second authority
model. It will agree with the session for a while and then drift on exactly the
case that matters — a newly added ConflictCode, which is a wire ordinal the
session owns. Because the switch is total over the enum, adding a member breaks
the build at the projection rather than silently defaulting; keep it that way
and never add a default: arm to control_timeline_conflict_result_code.
Two more constraints that are not obvious from the session API:
trusted.
control_timeline_admissible_writer_profile admits proposal and editor
and refuses everything else, including trusted, and an unnamed profile
resolves down to proposal rather than to whatever authority the host
itself happens to hold. Selecting the unquotaed profile on a caller's behalf
is the escalation the seam exists to prevent, so this is policy, not a default
worth tidying.registered_writer exposure row must state that profile's exact
quotas. tools/scripts/sequencer_exposure_check.py parses
tools/timeline/src/writer_profile.cpp rather than trusting the ledger, so
authority.bounds has to equal the profile's real
max_transaction_retained_bytes / max_session_retained_bytes, and every
refusal_codes entry has to be a name conflict_code_name emits. Transcribe
neither from memory; read them out of that source.The live operation reaches Forge Sequencer and Forge Modular without any
Forge-side change, because tools/cli/cmd_control.cpp and
tools/mcp/mcp_control_tool_catalog.cpp both walk the registry rather than
enumerating operations by hand — declaring the capability grantable is what
projects it to both surfaces.
examples/timeline-phase1/test_timeline_multitrack_arrangement.cpp runs in
pulp-test-timeline-multitrack-pdc; the phase-1 examples aggregate
(pulp-test-timeline-phase1-examples) compiles the example implementation
but not that test file. Compiling one Catch2 source into two executables
registers every case twice under the same ctest name, and
protected_merge_receipt.py issue refuses an inventory with a duplicated
name, which silently disabled PR-head receipt reuse for weeks. The pr-fast
ctest-unique-names guard now catches it on the PR head.
A compiled timeline test whose sources call PluginSlot::load, fork, or
another process or module API is scanned at configure time
(tools/scripts/script_test_inputs.py). Unless it has an edge to the built
target it loads, or a reviewed pulp_test_spawns(<test> NONE REASON "<why>") in
test/cmake/timeline_tests.cmake, it is spawns: undeclared and a selector
never skips it. The graph-binding suite loads PulpGain.clap only through
PULP_TEST_CLAP_PATH, which the top-level CMakeLists.txt sets together
with the edge in examples builds, so it is NONE only when examples are off.
Get a plugin's path from CMake, never from the working directory.
A timeline test that opens checkout files declares them in the same manifest
with pulp_test_data(<suite> NO_DEFINE PATHS ...): the persistence,
replay-golden, fixture-runner and document-fuzz suites read only
test/fixtures/timeline. A new suite that reads the corpus, or a case that
opens anything else in the tree, must be declared, or the suite reads as
data: undeclared and is never skipped. NO_DEFINE keeps the suite's own
PULP_TIMELINE_FIXTURE_DIR definition.
A program ctest runs directly is declared the same way, under its own target:
timeline-fixture-corpus runs pulp-fixture-runner --corpus <checkout>/test/fixtures/timeline, so the runner carries
pulp_test_data(pulp-fixture-runner NO_DEFINE PATHS test/fixtures/timeline).
Its source names no checkout path (the path arrives as an argument), so no
scan flags it; the nightly read audit is what caught the 41 corpus reads.
TimelineStepSequencerProcessor is about 400 KB. Two or three of them as
locals in one Catch2 case overflow the 1 MB main-thread stack MSVC links by
default, while the 8 MB macOS default hides it; the Windows nightly reported
eight phase1 cases as "Stack overflow". Own each one through
std::make_unique and bind a reference of the old name. Linking
pulp-test-timeline-phase1-examples with -Wl,-stack_size,0x100000 on Apple
makes the required macOS lane fail the same way, so keep that option when
adding cases to the target.
set_parallel_routing_enabled(true) makes the graph start a
GraphRuntimeWorkerPool sized to the core count, and its workers spin at
realtime priority. Two such suites side by side under parallel ctest starve
every normal-priority thread on the machine, which surfaces as a timing
failure in some unrelated suite. Register a suite that enables it (as
pulp-test-timeline-graph-binding and pulp-test-timeline-offline-renderer
do) with PROPERTIES RESOURCE_LOCK pulp_realtime_worker_pool; the
realtime-pool-resource-locks ctest fails a registration that leaves it out.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
73 skills in this plugin
/aaxOptional AAX support for Pulp, including developer-supplied Avid SDK setup, CMake enablement, DigiShell/AAX Validator workflows, and local AAX builds on macOS or Windows./ableton-linkConfigure, implement, and test Pulp's optional desktop Ableton Link tempo-sync adapter while preserving the developer-supplied SDK, licensing, realtime, latency-compensation, and no-install boundaries./agent-capabilitiesMaintain Pulp's installed design-time agent capability manifest and public-surface ledger. Use when adding, removing, renaming, or materially changing public audio, MIDI, signal, timebase, or sequence APIs; registering a new algorithm for generators; changing capability support or deprecation state; or repairing agent-capabilities freshness, schema, fingerprint, tombstone, or installed-SDK tests.npx claudepluginhub generous-corp/pulp --plugin pulpOther plugins' skills for the same job