Skip to content

di.util.cfg: one implementation of the shared config helpers - #150

Merged
DI-Dexter merged 5 commits into
DataIntellectTech:mainfrom
DI-Dexter:di-util-cfg
Nov 4, 2026
Merged

DI-Dexter merged 5 commits into
DataIntellectTech:mainfrom
DI-Dexter:di-util-cfg

Conversation

@DI-Dexter

@DI-Dexter DI-Dexter commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Raised in review on #149, item 13.

apphome, datahome and resolvedir are copied byte-for-byte into four process modules (di.torq.proc.rdb, .tickerplant, .wdb, and .housekeeping, which names its copy resolvepath). asbool/aslong are duplicated the same way.

This adds di.util.cfg with one copy of each, and binds it at load time so call sites are unchanged:

cfg:use`di.util.cfg;
apphome:cfg`apphome;
datahome:cfg`datahome;
resolvedir:cfg`resolvedir;

Three lines per module instead of rewriting every call — which keeps the diff reviewable and the behaviour identical.

Deliberately not in scope

  • di.permissions and di.torq.proc.compression also carry copies, but both are modified on the di.torq.proc.compression: one-shot hdb compression process type #149 branch and would conflict. They fold in once that merges.
  • di.torq.proc.hdb has its own single-argument resolvedir with different semantics (returns a symbol, always resolves under datahome). Not a duplicate — left alone.

Testing

Seven suites green: di.util.cfg, di.torq.proc.rdb, .tickerplant, .wdb, .housekeeping, di.torq, di.torq.depcheck.

Verified end to end on the TorqX-POC stack — all ten processes init, and data flows through the wdb into the idb (wdb trade: 411 idb trade: 964844).

VERSION bumps and deps.toml entries for all four consumers.

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 DataIntellectTech#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 DataIntellectTech#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.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Comment thread di/util/cfg/cfg.q Outdated
asbool:{[x]
if[-1h=type x;:x];
if[-7h=type x;:0<>x];
if[10h<>abs type x;:0b];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When x is not a boolean, long, or string (e.g. it is a symbol atom like `true), the guard if[10h<>abs type x;:0b] silently returns 0b instead of erroring. The doc says "anything else is an error", but a symbol or other non-string type falls through this guard and returns a silent false. The guard should signal an error for any unrecognised type, not return 0b.

@DI-Software-Engineering

Copy link
Copy Markdown

DIReview Summary

0 critical | 1 warning(s) | 0 suggestion(s)

⚠️ Spec check skipped — tracker lookup failed (NO_REF_FOUND). Standards axis only.

DIReview on DataIntellectTech#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.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@DI-Software-Engineering

Copy link
Copy Markdown

DIReview Summary

0 critical | 0 warning(s) | 1 suggestion(s)

⚠️ Spec check skipped — tracker lookup failed (NO_REF_FOUND). Standards axis only.

Suggestions

  • di/util/cfg/cfg.q:22 — type[x] in -5 -6 -7 -9h uses in to test membership of an atom in a list of atoms. The short type is -5h, int is -6h, long is -7h, float is -9h — but the doc says 'short/int/long/float'. This silently omits real/float32 (-8h) and double (-9h covers double, but not -8h real). If real (1.0e) is a plausible config value the check should include -8h as well. More importantly, type[x] is non-standard syntax for a module that uses type x everywhere else; the conventional form is (type x) in -5 -6 -7 -9h.

DI-Dexter added a commit to DI-Dexter/kdbx-modules that referenced this pull request Nov 2, 2026
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 on DataIntellectTech#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.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
DI-Dexter added a commit to DI-Dexter/kdbx-modules that referenced this pull request Nov 2, 2026
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>
@DI-Software-Engineering

Copy link
Copy Markdown

DIReview Summary

0 critical | 0 warning(s) | 1 suggestion(s)

⚠️ Spec check skipped — tracker lookup failed (NO_REF_FOUND). Standards axis only.

Suggestions

  • di/util/cfg/cfg.q:21 — Type -8h is the real (32-bit float) type in q, but the guard checks (type x) in -4 -5 -6 -7 -8 -9h without parenthesising the in call. Due to q's strict right-to-left evaluation, this parses as (type x) in (-4 -5 -6 -7 -8 -9h), which is correct. However, type -4h is the byte type. The doc change says 'byte through float' and the test exercises real (-8h) and float (-9h), but type -4h (byte) is included in the guard yet there are no tests for byte, and the original exclusion of byte was deliberate (the previous list started at -5h = short). If accepting a byte atom is intentional the missing test case is a gap; if it is unintentional, -4h should be removed from the list to match the 'short/int/long/real/float' intent implied by the doc.

DIReview on DataIntellectTech#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.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@DI-Software-Engineering

Copy link
Copy Markdown

DIReview Summary

✅ No new findings at 1bab428.

⚠️ Spec check skipped — tracker lookup failed (NO_REF_FOUND). Standards axis only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DI-Software-Engineering

Copy link
Copy Markdown

DIReview Summary

0 critical | 0 warning(s) | 1 suggestion(s)

⚠️ Spec check skipped — tracker lookup failed (NO_REF_FOUND). Standards axis only.

Suggestions

  • di/util/cfg/cfg.q:29 — The null-check fires incorrectly for a typed long input of 0N (the long null). if[null r;'...] will error when the caller intentionally passes 0Nj as a valid null-long setting. If a null long is a legitimately invalid value that should always error, this is fine and the doc should say so explicitly; but if 0Nj is a possible intentional setting value, the guard should be restricted to the string-parse branch (i.e. only check for null when x was a string/char-vector, not when -7h=type x).

@DI-Dexter
DI-Dexter requested a review from alowrydi November 3, 2026 04:59

@alowrydi alowrydi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Dexter - one copy of these is the right call. Approving.

Verified

  • Suites green on this branch: di.util.cfg 31/31, rdb 11/11, wdb 83/83, tickerplant 70/70, housekeeping 102/102.
  • Merged with #149 on current main: no conflicts, and those plus compression, permissions, di.torq, di.compression and depcheck all green.
  • Started the TorqX-POC stack (POC #8) on #149 + #150: every process up, depcheck 0 failures everywhere, so the transitive check covers di.util.cfg without the POC declaring it.
  • The four call sites bind at load time with the same behaviour. The (), added in resolvedir only makes a one-char string work. Leaving hdb's and logroll's one-argument resolvedir alone is right - different semantics.

Independent of #149 - either can merge first.

DI-Dexter added a commit that referenced this pull request Nov 4, 2026
* di.compression: stamp a VERSION

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.

* di.torq.proc.compression: one-shot hdb compression process type

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.

* di.torq.proc.compression: address review on #149

1. Trim comments to concise what-only, matching #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>

* address the remaining review items on #149

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.

* error on any type asbool cannot read

Carries the same fix made on #150 into the two copies this branch still
owns, so #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
#150 and this merge.

Three suites green; the POC stack starts clean and still enforces.

* accept every numeric atom, not an arbitrary five

Carries the #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.

* aslong: error on unparseable values; tidy comments

A malformed maxage compressed nothing and exited 0; a malformed maxsize
refused every query. aslong now errors, as wdb's tolong does.
@DI-Dexter
DI-Dexter merged commit c209e81 into DataIntellectTech:main Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants