Repository navigation
di.torq.proc.compression: one-shot hdb compression process type - #149
Conversation
The module shipped without one, so depcheck reports any module declaring a dependency on it as "has no VERSION file" and fails the pre-load version graph. di.torq.proc.compression needs to declare that dependency. 0.1.0 - a first stamp for the module as it stands, not a behaviour change. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Ports TorQ's code/processes/compression.q and config/settings/compression.q. The compression engine itself was already ported as di.compression; this is the process wrapper around it - config resolution, hdb path validation and the one-shot lifecycle - plus the framework settings tier and an entry in di.torq's built-in proctype registry, without which the proctype cannot start at all. The pass runs from di.torq's runhook as .compression.run[], not from init: init must not exit, since torqx.sh owns the process lifecycle. Keeping the pass in its own .compression.compressnow[] leaves it re-triggerable over IPC without terminating the process - the same split di.torq's sample loader uses. A hdbpath that does not exist is refused at init. Without that the partition traverse returns nothing and the run reports success having compressed zero columns, which reads exactly like a correct no-op. Documents one inherited divergence, not changed here: di.compression's loadcsv traps its own checkcsv, so an invalid algorithm is logged and the run continues, where TorQ lets it throw and abort. The suite asserts the current behaviour so that changing it fails deliberately. Tests build a real two-partition hdb and assert with -21! that the configured column is compressed and an unconfigured one is not. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
DIReview Summary0 critical | 0 warning(s) | 1 suggestion(s)
Suggestions
|
alowrydi
left a comment
There was a problem hiding this comment.
Ran the suite (21/21) and smoke-tested against the TorqX-POC stack: one-shot lifecycle, root publishing for runhook, and the hdb-path check all behave. Compressed a real 26-partition hdb (338MB saved, data verified readable after).
What's good
- Faithful port: the four settings map one-to-one to TorQ (
inputcsvis renamedcsvpath), and the invalid-hdb-path check matches TorQ's. - The lifecycle is right: the exit lives in
run, whichrunhookcalls after the full init, andcompressnowstays re-triggerable over IPC without killing the process. - Registry entry, root-published
.compression.run/.compression.compressnow, and thedi.compressionVERSION stamp (so depcheck stops rejecting it) are all in place. - The test builds a real two-partition hdb and checks with
-21!that the configured column is compressed and an unconfigured one isn't - and the 200k-row reasoning (kdb won't compress below block size) is exactly the trap a lazier test would fall into. - compression.md is clear, and the inherited csv-validation divergence is documented rather than hidden.
- Real-data run worked end to end: compressed, verified readable, and the process exited cleanly.
Nothing structural needs reworking. The four blocking items below are quick, mostly mechanical edits (trim comments, fix fixture dates, settle one default, add one assertion). I'd expect to approve once 1-4 are addressed.
Blocking
- 1. Comments are too long. Many of them explain why the code is written the way it is, and some point at TorQ or other modules. Trim each to a short line saying what the code does - the explanations already live in compression.md. Biggest ones: the 13-line header at the top of
compression.q, "Ported from TorQ" (l.3), "Legacy TorQ exits here too" (l.53-55), and the comment in test.csv row 31. This is the new comment rule in style.md (#148). - 2. Test fails from 2027.01.02. Fixture partitions are fixed at
2026.01.01 2026.01.02with maxage 365, and di.compression keepsage within (compressage;maxage). Reproduced by ageing the fixture: the 366-day partition stays uncompressed, so row 19 fails. Derive the dates from.z.D. - 3. maxage default is 365; TorQ ships 30. TorQ's code default is 365, but
config/settings/compression.q:12sets 30, so a stock TorQ process scans 30 days. Is 365 intended? If not, use 30; if so, say so in "Migrating from TorQ". - 4. Code defaults are never asserted.
compression.q:73-75says "the tests assert both halves" and rows 11-12 say "asserted below", but row 14 is arun- nothing checks maxage/exitonfinish afterinit[nodefaultscfg[]]. Assert them (e.g. from the captured init log line) or drop the claim.
Should fix
- 5. Doc example has
startwithall=1(compression.md:76) -torqx.sh start allwould then rewrite the hdb on every stack start. Should be0, as the POC row is. - 7. csvpath roots disagree. The code default uses
TORQXAPPCONFIG/compressionconfig.csv; the shipped setting:appconfig/compressionconfig.csvresolves underTORQXAPPHOME. Since the setting always applies,TORQXAPPCONFIGis ignored. - 8. toml rows prove nothing, and
asboolmis-parses"true". Rows 26-27 recompress already-compressed files (every file skipped), andtomlcfgpasses maxage/exitonfinish natively, so the string branches ofaslong/asboolnever run. Those branches have a bug:"B"$"true"is0b(only"1"parses true), soexitonfinish = "true"quoted in a toml silently disables exit. Rebuild the fixture first, pass"365"/"0"/"1", and either accept"true"or reject non-0/1 strings.asboolis a copy of the one in di.permissions (permissions.q:17), so a quoted"true"forenabledthere would silently leave access control off - worth its own ticket. - 9. No maxage-exclusion test. No fixture partition is ever outside the window - add one and assert it is left alone.
- 11. torq.md l.89-90 and l.95 list the builtin proctypes without
compression.
Your call
- 6. No default compression csv. TorQ ships
config/compressionconfig.csv(default,10,default,1,16,0) and resolves app-then-framework via.proc.getconfigfile; here an app without one fails.di.torq.configexportsgetconfigfile. (housekeeping also builds its csv path by hand, so this is a consistency question, not a regression in this PR.) - 10. Failed init leaves state half set.
.z.m.log/.z.m.hdbpathare assigned before the hdb check, so after a bad-path initinitialised[]is true andcompressnowdies on.z.m.cmpinstead of the init message. Validate, then assign. Low impact: torqx_init exits 3 on any init error, so this state is only reachable if a caller catches the failure. - 12. Bad csv exits 0. Confirmed live: two ERROR lines, nothing compressed, exit code 0. For a scheduled batch job that is a silent success. Fixable in this wrapper without touching di.compression: count calls through the injected error logger and have
runexit 1 if any. - 13.
apphome/datahome/resolvedirnow exist in three process modules;asbool/aslongcopy di.permissions - backlog candidate. - 14.
di/torq/VERSIONstays 0.5.0 though the registry gained a proctype - is a bump expected?
The DIReview suggestion to trap key .z.m.hdbpath isn't needed: key on a missing path returns ().
TorqX-POC (#6, already merged)
- On POC main,
start compression1fails until this merges - the builtin isn't on kdbx main. compression1.tomlhas no.qtwin; every other settings file has one since #7.deps.tomldeclares neitherdi.torq.proc.compressionnordi.compression.- The toml NOTE blames block size, but the shipped
2015.01.07partition is excluded bymaxage = 365first, and its columns (largest about 4 KB) are below the 2^17 block size anyway. On a stack that has run EODs, the recent partitions are in range and do get compressed.
1. Trim comments to concise what-only, matching DataIntellectTech#148's repo-wide pass. 47 comment lines -> 13. The rationale already lives in compression.md. 2. Derive the test fixture's partitions from .z.D. They were fixed at 2026.01.01/02, so from 2027.01.02 they fall outside the maxage window and the compression assertions would have started failing. 3. Ship maxage 30, not 365. TorQ's code default is 365 but its config/settings/compression.q sets 30, so a stock TorQ process scans 30 days - 365 was a parity miss. Recorded in "Migrating from TorQ". 4. Actually assert the code defaults. The comments claimed the tests checked them; nothing did. Both are now asserted from the init log after an init that supplies neither. Also: - add a partition outside the maxage window and assert it is left alone - csvpath's unreachable code default used TORQXAPPCONFIG while the shipped setting resolves under TORQXAPPHOME; both now use TORQXAPPHOME - compression.md's process.csv example had startwithall=1, which would rewrite the hdb on every stack start - torq.md's two proctype lists did not mention compression - the toml test rows recompressed already-compressed files and passed native types, so the string branches never ran; the fixture is rebuilt first and maxage/exitonfinish are passed as text Four suites green; the process still boots and exits on the POC stack. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
6. Ship a default compression csv (di/torq/compressionconfig.csv, the same
default,10,default,1,16,0 TorQ ships) and fall back to it when the app
has none. Previously an app without its own csv failed.
8. asbool read only "1" as true, so a quoted exitonfinish = "true" in a
toml silently meant false. It now accepts true/false/1/0 in any case and
throws on anything else rather than guessing. Fixed in di.permissions
too, where the same copy meant a quoted enabled = "true" would have left
access control off with no warning.
10. init resolved and assigned module state before validating the hdb path,
so a failed init left initialised[] true and compressnow died on an
unset .z.m.cmp. Everything is resolved into locals and validated first.
12. A pass that logged errors exited 0, which for a scheduled batch job
reads as success. The injected error logger is now counted and run
exits 1 if the pass logged any. errorcount is exported.
14. di/torq VERSION 0.5.0 -> 0.6.0, since the built-in registry gained a
proctype. di.permissions 0.1.0 -> 0.2.0 for the asbool change.
Tests cover the framework-csv fallback, the bad-boolean refusal, the error
count, and the toml path now passes "true"/"false" as text rather than
native types, so the string branches actually run.
Six suites green; the POC stack starts clean and still enforces permissions.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
DIReview Summary✅ No new findings at
|
Carries the same fix made on DataIntellectTech#150 into the two copies this branch still owns, so DataIntellectTech#149 does not ship a known silent-false. DIReview raised it against di.util.cfg: a value that is not a boolean, long or string fell through the type guard to 0b. The symbol case it named is not the worst one: asbool 1i -> 0b an int 1 read as FALSE asbool 1h -> 0b asbool `true -> 0b asbool (::) -> 0b In di.permissions that meant a .q settings tier writing enabled:1i left access control off with no warning. Numeric atoms are now accepted, nonzero being true; every other type errors, naming the type. Both copies are superseded by di.util.cfg once DataIntellectTech#150 and this merge. Three suites green; the POC stack starts clean and still enforces. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
DIReview Summary0 critical | 0 warning(s) | 1 suggestion(s)
Suggestions
|
Carries the DataIntellectTech#150 follow-up into the two copies this branch owns: the type list now covers -4h..-9h rather than omitting real (-8h) while accepting float, and uses (type x) to match the form used elsewhere. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
DIReview Summary0 critical | 0 warning(s) | 1 suggestion(s)
Suggestions
|
|
Hi Aaron, thanks, really useful review. All 14 items are addressed. #149 has 1–12 and 14. Some things to note: maxage now ships 30 rather than 365, matching TorQ's config/settings/compression.q, so a stock deploy scans 30 days; and the fixture dates derive from .z.D, since the hardcoded ones would have started failing on 2027-01-02. #150 is item 13: a new di.util.cfg module with one copy of apphome, datahome, resolvedir, asbool and aslong. rdb, tickerplant, wdb and housekeeping bind it at load time, so call sites are unchanged. di.torq.proc.hdb is left alone since its resolvedir takes one argument and has different semantics, so it isn't a duplicate. di.permissions and di.torq.proc.compression still carry their own copies. They're modified on the #149 branch and would conflict, so they fold in via a follow-up PR once both #149 and #150 have merged. That's the asbool/aslong/path-helper duplication. There's more of this than item 13 covered: totimespan is in five modules, tosym/aslist/assym in three each, all identical. A few others (astz, tolong, tobool vs asbool, and the timespan trio) have genuinely diverged, including a seconds-vs-nanoseconds difference. I'd rather land #150 first and do those as a follow-up, since the divergent ones need decisions rather than a move. TorqX-POC #8 covers the POC notes. It must merge after #149 since its deps.toml declares the compression modules, and I've checked every process fails at startup naming them if it goes first. Order: #149 before POC #8, since its deps.toml declares the compression modules. #150 is independent. The fold-in needs both #149 and #150; the wider conversion cleanup needs only #150, so those two can land in either order. |
A malformed maxage compressed nothing and exited 0; a malformed maxsize refused every query. aslong now errors, as wdb's tolong does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DIReview Summary0 critical | 0 warning(s) | 1 suggestion(s)
Suggestions
|
alowrydi
left a comment
There was a problem hiding this comment.
Thanks Dexter, I checked all 14 against the new code and ran it. Approving.
Verified
- Suites green with
TORQXHOMEunset: di.torq.proc.compression 35/35, di.permissions 58/58, di.torq 93/93, di.compression 73/73. Also green merged with #150 on current main. - Ran
compression1live via POC #8 against a scratch hdb: good csv exits 0 (pricecompressed,condnot), bad csv exits 1 ("2 error(s) during compression"), bad hdb path exits 3. - 1–4: comments say what the code does, fixture dates come from
.z.D, maxage ships 30, code defaults are asserted from the init log. - 5, 7, 9, 11:
startwithallis 0 in the doc, csv path is underTORQXAPPHOME, the out-of-window partition is asserted untouched,torq.mdlistscompression. - 8:
asbooltakes true/false/1/0 in any case and errors on anything else, in di.permissions too. The toml rows pass text, so the string branches run. - 6, 10, 12, 14: default csv fallback, validate before setting state,
runexits 1 on logged errors, versions bumped. - 13: split out to #150.
Merge order: #149 and #150 can go in either order, then POC #8 after #149.
* di.util.cfg: one implementation of the shared config helpers apphome, datahome and resolvedir were copied byte-for-byte into di.torq.proc.rdb, .tickerplant, .wdb and .housekeeping (which named its copy resolvepath). asbool and aslong are duplicated the same way. Raised in review on #149. Adds di.util.cfg holding one copy of each, and binds it in the four modules at load time so call sites are unchanged: cfg:use`di.util.cfg; apphome:cfg`apphome; datahome:cfg`datahome; resolvedir:cfg`resolvedir; Two things found while consolidating: - resolvedir signalled 'type on a single-character relative path. "x" is a char ATOM, so `like` was applied to an atom rather than a string. All five copies had it. Fixed with (), and covered by a test. - asbool read only "1" as true, so a quoted setting of "true" meant false. It now takes true/false/1/0 in any case and errors otherwise. NOT folded in here: di.permissions and di.torq.proc.compression also carry copies, but both are changed on the #149 branch and would conflict. They follow once that merges. di.torq.proc.hdb has its own single-argument resolvedir with different semantics - left alone deliberately. Seven suites green; the POC stack starts clean with data flowing. * di.util.cfg: error on any type asbool cannot read DIReview on #150 noted a symbol fell through the type guard to a silent 0b, contradicting the doc. Correct, and the symbol is not the worst case: asbool 1i -> 0b an int 1 read as FALSE asbool 1h -> 0b asbool 1f -> 0b asbool `true -> 0b asbool (::) -> 0b So a .q settings tier writing enabled:1i disabled the thing it was enabling, silently - the same class of bug as the quoted "true" already fixed here, and likelier to be hit. Numeric atoms (short/int/long/float) are now accepted, nonzero being true. Every other type errors, naming the type. Tested across all of them. * di.util.cfg: accept every numeric atom, not an arbitrary five DIReview on #150: the type list included float (-9h) but not real (-8h), which is an arbitrary gap, and type[x] was inconsistent with the (type x) form used elsewhere in the file. Both fixed - the list is now -4h..-9h, every numeric atom, with nonzero true. The review's premise is not right, for the record: the original did NOT accept any numeric via 0<>x. Measured, it took long alone - orig 1 -> 1b orig 1i -> 0b orig 1h -> 0b orig 1f -> 0b orig 1e -> 0b so int, short, float and real were all silent falses. This widens acceptance rather than narrowing it; the only values that now error are ones that previously returned a silent 0b. * di.util.cfg: cover byte in the asbool tests DIReview on #150: -4h is in the numeric guard and the doc says "byte through float", but no test exercised a byte. Keeping -4h deliberately - excluding it would reintroduce the arbitrary gap this list was widened to remove - so the test is what was missing. * di.util.cfg: aslong errors on unparseable values; tidy comments
Ports TorQ's
code/processes/compression.qandconfig/settings/compression.q.The compression engine was already ported as
di.compression(#82). This adds the missing half: the process type that drives it, socompressioncan actually be started as a TorqX process.What's here
di/torq/proc/compression/di/torq/settings/compression.qcsvpath,hdbpath,maxage,exitonfinish)di/torq/torq.qdi/compression/VERSIONDesign notes
The pass runs from
runhookas.compression.run[], not frominit.initmust not exit —torqx.showns the process lifecycle. Keeping the work in.compression.compressnow[]leaves it re-triggerable over IPC without terminating the process. Same splitdi.torq's sample loader uses.A
hdbpaththat does not exist is refused at init. Without that check the partition traverse returns nothing and the run reports success having compressed zero columns — indistinguishable from a correct no-op.