Repository navigation
Feature/wdb module - #137
Conversation
…es; idb writedown-mode port wdb: - all four writedown modes (default, partbyattr, partbyenum, partbyfirstchar) and the end-of-day merge (part, col, hybrid) via di.merge - modes saveandsort, save and sort; proctypes sort and sortworker run this module with settings/sort.q and settings/sortworker.q, as legacy loads wdb.q for both - end-of-day sort, move to hdb, reloads and sortworker peach ported from legacy wdb.q; workers setting stands in for -s -N - legacy upd (insert, configurable), movetohdb, clearwdbdata, manipulate, reloadproc helpers; filesystem calls through di.os; sort.csv defaults to $TORQXAPPCONFIG/sort.csv - publishes .wdb.writedownmode for the idb idb: mounts savedir or savedir/<partition> by writedown mode, as legacy; loadsym/loadidb/ loaddb, partitioncounthaschanged, clearrowcountcache, maptoint/mapfctoint at root. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- astimespan reads a string of digits as seconds, like a number ("N"$ read it as hours)
- sortparams: an empty sort config table when none is loaded, so the partitioned-mode
sort.csv checks log instead of throwing 'type
- movetohdb creates the hdb root before the move
- setroot defines .u.end with set, not as a root key named `.u.end
- flushend flushes the reloaded processes' handles, not the keyed table's rows
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
DIReview Summary1 critical | 5 warning(s) | 3 suggestion(s)
Suggestions
|
Resolve the builtin process-type registry conflict as a union: keep the branch's sort/sortworker entries and main's discovery entry. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…he suite di.subscriptions now requires a handlers dep, so wdb's init failed for every caller that did not pass one. A sort-mode wdb never subscribes - .z.m.subs is only read on the save path - so move the init below the sort-mode early return rather than widen wdb's required deps. Test fixture: - add a handlers mock to test.csv and test.q, needed on the save path - eodok/feedok took the sym column with `value`, which resolves symbols as variable names. select resolves the on-disk enum once the sym domain is loaded, so with sortworker peers the column arrives as plain symbols and the check threw 'aapl. Take the column as-is; distinct/differ handle both types. Suite goes from 7 failures to 71/71. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
tabsizes (wdb.q:62, wdb.q:122): tablelist[] orders by bytes from tabsizes, but only savetables populated it - savetablesbypart tracked partsizes instead. In a partitioned writedown every table therefore ordered on zero bytes and the largest was not flushed first. Track it in savetablesbypart too, and clear it at end of day in every mode, not just the default one. informgateway (wdb.q:229): an absent gateway is a normal deployment, and informgateway runs on every end-of-day reload, so it logged an error each time. Log it at info. movetohdb (wdb.q:381): the per-table branch logged each failed move and carried on, leaving tables split across the wdb and the hdb with no rollback and no signal. A multi-table move cannot be made atomic, so fail on the first error the way savetables does, and report a source directory left non-empty. Tests: tabsizestracked, tabsizescleared and nogatewayquiet - each verified to fail without the corresponding fix. Suite 74/74. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Checked the module against TorQ 5.2.19 code/processes/wdb.q, code/wdb/{origstartup,
writedown}.q, code/common/merge.q and config/settings/{wdb,sort,sortworker}.q.
endofperiod: legacy defined a log-only stub in code/wdb/writedown.q and the port
dropped it as STP-only. di.torq.proc.segmentedtp now exists and broadcasts end of
period through di.pubsub.callendofperiod, which sends the (current;next;data)
triple as ONE argument, so a subscriber without the callback fails the publish.
Define it at root, monadic.
getpartition: legacy exposed it as an overridable setting so a deployment could
decide its own partition value; the port hard-coded it. Read it from config,
defaulting to the built-in - the same pattern upd and savedownmanipulation use.
Tests: getpartitionoverride and endofperiodcallback, both verified to fail
without the fix. Suite 76/76.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… in the wdb The callback has to exist in the process that RECEIVES the publish. di.pubsub is the publisher half - it runs in the tickerplant and the wdb never loads it - so the default belongs with the subscriber half, which already owns root upd and the root table schemas. One place covers di.torq.proc.wdb, di.torq.proc.rdb and di.torq.proc.chainedtp; rdb had the same latent failure. Installed only when root endofperiod is not already defined, the rule chainedtp uses for upd, so a subscriber that forwards the roll downstream keeps its own. Tests: endofperioddefault (verified to fail without the install) and endofperiodnotclobbered. The wdb's endofperiodcallback now covers the same path through di.subscriptions. Suites 47/47 and 76/76. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Dropped from this PR entirely: di/subscriptions is back to main, and the wdb keeps the stub stripped as the original port had it. upstream/feature-segmentedtp already defines endofperiod in both the rdb and the wdb, and that branch is where the segmented tickerplant work belongs. Two PRs editing di/subscriptions at once would only collide. getpartition and the review fixes are unaffected. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
# Conflicts: # di/torq/torq.q
DIReview Summary1 critical | 10 warning(s) | 3 suggestion(s)
Suggestions
|
DIReview Summary0 critical | 3 warning(s) | 1 suggestion(s)
Suggestions
|
di/email/manual_tests.q was swept in by a `git add -A` and has nothing to do with this PR. Removed from the branch; it stays on disk for the email work. idb: the port changed the sym-load error from `1_string` to `string`, so the path printed with its leading colon. Restored, and applied to the other three path log lines in the file so they agree. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
StatusPicked this up as the original author has moved to another project. Merge conflict resolved. Suites green: wdb 75/75 (was 7 failing), idb 117/117, torq 72/72, plus chainedtp, subscriptions, merge, handlers, servers, rdb, hdb and tickerplant unchanged. Changes on top of the original work
Review threadsAll 20 replied to and resolved. Of the substantive findings, 6 were real and are fixed; the rest did not reproduce. Worth flagging for whoever reads the bot's output next: the finding labelled critical ( Correction to my own earlier replies. Twelve of the resolved threads say
No issues raised against Why the out-of-scope comments appearedAn earlier push carried a malformed merge commit: it held the merged file content but had not recorded |
|
I tried running the tests for wdb and got some unusual results TL;DR the first time I ran it it threw some errors but said all tests passed, but the second time it also threw errors but showed a lot of tests failing. Could you check if this is expected? |
|
Btw I ran against this feature branch |
testsort.q creates a root table `scalls` to record mock server calls, and it is still there when the suite finishes. tablelist[] returns every root table except the ignorelist, so a second moduletest in the same process tried to write down `scalls` - which has no sym column - and the partitioned writedown tests threw 'length. `calls` was already in the ignorelist for exactly this reason; add `scalls`. Reported by Eoghan: a second run in the same q session failed ~19 checks. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
emptypartition[] asks for a partition that was never written, so the mv fails - that is the point of the check. mv writes to stderr, which q does not capture, so the suite printed "mv: cannot stat ..." on every run and read as a problem. Run that one call with di.os's swappable syscall wrapped to drop stderr, and restore it afterwards. The module's own error log still fires, which is what the check asserts, and a real shell error anywhere else is still printed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
DIReview Summary1 critical | 0 warning(s) | 0 suggestion(s)
|
The first version trapped f and returned the error as a value, so a genuine failure inside the silenced call no longer reached the suite - the bare call it replaced would have raised it. Restore the syscall, then re-signal. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
DIReview Summary1 critical | 0 warning(s) | 0 suggestion(s)
|
|
hey Eoghan, thanks for catching this. The initial run where all tests passed but there was the message mv: cannot stat '/tmp/di_sort_k4unit/wdb/2026.01.15' is expected. The emptypartition[] test asks for a partition that doesn't exist to prove the failure is logged rather than thrown The rerun failures are a fixture leak. testsort.q creates a root table scalls for its mock server calls and leaves it behind. the wdb's tablelist[] treats every root table as data to write down, so on a second run it tries to write scalls which has no sym column and the partitioned writedown tests throw 'length. The calls root table was already in the ignorelist for the same reason, but scalls wasn't made the fix to add scalls to the ignorelist, and silenced the shell for the move failure so the mv message doesn't appear and the second run is clean now |
There was a problem hiding this comment.
Looks good to me, but I asked Claude to check if any functionality had been lost when porting over, and it came back with the below blurb.
TL;DR mostly ok but could you take a look at the first 2 in "Not documented":
Nothing core has been lost. Every piece of TorQ's wdb.q, wdb/writedown.q, wdb/origstartup.q and idb.q has a counterpart in the PR. That includes all four writedown modes, all three merge methods, sort-worker peach, fixpartition, initmissingtables, the eodwaittime reload handshake, the idb rollover/intradayreload, and maptoint/mapfctoint. Some behaviour has narrowed, though. The first three items below aren't covered in the docs.
PR #137's head is the same commit as your local feature/wdb-module (9c2f687). I compared it against TorQ origin/master (7e77714a). I read the code but didn't run anything.
Not documented
reloadorderonly works for hdb, rdb and idb types now. TorQ called rootreloadon any proctype inreloadorder.reloadexpronly recogniseshdbtypes,rdbtypesandidbtypes. Anything else is skipped with a warning (wdb.q:491), so a custom proctype inreloadorderno longer gets reloaded at end of day.- The
endofperiodstub is gone, but the module STP still sends it. wdb.md:202 lists it as deprecated. However, segmentedtp.q:447 callscallendofperiodon every period roll, and that sends(endofperiod;x)to all subscribers. A wdb subscribed to an STP will get an undefined-function error every period. TorQ's one-line logging stub inwritedown.q` was what stopped that. No data is lost, but either keep the stub or stop the STP sending it. - The default
numtabchanged. TorQ defaulted to`quote`trade!10000 50000. The module defaults to an empty dict (wdb.q:622), so quote and trade now flush at 100k rows instead of 10k/50k. This is odd becausemergenumtabkept the TorQ default.
Small config gaps
.merge.partlimit(TorQ setting, default 1000) isn't passed todi.mergeinit(wdb.q:685), so it can't be changed from the wdb config.settimeris now a number of seconds rather than a timespan. A TorQ-style value such as0D00:00:10makestolongthrow.- Several TorQ setting names were renamed or dropped:
subtabs,subsyms,replay,tpconnsleepintv,tpcheckcyclesandschema. A ported TorQ settings file that uses them is ignored without any warning.
Documented or deliberate
- Startup waits are now bounded. TorQ retried the tickerplant (wdb) or wdb (idb) forever. The module fails
initaftertpwaittimeout/connecttimeoutms(30s). TorQ's idb also logged and kept running when no wdb was found; the module throws. movetohdbstops at the first table that fails to move. TorQ logged the failure and carried on with the rest. Dexter made this change on purpose in562d159. The outer error trap still letspostreplayanddoreloadrun, so the hdb reloads with a partition split between the wdb and the hdb, which is the same situation as before.- IDB: registering with the wdb (
.servers.registerfromdiscovery),.proc.getattributesand the rootreloadalias are all listed under "Not ported" in idb.md:78-85.getattributesis the one that will matter once the gateway routes on attributes. - Also dropped: FinSpace/AWS support, the
schema:0boption (the schema always comes fromsubdetails), and the startup log lines describing the partition layout. The gateway is now told about reloads with an async(.gw.reload;msg)instead of TorQ's syncreloadstart[]call, which matchesdi.torq.proc.gateway`.
I'd fix 1 and 2 before merging, and either restore the old numtab default or document the new one.
…default From Eoghan's port-parity review on PR #137. All three narrowings confirmed against TorQ 5.2.19 before changing anything. reloadorder: TorQ's reloadfunc called root `reload` on whatever proctype was listed (code/processes/wdb.q, `. `reload x). reloadexpr only recognised hdbtypes, rdbtypes and idbtypes and returned (::) for anything else, which getprocs skipped with a warning, so a custom proctype in reloadorder was never reloaded. The default branch is now legacy's root `reload` - which is exactly what the rdb branch already did, so that branch collapses into it - and the dead (::) guard is gone. customreload[] proves it with a real connected peer of a custom proctype; it fails without this change. endofperiod: legacy shipped a logging stub in code/wdb/writedown.q. di.pubsub.callendofperiod broadcasts (`endofperiod;(current;next;data)) to every subscriber on each period roll, so without the stub a wdb pointed at a segmented tickerplant raises 'endofperiod every period. Restored and published at root. Note it is monadic, matching callendofperiod, which sends the triple as one argument - legacy's three-parameter stub would have been applied to one argument and silently become a projection. numtab: legacy defaults to `quote`trade!10000 50000 (writedown.q), the module defaulted to an empty dict, so quote and trade flushed at numrows instead of 10k/50k. mergenumtab had kept the legacy default, so the two disagreed. Restored. The test fixture now pins numtab/replaynumtab empty, since those tests want numrows to govern, and numtabdefault[] covers the shipped default. Also from the same review: partlimit is now passed through to di.merge init when configured (omitted, di.merge keeps its own default of 1000), and wdb.md gains a migration section for the TorQ settings that were renamed or dropped (subtabs, subsyms, replay, tpconnsleepintv/tpcheckcycles, schema) plus the settimer seconds-not-timespan change, which were silently ignored before. Suite is 79 checks, green, and clean on a second run in the same process. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
DIReview Summary0 critical | 2 warning(s) | 0 suggestion(s)
|
|
Thanks Eoghan, this was a genuinely useful pass — all three of the "Not documented" items reproduced, and I've fixed all three in 1. reloadexpr:{[ptype]
$[ptype in .z.m.hdbtypes;{[d] .hdb.reload[]};
ptype in .z.m.idbtypes;{[d] .idb.intradayreload[]};
{[d] `. [`reload] d}]
}
2. One thing worth flagging, because porting legacy verbatim would not have worked: the stub has to be monadic here. That leaves a coupling on the segmentedtp rebuild: that branch keeps 3. Small config gaps:
Docs: Suite is 79 checks, green, and still clean on a second Nothing done on the "Documented or deliberate" list — agreed those are either intentional or already written down. |
…e's default From the second DIReview pass on PR #137. The numtab point is fair: main ships wdb 0.2.0, which defaults numtab to an empty dictionary, so merging this changes flush thresholds for quote and trade on any config without a numtab key. wdb.md now carries an explicit "Upgrading from 0.2.0" note with the way to keep the old behaviour. The accompanying claim that the test fixture diverging from production is a footgun does not hold - pinning a config value is what makes those tests deterministic, and numtabdefault[] asserts the shipped default directly. On partlimit the review suggested resolving the default in the wdb and always passing it. That is the thing that drifts: it would put the number 1000 in two modules. Fixed the other way instead - di.merge owns the default, wdb.md no longer restates it, and the test asserts the fallback against di.merge's own partlimitdefault rather than a literal. Suite is 79 checks, green, clean on a second run in the same process. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…142 Audited the module against the definition-of-done checklist in the torq-module-extraction skill (PR #142, still open). Three items did not hold. Line length: style.md caps lines at 150 characters. Twelve lines were over, eleven of them introduced by this branch. All are long log messages or chained calls, now split. No behaviour change; the suite is unchanged at 79 green before the new test below. init idempotency: the checklist asks that init be idempotent where it registers anything. It registers a timer job, and di.timer raises on an id that already exists (init.q:31), so a second init threw. Fixed with the delete-then-add the end of day path already uses for sortflushend, rather than introducing a registered flag - same outcome, consistent with the surrounding code, no extra state. This needed a test to be worth anything. The fixture's timer mock is a pair of no-op lambdas and never detected a duplicate, so initidempotent[] installs a mock that mirrors di.timer and calls init twice. Removing the guard makes it fail. deps validation: a non-dict deps reached `key deps` and raised a bare 'type rather than saying what was wrong. init now checks the type first and names what it wants, which is the pattern the skill gives and what di.email already did. Left alone deliberately: the two direct .z.* assignments, .z.zd for compression and .z.pd for the sort workers. That rule is about event handlers going through the injected handlers dependency; neither of these is an event handler and no contract covers them. Suite is 80 checks, green, and clean on a second run in the same process. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
DIReview Summary0 critical | 1 warning(s) | 0 suggestion(s)
|
- #141 (toml retry/pubinterval): already carried here; keep this branch's versions, plus main's servers.md wording. - torq.q builtin dict: main's sort/sortworker plus tickerlogreplay/segmentedchainedtp. - wdb.q: main's full port, with this branch's subscription path reapplied: .sub.subscribe via .sub.getsubscriptionhandles, fixpartition on sd`d (skipped on re-init, when .sub.subscribe returns ()), root endofday dyadic for the segmented tickerplant, triadic endofperiod stub, .u.end unchanged. - wdb tests: fake tickerplant answers as a segmented one, found through a real di.torq.servers; config merges settings/default.q; freshwdb clears .sub.SUBSCRIPTIONS; end of day driven through .u.end; endofperiodstub sends three arguments. No expected values changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No description provided.