Repository navigation
feat(domination): finance namespace and FIX UTCTimestamp (FIN-95, #403) - #493
Conversation
Add the finance namespace, with three functions for the FIX UTCTimestamp (YYYYMMDD-HH:MM:SS[.fraction]). - parseFixUtcTimestamp reads a stamp and returns its instant, the precision its digit count states, whether it is a leap second, and the picosecond digits apart from the instant. It returns null for any other width. - formatFixUtcTimestamp writes an instant at a precision, cutting and never rounding. It returns an empty string for a date-time with no offset. - isValidFixUtcTimestamp is true exactly when the parser returns a value. - A seconds field of 60 is accepted only on one of the 27 days a leap second was inserted. The package gains the @northguild/gmt/finance subpaths and a gmt-finance agent skill. The docs site gains a Finance industry, a guide, two scenarios, a mistakes page and the FIX Timestamp Reader tool, with its chat tool. Close FIN-95 in the tracker, fold the spec's decisions into the issue file and delete the spec folders. The bundle budget for the root entry rises from 569,400 to 577,800 bytes. Two shared Dox styles change so the space held for a tool matches the loaded tool.
…x-utc-timestamps # Conflicts: # README.md # apps/dox/src/components/ask/widget-registry.ts # apps/dox/src/data/gmt-stats.json # apps/dox/src/lib/chat-constants.ts # apps/dox/src/lib/dox-tools.ts # apps/dox/src/lib/widget-load-error.test.tsx # apps/dox/src/lib/widget-permalink.ts # apps/dox/worker/tools.ts # packages/gmt/README.md # scripts/bundle-size.budgets.json
|
/craig-review |
There was a problem hiding this comment.
code-reviewer: minor issues
This adds the finance namespace with parseFixUtcTimestamp, formatFixUtcTimestamp and isValidFixUtcTimestamp, plus the FIX Timestamp Reader tool, its docs and the wiring around them. The library code is sound and well tested: truncation, leap-second gating, year limits, picosecond handling and round trips all check out, and the docs examples agree with the code. I found two small problems in the docs-site tool: one refusal reason is worded wrongly for some inputs, and one gate registration may fail on an ambiguous control name. I could not see lib/locate.mjs, utcReading.ts or parseUtcReading, so I assumed those behave as their callers expect.
Reviewed 9375d35 for craig-o-curtis · claude-opus-5-5 · 85 files · $0.86
) The FIX Timestamp Reader said a second 60 fell on a day UTC inserted no second whenever the same stamp with 59 parsed. That was false for a 60 at any minute but 23:59 on one of the 27 insertion days, such as 20161231-23:58:60. A second library probe now moves the stamp to 23:59 on the same day. If that parses, the day did insert a second, and the reason says the 60 is at the wrong time, since UTC inserts one only at 23:59:60. The new sentence joins the reasons the hold reserves space for. It is shorter than the longest, so the reserved box does not change. Raised by craigs-reviewer on #493.
|
The root budget raise to 578900 is approved. #494 changes the same line, so whichever PR merges second merges main, measures again and sets the figure the formula gives. |
|
Thanks. If #494 merges first, I will merge main into this branch, measure the merged root entry with |
craig-o-curtis
left a comment
There was a problem hiding this comment.
Thanks for this one. The finance functions are solid. They follow the FIX UTCTimestamp grammar, accept a second of 60 only at 23:59:60 on the 27 insertion days, never round or widen the precision, and keep the sentinel contract. The FIX Timestamp Reader tool, its registration and the two shared style changes also check out, and the full Dox suite passes at 39ad662. A few things need fixing before I approve. Most are text that no longer matches the code.
To fix
1. Other docs still say only timescale/ and gnss/ accept a second of 60. This PR makes that untrue, and the PR updates gmt-basics, gmt-integration and gmt-timezone but misses these places. They are outside the diff, so I can't comment on them inline:
packages/gmt/skills/gmt-gnss/SKILL.md:70: Every other GMT function rejects:60. This skill ships in the package, so an agent reading it will expectparseFixUtcTimestamp('20161231-23:59:60')to return null.- The JSDoc of
fromTAI,fromTT,fromTCG,fromTai64n,gnssToUtcandgnssWeekToUtc, which say other GMT functions reject a second of 60. packages/gmt/src/recurrence/parse/parseRecurrenceRule.ts:18andpackages/gmt/src/internal/recurrenceRuleText.ts:11-12.context/code-review-checklist.md:18: its list of directories that accept 60 has nofinance/.context/domination/issues/CORE-84.md:67.
Please add the FIX functions in each, worded as in the three skills you updated.
2. apps/dox/worker/tools.test.ts has no showFixTimestampReader case. showTai64nLogReader and showTerrestrialTimeStack each have one. Please add the same few lines, expecting widget: 'fix-timestamp-reader'.
3. apps/dox/scripts/readout-still.mjs has no fix-timestamp-reader entry in its TOOLS list. The tool has readouts next to inputs. grow-measure.mjs and html-diff.mjs already list it. The new holds browser test is a good addition, but the gate should cover the tool too.
4. The section What gmt provides in context/domination/issues/FIN-95.md (lines 108 to 111) doesn't match the code. Nothing calls toNanoseconds, fromNanoseconds, truncateNanoseconds or resolveLocal. The code uses LEAP_SECOND_STEPS and taiOfUtc (internal/leapSeconds.ts), parseUtcReading and secondSixtyWallClock, and isoYearString. Please list those, with the stories they came from, so the Blocked by column built from this section is right too.
The inline comments cover the rest: two checks that can never fail, a duplicated table, three sentences in the context files, and the reason order that 39ad662 changed.
Optional
apps/dox/src/lib/widget-permalink.test.tshas a round-trip case for tai64n but none forfixstamp. The mount test covers the behaviour, so this is only for consistency.- One line in the parser JSDoc saying it reads the FIX Latest widths (3, 6, 9 or 12 digits) would help someone on FIX 4.2 or 4.4, where only whole seconds or
.sssare defined. As written, they might expect.123456to be refused.
What I checked
- Library: grammar edge cases, the 60 rule on every insertion day and on the wrong day, minute and hour, truncation, picosecond padding, annotations, year bounds, and that
isValidis true exactly whenparsereturns a value. All 1,211 finance tests pass, including underTZ=Pacific/Apia. The bundle budget matches the--updateformula, and only the root entry moved. - Dox: all 18,702 tests pass. Lint, format and
astro checkare clean. The Dox gates pass in Chromium and WebKit, apart from the hero-space failure that is already on main. I checked seven seed shapes, keyboard order, and that nothing moves while typing or switching presets at 1440 and 390. The style changes do what you said: the load jump is 0 on dtm-decoder, x12-time-reader and epcis-event-reader, dtm-decoder is 2 px taller and id-timestamp-decoder about 6 px shorter. Firefox was not run locally, so that's left to CI.
|
@baldurpan The hero-space gate ( |
|
@baldurpan Two more for this PR, found while checking the shared style changes. Both are on main already, but please fix them here. The space a tool holds before it loads should match the loaded tool. With JavaScript off (the held space) against loaded, in Chromium and WebKit, light and dark:
Your change brought the load jump to 0 on dtm-decoder, x12-time-reader and epcis-event-reader. These two should get the same. The numbers were the same before and after this PR's style changes, so they don't come from them. |
Answers the four owner questions settled in review of #494. A sender writes ^ only before another populated component (ch. 2 2.6.1.1), and a recipient treats a component not sent as not present (2.6.2). splitHl7Ts now drops every trailing ^ before it splits, so 20240615^D^ reads as 20240615^D and the null value followed by an empty degree reads as kind null. A third component that is not empty (20240615^D^X) still returns null, and so does a degree after the null value. New rows cover both sides in the parse, validate and split tables. The HL7 Timestamp Reader drops the same empty components before it picks the reason under NO SIGNAL, so a third component that is not empty now gets the picture reason, not the degree reason. The hub text and the guide intro now give HL7 International's own claim for version 2, from the HL7 TSC product list, in place of the unsourced most of their records. decisions.md moves the four questions to the settled list, records the approved 581300 B root budget and the rule for #493, and opens one new question: 2.6.2 also says to ignore a component that was not expected, which would read 20240615^D^X as 20240615^D.
Answers the review of #493. Library: - fixPrecisionOfDigits takes only the five counts the FIX pattern matches, and its table is built from FIX_FRACTION_DIGITS, so the two cannot disagree. parseFixUtcTimestamp drops the null check and the empty-instant check that could no longer fire. - fixInstantText writes the instant from the matched digits and drops the year check: the pattern gives a four-digit year. An ordinary stamp now reads in 4.7 µs, down from 16.4 µs; a second 60 in 7.6 µs, down from 23.0 µs. - parseFixUtcTimestamp notes that FIX 4.2 and 4.4 define only whole seconds and three digits, and that it still reads 6, 9 and 12. - The second-60 wording names finance/ with the other readers, in the timescale, gnss and recurrence JSDoc and in the gmt-gnss skill. - The fixUtcTimestamp tests are tables. Dox: - readout-still has a row for the FIX Timestamp Reader. On the first and last stamp preset it types stamps and instants into both boxes and picks every instant preset. The row found a real jump: in WebKit at 1440 px a 64-character stamp grew the read call frame by 20 px. The frame scrolls sideways when a line is too long, and its hold was sampled with a 30-character stamp, so the scrollbar was not reserved. Both call frames are now sampled with 64 characters, the most a box takes, and a mount test checks the samples. - readout-still --resolve-only launched Chromium through a boolean and threw; it now uses launchBrowser. A tool with no chart (frame: false) no longer crashes the snapshot. - New cases: showFixTimestampReader in the worker tests, and the fixstamp permalink round trip. - The tool page and fix-picture give the probe order as it runs. Context: coding-standards, the review checklist, CORE-84, FIN-95 and built.md say the same. The Dox stats are synced.
|
Thanks for the review. 1. The second-60 wording. The FIX functions are now named everywhere you listed. That covers the gmt-gnss skill, and the JSDoc of 2. 3. readout-still. The tool has a row now. On the first and the last stamp preset, it types stamps and instants into both boxes and picks every instant preset. The row found a real jump. In WebKit at 1440 px, a 64-character stamp made the read call frame 20 px taller. The frame scrolls sideways when a line is too long. Its hold was sampled with a 30-character stamp, so no space was kept for the scrollbar. Both call frames are now sampled with 64 characters, the most a box takes. A new mount test checks that the samples are that long. The script itself needed two fixes:
The gate now passes in Chromium and WebKit: 48 drags checked, 0 failed. 4. FIN-95, What gmt provides. It now lists what the code uses:
The code no longer uses The optional points. I did both:
Still to come. The hero-space gate, and the held space of column-timestamp-bridge and id-timestamp-decoder, come in the next push. I will answer those two comments when it is up. Validation at
|
|
/craig-review |
There was a problem hiding this comment.
code-reviewer follow-up: minor issues
Since my last review, the branch simplifies the FIX parser: fixInstantText now writes the instant straight from the matched fields, and fixPrecisionOfDigits is narrowed to the five widths the grammar allows. It also makes the Dox refusal sentence tell a 60 at the wrong minute apart from a 60 on a day with no leap second, and adds the FIX Timestamp Reader to readout-still through typed entries. The library changes look correct, and the new tests pin them against Temporal's own output. The open points are two in the gate wiring and one small style point; none blocks the merge.
Reviewed cbaff76 (changes since 9375d35) for craig-o-curtis · claude-opus-5-5 · 27 files · $0.63
Answers the second round of review on #493. Held space. column-timestamp-bridge and id-timestamp-decoder now hold the same height before they load as after, in Chromium and WebKit, at 1440 and 390 px, light and dark. Three things made them differ: - The calls frame and its output were empty until the library loaded. The template now holds the lines the default preset fills, and a sizer as wide as the widest line, so the scroll track shows just as it does once loaded. DEFAULT_CALLS records both numbers, and a mount test checks them against the real library. - In the format card, inline rows and chips sat in a line box with the hold wrapper's strut, and their block ghosts did not. They are blocks now. - The precision ladder aligned each rung on its baseline. Before load a rung's value is an empty hold, and an empty box's baseline is its bottom edge. The rungs now align to the top. The instant hero's hold now keeps the NO SIGNAL pill too. At 390 px the pill is taller than a line of the instant, so the decoder changed height by 4.4 px between presets. hero-space. checkZoomFills and checkSkyCamera read the globe's pixels. Since #478 the globe hands its canvas to a worker, and getContext then throws. The two checks now remove transferControlToOffscreen first, so the globe draws on the main thread with the same painter. readout-still. A missing frame fails the gate again. Only a row with frame: false skips it. Library. PRECISION_OF_DIGITS is a literal, so nothing runs at import. A test checks that it is FIX_FRACTION_DIGITS the other way round. Its five rows raise the published test count in gmt-stats.json.
|
@craig-o-curtis, both of your comments are answered in 841c809. Held spaceI measured each tool with scripts off (the held space) and with scripts on (the loaded tool), in Chromium and WebKit, at 1440 and 390 px, light and dark. Before this commit the held space was shorter than the loaded tool. At 1440 it was 580 px short on column-timestamp-bridge and 144 px short on id-timestamp-decoder, the same as your figures. After it, held minus loaded is 0 px in all 40 cells: column-timestamp-bridge, id-timestamp-decoder, dtm-decoder, fix-timestamp-reader and database-timestamp-reader, each in 2 browsers, 2 widths and 2 themes. Three things made the held space differ:
The 4.4 px between decoder presets at 390 came from the NO SIGNAL pill. At that width the pill is taller than a line of the instant, and the value's hold did not keep it. It does now: the hero is 1428.7 px in Chromium and 1532.5 px in WebKit for every preset. One difference between presets is still there, and was there before this pull request. The three Snowflake presets run a fifth call, hero-spaceI ran it on the merged tree. Two checks failed: Both checks read the globe's pixels. Since #478 the globe hands its canvas to a worker with Result: This gate is local only ( Validation
|
craig-o-curtis
left a comment
There was a problem hiding this comment.
Approving. Thanks for the thorough fixes. Every inline thread is answered, and the rewritten fixInstantText gives the same result as before on every stamp I tried, about 21,000 of them, including all 27 leap-second days at 0 to 12 fraction digits and years 0000 and 9999.
A few text spots still say only timescale/ and gnss/ read a second of 60. Please fix them before you merge:
apps/dox/src/content/docs/guides/industries/finance-message-timestamps.mdx:215-216says the instant reads back throughtimescale/, which are the ones that accept a second of 60. TheformatFixUtcTimestampexample three lines above accepts one, so the page contradicts itself.apps/dox/src/content/docs/guides/industries/gnss-system-time-and-week-rollover.mdx:82: Only the functions of this layer and oftimescale/read a result with a second of 60. That is no longer true.packages/gmt/src/finance/parse/parseFixUtcTimestamp.ts:37-38says the instant is read back byformatFixUtcTimestamp,toTAIandisLeapSecond, and that other GMT functions refuse it.toTT,toTCG,toTai64n,utcToGnssand others read it too. Suggest the wording intypes/fix.ts:35: only thetimescale/,gnss/andfinance/functions read it back.- Older, but the same claim:
guides/core-date-operations/leap-seconds-and-tai.mdx:100-101andcontext/domination/issues/MAR-16.md:81say every other function rejects a second of 60.
Closes #403 (FIN-95).
Summary
This adds a
financenamespace to@northguild/gmt, starting with the FIXUTCTimestamp(YYYYMMDD-HH:MM:SS[.fraction]). A FIX stamp states its precision by how many fraction digits it has, and its seconds field can read60on a day a leap second was inserted. The new functions read and write the stamp without losing either fact. The docs site gains a Finance industry, a guide and the FIX Timestamp Reader tool.What changes
1. Library:
@northguild/gmt/financeNew subpaths
/parse,/formatand/validate.parseFixUtcTimestamp(value)returns{ instant, precision, leapSecond, picoseconds }, ornull. The precision comes from the number of fraction digits (none, 3, 6, 9 or 12) and is never widened. Digits 10 to 12 of a picosecond stamp come back inpicoseconds, so nothing is dropped without saying so.formatFixUtcTimestamp(instant, precision)writes an instant in UTC at the precision a counterparty asks for. It cuts and never rounds, and"picosecond"pads000. It returns""for a date-time with no offset.isValidFixUtcTimestamp(value)is true exactly when the parser returns a value. It takes any value and narrows it tostring. This replaces the issue'svalue: stringsignature with the usual overload trio.60is accepted only on the 27 days a leap second was inserted. It reads back as23:59:60.package.jsonexports andtypesVersions, the noThrow fuzz list, and a scoped exception for finance message grammars incontext/coding-standards.md. FIN-96 builds into the same realm.2. Agent skill
gmt-financeTanStack Intent skill, listed in the skills registry, the vocabulary the docs chat reads, and the install and skills pages.3. Docs site
finance-message-timestamps), two scenarios and a mistakes page.4. Bookkeeping
@northguild/gmt.issues/FIN-95.md,issues/FIN-95/design-notes.mdandcontext/dox/built.md, and deleted. The painpoints row now cites FIN-95 and FIN-96.5. Merge with main
origin/mainis merged in. It brings SPA-47 (the Terrestrial Time Stack tool, #489) and the #480 gate fixes (#486). Both new tools sat at the same place in six registration files, and each file now keeps both. InDOX_TOOL_DOCSthe Terrestrial Time Stack keeps index 43, and the FIX Timestamp Reader follows at 44. The function count, test figures, reference corpus and the root bundle budget are regenerated for the merged tree.Why
FIX engines send
SendingTimeandTransactTimeat whatever precision they support, and a reader that guesses the precision, rounds, or rejects23:59:60gets a different instant from the one that was sent. The functions keep the precision and the leap second, so a stamp can be checked and written back the same way.For the owner to check
scripts/bundle-size.budgets.jsonrises from 570,400 to 578,900 bytes. The merged root entry is 573,092 bytes, and 578,900 is that times 1.01, rounded up to the next 100, which is the--updateformula. No other budget changes. Please confirm it..pilland.chipare now block and fit-content..frameGhosthas a 1px margin.Known, and already there before this story
Left to CI
Validation
pnpm validateon the merged tree, against origin/main: 23 of 23 checks pass (format, deps, markers, licences, docs-check, bundle-size, the builds, dox-pages, stats, compat, upstream, api-surface, dox-tables, lint, typecheck and test).node scripts/bundle-size.mjs: the root entry is 573,092 bytes, under its 578,900 budget. Every other entry is under its budget too.Release
One minor changeset for
@northguild/gmt:.changeset/finance-fix-utc-timestamp.md. Merging publishes nothing.Checks
pnpm changeset.pnpm run validatepasses.