Repository navigation
di.util.cfg: one implementation of every config coercion - #152
Conversation
DIReview Summary✅ No new findings at
|
| if[null r;'"di.util.cfg: cannot read \"",$[10h=abs type x;(),x;-3!x],"\" as a whole number"]; | ||
| r | ||
| } | ||
|
|
There was a problem hiding this comment.
spanunits is defined at module load time as a plain dict literal with timespan values. If di.util.cfg is loaded in a use context, this top-level assignment executes once. The dict key lookup spanunits unit for a missing key returns the default value for the value type — for a timespan dict, the default is 0Nn. null 0Nn is 1b in q, so the guard if[null u:…] correctly catches an unknown unit. This is fine per the Known q facts (null of a typed null is 1b).
DIReview Summary0 critical | 1 warning(s) | 1 suggestion(s)
Suggestions
|
| x:$[-11h=type x;string x;x]; | ||
| r:$[-16h=type x;x; | ||
| (type x) in -17 -18 -19h;`timespan$x; | ||
| (type x) in -5 -6 -7h;u*x; |
There was a problem hiding this comment.
The branch for types -5 -6 -7h (short, int, long) now returns u*x (a raw numeric product, e.g. a long or int) instead of a timespan. Previously, \timespan$uxwas applied to all five numeric types uniformly, converting the product to a timespan. The new code omits the`timespan$cast for the integer types, so callers receive a raw integer/long rather than a 0Nn-or-timespan value, breaking the contract ofastimespan. The fix is `timespan$uxfor the-5 -6 -7h` branch (the same cast that was there before, now separated from real/float).
DIReview Summary0 critical | 1 warning(s) | 0 suggestion(s)
|
alowrydi
left a comment
There was a problem hiding this comment.
Right direction, and the mechanical part checks out. A few things before merge.
Verified
- Merged with #153 on current main: same results as main in every suite except the two that grew, di.util.cfg (62/62) and di.torq (100/100). Suites that fall short do so identically on main.
- TorqX-POC on the merged tree: every process started reports depcheck 0 failures.
- Probed
astimespan/asbool/aslongdirectly. Real and float arithmetic is correct and integer inputs return a timespan, so DIReview's warnings onu*xdon't apply.assymmatches idb's oldastzon every input I tried. - Every module that uses
di.util.cfgdeclares it at 0.2.0. Shipped framework and POC settings use explicit timespans and booleans.
Please fix before merge
- Housekeeping
runtimesregression.runtimes = "0200 1430"used to give 02:00 and 14:30. It now gives8D08:00and59D14:00with no error, so the job would first fire days or weeks out. The PR's "who is affected" list doesn't cover this form.astimespansshould reject anything outside 0-24 hours, which also catchesruntimes = 30. - heartbeat still has its own
totimespan. #151 landed after this branched and adds the old copy atheartbeat.q:20, so"30"is still 30 hours there and junk is0Nn. Please rebase and useastimespan[second;…]`. - Comments now sit above the wrong code. The
cfgblock went between an existing comment and the line it describes:- gateway.q: "di.dataaccess partition coverage…" (belongs to
buildpartitions) - segmentedtp.q: "di.eodtime settings from an [eodtime] section…" (
eodconfig) - tickerlogreplay.q: "log the error and exit" (
ex) - subscriptions.q: "registry of active subscriptions" (
SUBSCRIPTIONS)
- gateway.q: "di.dataaccess partition coverage…" (belongs to
- Dead check in subscriptions.q.
if[null p;…]can't fire now thatastimespanerrors. Remove it. - No call-site test for
runtimes. housekeeping/test.csv is unchanged. Add rows for a bare number as an hour and for the out-of-range rejection.
Nits, fine as a follow-up
- Errors name the value but not the setting (
cannot read "ture" as a boolean), where the old messages said "rolltimeoffset must be a timespan". With this many settings, the name would help. astimespan[second;0W]overflows to-0D00:00:01, while the text"0W"gives0Wn`. The old copies did the same multiplication, so this isn't new.- hdb's
datahomeis still an identical copy, andtosym/assymdo the same job for text and symbols. - Unrelated blank-line removals in tickerlogreplay.q, a double blank line in idb.q, and
astz:cfgassymcould just beassym`. - compression test.q:68's comment still says "neither true/false nor 1/0", and some test comments explain history ("it used to…").
Moves totimespan, tosym, aslist, assym and astoklist (and astz, now bound to assym) into di.util.cfg - 18 copies across 10 modules, behaviour unchanged. Diverged helpers (tolong, tobool, the timespan trio) are left for their own PRs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
astimespan[unit;x] replaces the three timespan helpers that disagreed on what a bare number means; wdb, idb, permissions and compression now use the shared asbool/aslong. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
timespan*real rounds the real first, so 1.5e seconds gave 2s and 0.1e hours gave 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
di.util.cfg goes 0.1.0 -> 0.2.0, and the seven modules bumped twice drop back one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eat, misplaced comments runtimes text is read as a time of day again and anything outside 0-24 hours errors. heartbeat moves onto astimespan, and comments stranded by the cfg block go back above their code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
b7d4225 to
a51d69f
Compare
DIReview Summary1 critical | 2 warning(s) | 1 suggestion(s)
Could not be posted inline
Suggestions
|
"N"$"30" is 30 hours, so -retry 30 on a timespan-typed setting is now logged and skipped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| @@ -86,6 +86,9 @@ parsefailed:{[t;raw;vals] | |||
| any null vals]; | |||
| }; | |||
|
|
|||
There was a problem hiding this comment.
barenumber accepts strings like "-." (all characters are in .Q.n,".-") which are not valid numbers. For example, ".." or "-" or "." would be flagged as bare numbers and rejected for timespan settings, even though "N"$ would not parse them as hours (they would fail with a parse error caught by parsefailed). The check incorrectly blocks values that would already fail parsefailed with a clearer message. To fix, anchor the pattern more tightly: e.g. require the first char to be a digit or -, at most one ., etc., or check not null "F"$x instead of a character-set membership test.
DIReview Summary0 critical | 1 warning(s) | 0 suggestion(s)
|
…erflow Coercion errors name the setting, tosym folds into assym, hdb uses the shared datahome, and an empty runtimes logs an error as TorQ does. Infinity stays infinite, as in TorQ. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A WSL2 clock step of about -645ms every 32s cut the 1.5s sleeps below the 1s limits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
As TorQ's timer does. An infinite period wrapped into the past and ran on every tick. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
xbar needs a numeric bar size, not a minute. A mode 5 period under a minute is now rejected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The follow-ups were bumped on top of the PR's own bumps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| .z.m.jobcsv:resolvepath[apphome[];config`jobcsv]; | ||
| / defaults match di/torq/settings/housekeeping.q | ||
| .z.m.runtimes:$[`runtimes in key config;astimespans config`runtimes;enlist 0D02:00:00]; | ||
| .z.m.runtimes:$[`runtimes in key config;named[`runtimes;astimespans;config`runtimes];enlist 0D02:00:00]; |
There was a problem hiding this comment.
An empty runtimes list is now only logged as an error (log[error]) rather than throwing — execution continues and .z.m.runtimesis set to(). If the downstream code that schedules jobs iterates over .z.m.runtimesit will simply schedule nothing, which may be a silent misconfiguration. The testrtnone(line 136 in test.csv) explicitly expectsrtnone[]to succeed (i.e.initdoes not throw), confirming this is intentional. But the oldastimespans did throw on an empty string (rtempty) — an empty *list* (`` timespan$() ``) is now accepted silently. If a misconfigured TOML produces an empty list, the housekeeping process will start, log an error, and run no jobs — operators may not notice. This is a design choice rather than a code defect, but note that the error is logged and not raised, so monitoring must rely on log scanning.
DIReview Summary0 critical | 1 warning(s) | 2 suggestion(s)
Suggestions
|
alowrydi
left a comment
There was a problem hiding this comment.
Thanks Dexter, all the items from my last review are addressed. Approving.
Checked
runtimes:astimespansrejects anything outside 0-24 hours, a bare number is an hour,"0200 1430"still works, and an empty string errors. The new housekeeping rows cover each case.- heartbeat now uses
astimespan, with tests for digits as text and a number. - The four misplaced comments are back above the right code, the dead
if[null p;…]check is gone, and the history-style test comments are removed. - Errors name the setting,
tosymis merged intoassym, hdb uses the shareddatahome, and0Wstays infinite. - di.timer: the new period check matches TorQ's
within (periodstart;periodend)rule. The mode 5 fix is right, and the tests cover the interval, an exact boundary, rollover to the next day, a past start and the under-a-minute rejection. - Merges cleanly into current main.
Resolve the segmentedtp VERSION conflict with #152 as 0.3.1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Follow-up to #150. Every config coercion helper in
di.*now has one implementation, indi.util.cfg. Modules bind them at load time, the same way #150 does.Eleven commits:
f4b714e– move the identical copies. No behaviour change.b53bf2d– merge the copies that had diverged. This changes behaviour on purpose; see below.e22a0f5– fixastimespanfor reals. A real (1.5e) is cast to float before scaling. q rounds a real multiplied by a timespan to a whole number first, so1.5eseconds gave 2s and0.1ehours gave 0.886a0af– bump each module's VERSION once for the PR. Every module is one minor version abovemain; for exampledi.util.cfggoes 0.1.0 → 0.2.0.a51d69f– address the review. Theruntimesrange check, heartbeat moved ontoastimespan, and the misplaced comments.c0cad98– refuse bare digits on a timespan override. See "Command line" below.35d8404– the follow-ups. Errors name the setting,tosymmerges intoassym, infinity stays infinite, hdb uses the shareddatahome, and an emptyruntimeslogs an error.8f842a0– widen thedi.clienttrackingidle and retain test sleeps to 3s. A WSL2 clock step of about -645ms every 32s cut the 1.5s sleeps below the 1s limits.74c3f55–di.timer: disable a job whose next run falls outside its period. See section 3.9f0b9f4–di.timer: fix mode 5. See section 3.01f195b– keep to one VERSION bump per module after the follow-ups.If you have already reviewed the earlier commits, read 5 onwards.
Rebased onto
mainafter #151, so the first four hashes changed; their content did not.1. Identical copies moved
tosym(nowassym)aslistassymastoklistastz(nowassym)astzis replaced byassym. The tickerplant copy has the same source. idb's`$(),xgives the same result on every input tried, including a char atom and an empty string.2. Behaviour changes
totimespanincluding heartbeat's copy, wdbastimespan, housekeepingastimespans)"30"was 30 hours intotimespan("N"$) but 30 seconds in wdb's. Housekeeping read a bare number as nanoseconds. Junk text gave0Nn.astimespan[unit;x]. A bare number, or bare digits as text, counts inunit(`second,`minuteor`hour). Unreadable input errors.tosym(chainedtp, segmentedtp, tickerlogreplay)assym, so a number throws.tolong(idb, wdb)0Non a bad value; wdb threw.aslong, which throws (wdb's behaviour).tobool,asbool)"ture"as0band threw on a symbol.asboolrejectedyes/no.asbool 0Nwas1b.asbool. It acceptstrue/false,yes/no,t/f,y/nand1/0in any case. Anything else errors, including a null number.An
asbool,aslongorastimespanerror reading a setting now names it:setting retry: di.util.cfg: cannot read "junk" as a timespan.Unit at each call site:
Seconds:
retry,discoveryretry,pubinterval,eodwaittime,checksubscriptionperiod,rolltimeoffset,heartbeatpublishintervalandheartbeatcheckinterval. The module docs already describe all of these in seconds, so a bare number reads as before.Housekeeping
runtimesis a time of day, so it has its own rules:"0200 1430","02:00 14:30""N"$)230,-1,"30","junk"""Command line:
-retry 30on a timespan-typed setting is now refused and logged, and the old value stays."N"$"30"is 30 hours, which is never what an interval means. Use00:00:30or0D00:00:30. This differs from TorQ, which accepts it as 30 hours. A string-typed setting from.tomlkeeps the text, soastimespanreads it in the module's unit.di.permissionsanddi.torq.proc.compressionnow use the sharedasbool/aslongin place of their own copies. compression also uses the shared path helpers.di.permissionsgains adeps.toml.di.torq.proc.hdbuses the shareddatahomeand also gains one.Who is affected: a setting that relied on the old meaning:
runtimes, or aruntimesvalue outside 0–24 hours;tosym.None of the shipped
di/torq/settingsor TorqX-POC settings do any of these. They all use explicit timespans and booleans.3.
di.timer0Wnruns once.di.timeronly checked the end time, and.z.p+0Wnwraps to 1734, so the job ran on every tick. It now checks both ends. An infinite, null or negative period runs once and is disabled; normal periods are unchanged.xbarwas given a minute as its bar size. It now schedules astimer.mddescribes. A period under a minute is rejected when the job is added, as it would otherwise run once and silently stop.