# Quote Term Calendar Primitives — Performance Learned

## 2026-08-25 — PRs NexusCRM#4616 / nexuscrm-pingcap-pack#5460

- Candidate lineage: Core main `0609060d837c97f7c7fa67268a961a251268eff1`,
  app packs `e5bbdb39b69168e66777361a98da7f693f1c3b9c`, and the L2 Quote
  change merged by `41076ab92a9db8ca82a020d79083f545aa71f8c3`.
- Environment/workload: the Test2 full-inspection Quote path, where the
  QuoteLineItem before-save Flow and active Quote formula evaluate the shared
  service-window term function.
- Baseline: the expanded calendar body compiled from 2,176 source bytes to
  3,223 SQL bytes with 42 field-reference occurrences and used seven Flow
  formula resources.
- Candidate: the pack-owned function body compiles from 70 source bytes to 835
  SQL bytes with 16 field-reference occurrences and one Flow formula resource.
- Core runtime evidence: target-clamp median 654.1 ns/op, 480 B and 7
  allocations; day difference median 635.1 ns/op, 456 B and 6 allocations.
  The SQL DATE range parity guard added no allocations and did not change the
  835-byte emitted SQL.
- Correctness evidence: real TiDB active/frozen parity passed ordinary dates,
  year 0999, the year-1 lower boundary, and the year-9999 upper boundary. The
  final L2 pack builder, metadata audit, historical tuple validator, and eight
  Quote contract/semantics tests passed.
- Next evidence: after the Core commit is merged and final-pack lineage is
  regenerated through a follow-up PR, run the same Test2 full inspection and record
  stage timings against the prior successful Test2 baseline. Local/compiled
  evidence predicts the improvement; Test2 remains the end-to-end proof.
