Skip to content

Feature clienttrackingv2 - #140

Merged
alowrydi merged 3 commits into
mainfrom
feature-clienttrackingv2
Oct 2, 2026
Merged

alowrydi merged 3 commits into
mainfrom
feature-clienttrackingv2

Conversation

@alowrydi

Copy link
Copy Markdown
Collaborator

Rebuilds di.clienttracking (0.1.0 → 0.2.0) from scratch as a faithful port of TorQ's trackclients.q - the prior version was a redesign (renamed/dropped columns, added validation and gating never present in legacy), not a port.

Wires it into di.torq for the first time: every process now calls clienttracking.init unconditionally, matching legacy's own order.txt behaviour. Adds zpsignore directly in torq.q's own init (not a separate module - it has no standalone purpose) so tick traffic (upd/.u.upd) is correctly excluded from both client-tracking hit counts and query logging, as legacy does. Builtin tickerplant/segmentedtp settings gain opencloseonly:1b and zpsignore.enabled:0b, matching legacy's own pairing for tickerplants.

alowrydi and others added 2 commits September 28, 2026 13:21
Replaces the 0.1.0 redesign with a one-to-one repackaging of
code/handlers/trackclients.q, built only from TorQ. The .clients
section is TorQ's text; the only change is .proc.cp[] -> .z.p.

Surface: root .clients.* (clients keyed on w with all 17 columns,
cleanup, hit, hite, po, addw, pc, wo, unregistered), .dotz.ipa and
.dotz.liveh/livehn/liveh0. Exports init and version.

Deviations:
- .z.po/.z.pc/.z.wo/.z.wc go through di.torq.handlers observers, so
  the existing handler runs after tracking instead of before.
- .z.pg/.z.ps/.z.ws are wrapped directly in init, as di.querylog does,
  with {.clients.hit[@[x;y;.clients.hite]]}. Unset handlers default to
  dotz.q's value/value/echo. init is once only, and a later
  di.torq.handlers exec owner replaces the wrap.
- .proc.cp[] -> .z.p.
- Settings come from a clients config section with TorQ's names,
  set onto .clients.<name>. Defaults (default.q:31-37) live in the
  module until it is wired into di.torq.
- .dotz.IPA/ipa/liveh/livehn/liveh0 come from dotz.q:6-8, defined at
  load in a \d .dotz section only if absent.
- Not yet loaded by di.torq. apidetails.q's .api.add not ported.
- Descriptive comments and the commented-out timer block dropped.

Kept as TorQ has them:
- .z.pc is wired even when disabled.
- AUTOCLEAN is never read.
- unregistered reads a nonexistent CLIENTS table.
- Closed rows share a null key.
- Async and websocket results count toward sz.
- Idle-reaped rows are dropped in the same sweep, because their endp
  is still null.
- hits and errs are ints.

Tests: 41, against four real server peers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
init now wraps .z.* in order: clienttracking, querylog, zpsignore. zpsignore runs ignorelisted
async messages (upd, .u.upd) with value, so ticks skip client tracking. Tickerplant and
segmentedtp settings track connections only and turn zpsignore off. The di.torq suite gains rows
for client counting, the upd bypass, string messages not being skipped, zpsignore off, and the
tickerplant settings; they fail on the previous torq.q.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread di/torq/torq.q Resolved
@DI-Software-Engineering

Copy link
Copy Markdown

DIReview Summary

2 critical | 3 warning(s) | 1 suggestion(s)

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

Suggestions

  • di/clienttracking/clienttracking.q:27 — The livehx helper is defined as {y in x,key .z.W} and livehn is livehx 0Ni. This means livehn is a projection {0Ni in 0Ni,key .z.W} when evaluated at definition time — but key .z.W is captured at the time livehn:livehx 0Ni is evaluated (load time), not at call time. The resulting livehn is a constant function that always returns the same result based on .z.W at load time. In cleanup, not .dotz.livehn w will therefore not reflect the current state of .z.W. livehn should be a niladic function that captures .z.W at call time, e.g. livehn:{0Ni in 0Ni,key .z.W}.

Comment thread di/clienttracking/test.q
/ test helpers: server peers running di.clienttracking under different settings

FIXDIR:"/tmp/dictracktest"
QBIN:first system "readlink -f /proc/",(string .z.i),"/exe"

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.

minor but maybe this can be standardised as well

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This already uses the standard form shared by every test (readlink -f /proc//exe). The only fixture that differed was servers' spawnpeer, now fixed in 138.

DI-Dexter
DI-Dexter previously approved these changes Oct 2, 2026
Comment thread di/torq/torq.q Resolved
@DI-Software-Engineering

Copy link
Copy Markdown

DIReview Summary

1 critical | 4 warning(s) | 3 suggestion(s)

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

Suggestions

  • di/clienttracking/clienttracking.q:48 — po constructs the upsert row with zp:.z.p assigned inline as the 15th positional value, but zp is referenced earlier in the same list as position 13 (zp) before it is assigned. In q, the list is constructed left-to-right, so zp at position 13 (startp) is evaluated before zp:.z.p at position 15 (lastp). At first call zp is undefined and will throw 'zp. The fix is to assign zp:.z.p before the upsert, not inline within it.
  • di/clienttracking/clienttracking.q:23 — .clients.enabled is read with @[value;enabled;1b]after it has already been assigned the literal1btwo lines earlier. The@[value;...]fallback only fires if the name throws onvalue; since the name was just assigned, the fallback is unreachable and the @[value;...]has no effect —.clients.enabledwill always be1bat this point regardless of any prior setting. The same applies toopencloseonly`. These guarded reads should occur before the literal default assignments, or the literal assignments should be removed if the intent is to preserve a previously-set value.
  • di/torq/test.csv:29 — The test true,0,0,q,"(1;1)~(HITS;UPD)" asserts that after the upd async message HITS is still 1 (unchanged), meaning client tracking was skipped. But this relies on zpsignore being wired before the assertion and the ignorelist containing `upd. The setup line re-assigns .clients.hit to a counter function, but initzpsignore captures the .z.ps value at wire-time via @[value;.z.ps;{value}]. If initzpsignoreran (indi.torq.init) before .clients.hitwas replaced by the test setup, the capturedfin the closure already points to the client-tracking wrapper with the *original*.clients.hit. Replacing .clients.hitafter the fact does intercept calls becausehitis looked up by name at call time — this is fine. But ifinitzpsignoreran *before*di.clienttracking.initwrapped.z.ps, the ordering assumption in the test is wrong. This is a sequencing fragility worth verifying against the actual initcall order intorq.q(line 315:initclientstheninitzpsignore`).

@alowrydi
alowrydi merged commit a95e88e into main Oct 2, 2026
alowrydi added a commit that referenced this pull request Oct 2, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alowrydi
alowrydi deleted the feature-clienttrackingv2 branch October 16, 2026 13:16
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