Repository navigation
server: TENSORFOLD_REQUEST_LOG_REPLIES records each reply beside its request - #4918
Conversation
947a1c5 to
5de4747
Compare
|
Independent host verification of head
Host-side looks clean. Not run here: the full no-GPU suite ( — eXsoR65's AI agent (DeepSeek Harness): eXsoR65 authorized this comment before posting. |
|
Thanks @devopsfortunato. The reply capture is off by default, and the whole/streamed reply tests are useful. Three fixes are needed: bound the file's total growth and complete records, including error messages; enforce private access on Windows, where the current helper accepts inherited ACLs; and keep request/reply IDs paired on Ollama routes, whose request currently gets a null ID. Please add focused tests for those paths and two-client isolation. The content cap alone does not cover them.
|
85bc172 to
c55e783
Compare
|
Thanks @devopsfortunato. Ollama request/reply pairing and selection of all nine focused tests are fixed in source. Reply capture remains off by default. Two issues remain: the append writer has no total retention or complete-record limit, including error strings, and Windows still accepts inherited access without enforcing private permissions. Please add the bounds and private-access enforcement or platform refusal, with focused tests. Please also cover actual Ollama pairing and two-client isolation; the current direct trace tests do not exercise those routes.
|
ba2d1c2 to
0a48634
Compare
|
Both points are addressed in Bounds and retention. One JSON record per write, one file at a time:
Windows. The request log now refuses the platform instead of writing a file whose access it cannot enforce: Tests added for those paths ( End-to-end, as asked: Green on this tree: the three host steps ( |
0a48634 to
0a8781c
Compare
|
Two coverage gaps from the revision are now closed in
Rebased onto current |
|
Thanks @devopsfortunato. The record/error bounds, stable rotation lock, Windows refusal, UTF-8 checks and actual two-client Ollama pairing tests are present. The focused results are useful, and this head merges cleanly. One retention case remains: an existing oversized log is renamed intact to
|
|
I ran the reply log and Ollama loopback suites on a clean trial merge of zig build test-request-log-replies-host test-ollama-e2e-host -Dfixed-cpu -j2 --summary allFor the oversized-file case Ash flagged, there is a small fixture that uses the existing Igor Lessio - AIFLOW LABS |
0a8781c to
92afc16
Compare
|
Both points are addressed in The oversized-log case now has a policy. When a record must rotate the current file, the writer renames it to The Ollama test file is split. The Green on the rebased head ( On the other two red jobs: |
|
Thanks for the independent run, and for the fixture — it is now the test in the tree, nearly verbatim: 40 records at a 1024-byte limit, one append at 256, then exactly one parseable record in the active file, |
|
Thanks for adding the fixture. I trial-merged zig build test-request-log-replies-host test-request-log-host test-ollama-e2e-host test-environment-host -Dfixed-cpu -j2 --summary allThe active file and both size checks now pass. I extended the oversized-archive fixture with one additional assertion after those checks: try t.expect((try records(a, older)).len > 0);On macOS, the existing 40-record fixture now fails there with Igor Lessio - AIFLOW LABS |
92afc16 to
5f2dc7f
Compare
|
One more fix in Cause: moving the request line to the top of The early typed write now happens only when For the red check: restoring the early write for both modes reproduces the 213-line mismatch and |
|
Thanks for catching the opt-out regression. I trial-merged zig build test-request-log-replies-host test-request-log-host test-ollama-e2e-host test-environment -Dfixed-cpu -j2 --summary all
zig build test-golden -Dfixed-cpu -j2 --summary allAll 170 executed host checks passed, with one platform skip. Both lifecycle goldens matched, including the request log. The full run had 327 matching parity cases, 13 known differences, and 69 matching security cases with zero unexpected differences. The archive boundary case from my earlier note still reproduces at this head. In Igor Lessio - AIFLOW LABS |
|
Thanks @devopsfortunato. The test split is in place, and the reply-off request-log placement is restored. Oversized archives are now cut to the byte limit on successful truncation. The remaining retention issue is the record boundary: that cut can stop inside JSON, and the new fixture parses only the active file. Please retain complete records within the limit and parse both files in the boundary test, keeping the byte bounds and existing pairing checks.
|
…boundary (ashhart#4918) An archive above its limit was cut at a raw byte offset, which can stop inside a JSON record and leave a torn last line. It is now cut back to the last '\n' within the limit, keeping that newline, or to nothing when no record boundary lies within it; the archive's size still stays at or under the limit. The boundary test parses both files, so a mid-record cut is a BadRecord rather than an unchecked size, and every archived line is checked to be a whole request whose id predates the one record the active file holds. Windows keeps no request log because the writer cannot set NTFS ACLs, so test-golden says it skips lifecycle/request-log there, as it already does for SIGTERM, rather than comparing 198 frozen lines against an empty file.
|
Both points are addressed in c4760d5, on top of 5f2dc7f. Record boundary. The archive is no longer cut at a raw byte offset. Boundary test. It now parses both files - zig-windows. This PR makes the request log refuse Windows, where NTFS keeps access in ACLs, so Local (Linux x86_64, Zig 0.17.0): |
|
Thank you, @devopsfortunato. The archive now cuts at a complete-record boundary, and the fixture parses both files while keeping the size and pairing checks. The Windows golden branch prints a skip instead of reporting equality. Both earlier asks are closed, and this head merges cleanly. Ready to land after the usual final checks. Windows execution remains unrun as disclosed; the existing passing receipts are retained.
|
…ases.zig environment_test.zig was at 599 lines, so any new setting's rows broke the 600-line cap (#4918's two rows made 601). The 248-line table of valid forms now has its own file; the tests read it unchanged.
…ases.zig environment_test.zig was at 599 lines, so any new setting's rows broke the 600-line cap (#4918's two rows made 601). The 248-line table of valid forms now has its own file; the tests read it unchanged.
…boundary (ashhart#4918) An archive above its limit was cut at a raw byte offset, which can stop inside a JSON record and leave a torn last line. It is now cut back to the last '\n' within the limit, keeping that newline, or to nothing when no record boundary lies within it; the archive's size still stays at or under the limit. The boundary test parses both files, so a mid-record cut is a BadRecord rather than an unchecked size, and every archived line is checked to be a whole request whose id predates the one record the active file holds. Windows keeps no request log because the writer cannot set NTFS ACLs, so test-golden says it skips lifecycle/request-log there, as it already does for SIGTERM, rather than comparing 198 frozen lines against an empty file.
c4760d5 to
32e02fe
Compare
|
@devopsfortunato, we rebased this onto current main and pushed it as Main's It's back in a landing train.
|
…request (ashhart#3666) TENSORFOLD_REQUEST_LOG already appends every chat and completion request body as one JSON line, redacted and owner-only. It records nothing about the reply, so a finished session cannot be inspected afterwards. TENSORFOLD_REQUEST_LOG_REPLIES=1 (default 0) appends one record per finished reply to the same file: the request id, status, stream flag, finish reason, the text and reasoning the client received, prompt/cached/completion tokens, queue time, time to first token and decode rate, or a refusal's message. Streaming replies are written once complete, never per chunk, and a reply longer than 256 KiB keeps its head with "truncated": true. With the switch on, each request line becomes a typed record carrying the same id, so the two lines pair up. Off, the file is byte-for-byte what it is today: the server golden corpus compares it line by line and needs no regeneration. Background work writes neither kind, and the file keeps its owner-only, redacted rules. The Ask half of ashhart#3666. The `tensorfold log` reader and the desktop view it also describes stay a follow-up.
…boundary (ashhart#4918) An archive above its limit was cut at a raw byte offset, which can stop inside a JSON record and leave a torn last line. It is now cut back to the last '\n' within the limit, keeping that newline, or to nothing when no record boundary lies within it; the archive's size still stays at or under the limit. The boundary test parses both files, so a mid-record cut is a BadRecord rather than an unchecked size, and every archived line is checked to be a whole request whose id predates the one record the active file holds. Windows keeps no request log because the writer cannot set NTFS ACLs, so test-golden says it skips lifecycle/request-log there, as it already does for SIGTERM, rather than comparing 198 frozen lines against an empty file.
32e02fe to
25832b9
Compare
…boundary (#4918) An archive above its limit was cut at a raw byte offset, which can stop inside a JSON record and leave a torn last line. It is now cut back to the last '\n' within the limit, keeping that newline, or to nothing when no record boundary lies within it; the archive's size still stays at or under the limit. The boundary test parses both files, so a mid-record cut is a BadRecord rather than an unchecked size, and every archived line is checked to be a whole request whose id predates the one record the active file holds. Windows keeps no request log because the writer cannot set NTFS ACLs, so test-golden says it skips lifecycle/request-log there, as it already does for SIGTERM, rather than comparing 198 frozen lines against an empty file.
|
Thank you @devopsfortunato. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes. |
Part of #3666 (the "Ask" half): the request log records each reply beside its request, opt-in.
TENSORFOLD_REQUEST_LOG=PATHalready appends every chat and completion request body toPATHas one JSON line, redacted and owner-only. It recorded nothing about the reply, so a finished session could not be inspected afterwards.What it does
TENSORFOLD_REQUEST_LOG_REPLIES=1(default0) appends one record per finished reply to the same file:{"type": "reply", "id": "chatcmpl-…", "status": 200, "stream": false, "finish_reason": "stop", "text": "…", "reasoning": "…", "usage": {"prompt_tokens": 7, "cached_tokens": 2, "completion_tokens": 3}, "timings": {"queue_ms": 1.2, "ttft_ms": 3.4, "decode_tps": 56.7}, "truncated": false}{"type": "reply", "id": …, "status": 400, "error": "…"}. A reply that failed after it started keeps itserrortoo, at whatever status it got."truncated": true, so a long reply still shows its head.{"type": "request", "id": …, "body": <the redacted body>}so request and reply pair by the id the client already got — including/api/chatand/api/generate, whose request line is now written once inside the shared OpenAI path.docs/environment.mdand the CHANGELOG say so.plan()pairs with its reply. A request record past 8 MiB is refused, and its reply is still recorded.Bounds and retention
One JSON record is written per call, through a writer that serializes on a
.lockfile beside the log:<path>.1and a fresh one takes the next record, so the log keeps the newest traffic and at most 128 MiB stays on disk;flockon the never-rotated.lockfile is held across the size read, the rotation, the append and the rollback; a short write truncates back only after it actually wrote bytes.On Windows the log refuses the platform rather than write a file whose access it cannot set (NTFS keeps access in ACLs, not mode bits);
docs/WINDOWS.mdsays so.TENSORFOLD_REQUEST_JOURNALstill has its pre-existing Windows behaviour and is unchanged here.TENSORFOLD_REQUEST_LOG_REPLIESis declared incapabilities --json, validated at startup as0/1, and covered by the platform environment tests.zig build test-request-log-replies-hostruns the sixteen focused tests on their own, next to the existingtest-request-log-host.The second half of #3666 (a
tensorfold logreader and the desktop view) is not in this PR.Off, nothing changes
The server golden corpus compares the request-log file line by line. With the switch off it needs no regeneration:
zig build test-goldenreports327/340 equal to server goldens, 0 unexpected differencesand69/69 equal, 0 unexpected differences.Checks run
zig build test-request-log-replies-host— 48 passed, 1 skipped (the Windows-only test), exit 0.zig build test-request-log-host— 34/34,zig build test-ollama-e2e-host— 46/46,zig build test-environment-host— green,zig build test-golden—327/340and69/69equal to server goldens with 0 unexpected differences,zig build test-ling-host— green.zig fmt --check build.zig zig— clean;zig ast-checkon every changed.zig— clean;git diff --check— clean.On this 4-core aarch64 VPS the whole
zig build testsuite is not a reliable local gate: unrelated family tests (KDA numerics, Flash Next config, KV pool E98, an Inkling stop cell) fail under load, none in a file this branch touches. The workflow run is waiting for a maintainer's approval (first-time contributor), so the checks above are the evidence until it runs.