Files
effectcraft/CLAUDE.md
T
Dylan M. Taylor f6ef1a7906 Use chrono instead of hand-rolled UTC conversion (#2023)
* Use chrono for UTC/calendar conversion instead of hand-rolled copies

Replaces the hand-rolled civil_from_days / days_from_civil copies (log
timestamp, ISO metadata dates, Align Video to Data timestamp parsing, the
Numbers effect's date, the Home and Render Queue date columns, and the
benchmark report date) with chrono as a workspace dependency. Output formats
are unchanged and pinned by the existing tests. AGENTS.md now says time goes
through chrono.

Follow-up to storytold/cadcraft#1785

* Keep 5-digit years unprefixed; derive Numbers weekday from the same date

chrono's %Y writes a '+' before years past 9999, where the old code wrote
{y:04}. timestamp, iso_date, format_utc, utc_stamp and xtask's utc now write
the year with {:04} again and let chrono format the rest, so a far-future
clock keeps the plain zero-padded year.

date_from_days took its weekday from the raw input modulo while the
year/month/day fell back to the epoch for day counts outside chrono's range,
so an unrepresentable count printed a fallback date paired with the input's
weekday. The weekday now comes from the same resolved date, so both agree.

Tests cover the year-10000 timestamp and the out-of-range Numbers date.

* Keep the whole date in format_ago for five-digit years

format_ago cut format_utc to 10 bytes, so a year past 9999 lost its last
digit (10000-01-0). Take the date up to the space instead. Tested.

* Keep Numbers dates exact past chrono's range

date_from_days converted the day count by building a Unix timestamp and
calling DateTime::from_timestamp, which falls back to the epoch (and so
reads 1970-01-01, a Thursday) once the date leaves chrono's NaiveDate
range near year ±262143. Numbers' `value` slider is a plain scalar with
no range guard, so a keyframed count reaches that: Long Date of
100_000_000 showed "Thursday, January 1, 1970" instead of the real
"Monday, September 13, 275790" -- exactly the plausible unrelated-date
fallback the review rejects, and the derived weekday matched the stand-in
date, not the input.

Route it through the 400-year Gregorian cycle like pdfcraft 9d4cb3ca:
chrono converts the day within one cycle (num_days_from_ce of the rebased
rest, always in range) and the whole cycles are added back as years, in
i128 so i64::MIN/MAX can't overflow. chrono stays the only calendar
logic. The weekday still comes from the resolved date, so it always
agrees with it.

Tested: date_from_days_past_chrono_range pins the pre-chrono dates and
weekdays at/over chrono's bound on both sides of the 2000-01-01 epoch
(and that the extremes don't overflow); numbers_formats adds the same
through the public numbers_text entry (Long/Short Date). cargo test
-p effectcraft-effects, fmt --check and clippy -D warnings all clean.

* time: preserve out-of-range years instead of the epoch

`DateTime::from_timestamp(..).unwrap_or_default()` changed the existing output:
inputs the old hand-rolled civil-from-days converted (e.g. `10_000_000_000_000`
s → 318857-05-20 17:46:40) collapsed to the epoch. Restore the old conversion
domain with a cycle-based helper: reduce by whole 400-year Gregorian cycles
(146_097 days), convert the in-range remainder with chrono, and carry the year
back as i128 (saturating to the output type). Only the year leaves chrono's
range; month, day and time of day stay exact. chrono remains the only calendar
logic (NaiveDate::from_num_days_from_ce_opt); no new features.

Sites (UTC):
- crates/engine logging.rs `timestamp` (u64 ms): far-future clock keeps its year.
  10e12 s → "318857-05-20T17:46:40.000Z", u64::MAX ms → "584556019-04-03T14:25:51.615Z"
  (was "1970-01-01...").
- crates/engine media_browser.rs `iso_date` (u64): 10e12 s → "318857-05-20T17:46:40Z",
  u64::MAX → "584554051223-11-09T07:00:15Z".
- crates/ui-egui panels/home.rs `format_utc` (i64): 10e12 → "318857-05-20 17:46",
  i64::MIN → "-292277022657-01-27 08:29".
- crates/ui-egui panels/render_queue.rs `utc_stamp` (u64): 10e12 → "318857-05-20
  17:46:40", u64::MAX → "584554051223-11-09 07:00:15".
- xtask bench.rs `utc` (u64): 10e12 → "318857-05-20 17:46 UTC", u64::MAX →
  "584554051223-11-09 07:00 UTC"; added a test.

* Name the 400-year range extension as the one exception to the time rule

The rule said never to hand-roll calendar math, but the range fix
(shifting by whole 400-year Gregorian cycles so dates past chrono's year
range keep their old output) is cycle arithmetic, so the rule and the code
disagreed. The rule now names that exception: the library still computes
month, day and time, and only whole cycles are carried in the year.

* Say the library computes month and day; time-of-day is plain arithmetic

Narrows the range-extension wording: the date library computes the
calendar fields, and splitting seconds into hours, minutes and seconds
is ordinary arithmetic, which is what the code does.
2026-10-23 11:29:09 -04:00

4.9 KiB
Raw Blame History

EffectCraft — instructions for agents

EffectCraft is a clean-room, open-source, pure-Rust motion graphics and visual effects compositor targeting Adobe After Effects parity (and beyond). Native on macOS, Windows, Linux; web via WASM. Sibling of ../photocraft (Photoshop), ../pdfcraft (Acrobat), ../vectorcraft (Illustrator), ../filmcraft (Premiere), ../lightcraft (Lightroom) and ../designcraft (InDesign), with the same conventions.

Start every session here

plan/ is maintainer-local (gitignored). Public equivalents: ROADMAP.md, docs/.

  1. Read plan/STATUS.md (current milestone, next task, running agents, blockers).
  2. Read the task in plan/execution-plan.md §3, the relevant section of plan/architecture.md, and the crate README/docs you touch. Feature ids: plan/aftereffects/feature-catalog.md; effects: plan/aftereffects/effects-list.md; UI reference: plan/aftereffects/README.md.
  3. Read docs/gaps.md: every known shortfall, ranked, and the prioritised workstreams; the numbers are in docs/target-app-parity.md. Fidelity, reliability and stability (G1–G3) come before new features.
  4. Follow the autonomous operation protocol (plan/execution-plan.md §7). Don't stop to ask.

Non-negotiables

Read AGENTS.md first; its rules override everything here. No Adobe assets, every asset licensed + attributed (cargo xtask assets).

  • Never crash (AGENTS.md "Never crash"; outranks feature work: a crash loses people's work). Non-test code has no unwrap()/expect()/panic!/unreachable!/todo!/unimplemented! and no unsafe: return Result and use ?, ok_or, let … else. Input-derived indices, slices and arithmetic use get() and checked/saturating math; recursion is depth-limited; locks handle poisoning. The app's last-resort guard turns an escaped panic into an error and keeps the document. Every crash fix gets a regression test. Standard: craftrules standards/never-crash.md.
  • Clean-room. Behaviour and public docs only. No GPL/LGPL/AGPL code. ffmpeg only as an external test oracle.
  • Pure Rust. Media codecs come from FilmCraft crates (git deps behind crates/media, see plan/adr/0001).
  • Layering (cargo xtask layers): nothing below L5 depends on egui/eframe/winit/rfd/cpal; L0–L4 build for wasm32.
  • Exact time: effectcraft_time::Tick (254 016 000 000/s). Keyframe times are layer time.
  • Time goes through chrono (workspace dependency). Never hand-roll UTC/calendar conversion (days-to-date algorithms, leap-year math); a crate owns only its output format string. The one exception is range extension: past the years chrono can represent, shift the date by whole 400-year Gregorian cycles (146,097 days, after which the calendar repeats), let chrono compute the month and day, and add the cycles back to the year (splitting seconds into hours, minutes and seconds is plain arithmetic).
  • Property tree: everything animatable is a Property in the layer's PropGroup tree, addressed by paths (transform/position, effects/#1/blurriness, @uid).
  • Everything is a command (crates/engine): id, label, menu path, shortcut, params, enabled(), run(). UI, CLI, control channel and MCP dispatch by id.
  • Everything is agent-drivable: every interactive widget registers an automation id; UI state is serde.
  • Community links (Help menu, About, header Discord button): https://discord.gg/artcraft, https://getartcraft.com, https://getartcraft.com/apps/effectcraft, https://github.com/storytold/effectcraft.
  • Quality gates before every commit: cargo xtask ci (fmt, clippy -D warnings, tests, layers, assets, wasm).
  • Commits: one task id per commit (M6.3: trim paths). Only green states.

Running and looking at the app

  • cargo run -p effectcraft -- --control 9877 opens the desktop app with the JSON-lines control server (docs/control-protocol.md).
  • For UI work, look at the result. Headless (no window, works while the user is busy on the machine): cargo run -p effectcraft-ui-egui --example snapshot -- --out ui.png --step '{"method":"engine.execute","params":{"command":"layer.select","params":{"layers":["#2"]}}}' (steps are control-channel requests; --script steps.jsonl; {"method":"snap","params":{"path":…}} for intermediate shots). Or drive the live app via the control channel and take ui.screenshot (needs the window visible on screen).
  • After Effects reference: drive AE via ExtendScript (osascript -e 'tell application "Adobe After Effects 2026" to DoScriptFile "x.jsx"') and capture only AE's window (screencapture -l <windowid>); keep captures in plan/aftereffects/ref/ (gitignored), never commit them, never capture the Home screen.
  • Parallel agents: separate git worktrees and CARGO_TARGET_DIR=target/agent-<name>; keep every Cargo.toml valid (the crates/* glob).