Skip to content

Close the gates scripts and skills walked around, bound the shell, deliver background results in the gateway - #608

Merged
FMXExpress merged 2 commits into
mainfrom
claude/opencode2-a-fixes
Oct 22, 2026
Merged

FMXExpress merged 2 commits into
mainfrom
claude/opencode2-a-fixes

Conversation

@FMXExpress

Copy link
Copy Markdown
Owner

PR A of the OpenCode 2.0 plan (docs/opencode2-plan.md): the defects the code survey turned up, which the later PRs (Code Mode, async shell, permissions) build on. No new features here except the shell timeout; every item is a gap in something that already existed.

What was wrong, and what changed

1. The execute_code tool RPC bypassed every dispatch gate. A script's pasclaw __tool <name> reached Registry.RunTool directly, so a plan-mode turn could mutate through a script, no BeforeToolCall hook ever saw the call, and the output cap did not apply.

  • PasClaw.Tools.Registry gains IToolDispatcher and a capture hook; PasClaw.Tools.ToolLoop implements it (TLoopDispatcher over DispatchOneToolCall: mode gates, hooks, preflight, promptware scan, output cap) and publishes the in-flight config per thread.
  • execute_code captures a dispatcher on the dispatching thread; the RPC server uses it. Registry-only harnesses with no loop keep the old path.
  • Tested on the dispatcher directly and end to end over the loopback socket (test-rpc-gate). Negative-tested by bypassing the dispatcher: the refusal assertion failed, as it should.

2. Subagent scripts reached the parent's registry. BuildFilteredRegistry copied the parent's execute_code record, runner included, so a subagent's script dispatched into the parent's full tool surface, the bypass the per-registry runner was built to close. The child registry now re-registers execute_code bound to itself. Tested by comparing runner identity for the wildcard and explicit-list shapes.

3. Shell skills skipped the denylist. A kind: shell skill ran RunOneShot with no ShellAllowed, outside the shell backend, and with no Category, so plan mode let it through and the Docker backend had a side door. The rendered command now passes the denylist, runs through the active backend, and shell skills are tcMutating (prompt skills tcReadOnly). Tested with a recording backend and a denylisted template (test-skills-shell-gate).

4. shell_exec had no timeout. The only bound was the 1 MiB output cap. New shell_timeout_sec (default 600), applied through PasClaw.Platform to the local and Docker paths, kills the child on expiry with exit=124 and a "timed out after N s" note. shell_exec gains a timeout_sec argument, implemented as a thread-scoped override so parallel calls cannot leak into each other. Tested with real sleeps on POSIX and a config round-trip (test-shell-timeout).

5. Background subagent results never reached gateway sessions. The gateway registered spawn_background and never set BackgroundDrainKey; and one coordinator serves every session, so a single key could not have been right anyway. Jobs are now stamped with the drain key of the dispatch that spawned them, DrainByKey walks every coordinator for jobs stamped with the asking loop's key, and the four gateway loop builders set the key beside the steering key. Tested gateway-shaped: a coordinator with no key, a spawn through a dispatcher for session A, a loop for session B that sees nothing, a loop for A that sees it once.

6. No client sent the session header. TPasClawClient.Chat gains SessionId (sent as X-PasClaw-Session) and SessionContext (session_context: true), so a client can send one message and have the gateway hold the transcript. This is the prerequisite for attach mode (PR F).

7. The TUI never built the real system prompt. A TUI turn sent only the working-state snapshot plus a short mode blurb, so it saw no memory, no facts, no AGENTS.md, no skills catalog, while pasclaw agent on the same workspace saw all of it. It now calls BuildSystemPrompt like the CLI and gateway and appends the working state.

Config

shell_timeout_sec (default 600, 0 = none). Documented in configuration.md; tools.md and security.md describe the gated RPC, skill gating and the timeout.

Verification

  • Full make test: 45 passes, 0 make errors. Three new targets in the aggregate: test-rpc-gate, test-skills-shell-gate, test-shell-timeout; test-subagent-default and test-subagent-bg gained cases.
  • Not covered by an automated test: the client header (the client tests need a live gateway and skip without one) and the TUI prompt change (no TUI harness). Both are small and were read carefully.

Generated by Claude Code

…liver background results in the gateway

The first PR of the OpenCode 2.0 plan (docs/opencode2-plan.md): the
defects the code survey found, which everything after depends on.

The tool RPC goes through the dispatch gates. A script's `pasclaw
__tool` reached Registry.RunTool directly, so a plan-mode turn could
mutate through a script, no BeforeToolCall hook ever saw the call, and
the output cap did not apply. PasClaw.Tools.Registry gains
IToolDispatcher and a capture hook; PasClaw.Tools.ToolLoop implements
it (TLoopDispatcher over DispatchOneToolCall: mode gates, hooks,
preflight, promptware scan, output cap) and publishes the in-flight
config per thread; execute_code captures a dispatcher on the dispatching
thread and the RPC server uses it. Registry-only harnesses keep the old
path. Tested on the dispatcher and end to end over the loopback socket;
negative-tested by bypassing the dispatcher, which failed on the
refusal assertion.

Subagent scripts stay in the subagent's registry. BuildFilteredRegistry
copied the parent's execute_code record, runner included, so a
subagent's script dispatched into the parent's full tool surface -- the
bypass the per-registry runner was built to close. The child registry
re-registers execute_code bound to itself. Tested by comparing runner
identity for the wildcard and explicit-list shapes.

Shell skills are shells. A kind:shell skill ran RunOneShot with no
ShellAllowed, outside the shell backend, and with no Category, so plan
mode let it through and the Docker backend had a side door. Now the
rendered command passes the denylist, runs through the active backend,
and the tool is tcMutating (prompt skills tcReadOnly). Tested with a
recording backend and a denylisted template.

shell_exec has a timeout. There was none; the only bound was the 1 MiB
output cap. shell_timeout_sec (default 600) in config, applied through
PasClaw.Platform to the local and Docker paths, kills the child on
expiry with exit 124 and a "timed out after N s" note; shell_exec's new
timeout_sec argument overrides it per call through a thread-scoped
override that cannot leak between parallel calls. Tested with real
sleeps on POSIX and a config round-trip.

Background subagent results reach gateway sessions. The gateway
registered spawn_background and never set BackgroundDrainKey; and one
coordinator serves every session, so a key could not have been per
session anyway. Jobs are now stamped with the drain key of the dispatch
that spawned them (CurrentDispatchDrainKey, from the same per-thread
publish as above), DrainByKey walks every coordinator for jobs stamped
with the asking loop's key, and the four gateway loop builders set the
key beside the steering key. Tested gateway-shaped: a coordinator with
no key, a spawn through a dispatcher for session A, a loop for session B
that sees nothing, a loop for A that sees it once.

TPasClawClient sends the session. Chat gains SessionId (sent as
X-PasClaw-Session) and SessionContext (session_context: true), so a
client can send one message and have the gateway hold the transcript --
the prerequisite for attaching a second surface to a running session.
Previously no client sent the header the gateway reads.

The TUI builds the real system prompt. A TUI turn sent only the
working-state snapshot plus a short mode blurb, so it saw no memory,
no facts, no AGENTS.md, no skills catalog, while `pasclaw agent` on the
same workspace saw all of it. It now calls BuildSystemPrompt like the
CLI and gateway and appends the working state.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LGQKz579j1ZnDRwmr6h1V6
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T07:18:11.159016Z ffa0c63 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ffa0c638ed

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1276 to +1280
if (TimeoutMs > 0) and (Trunc((Now - StartT) * 86400000.0) >= TimeoutMs) then
begin
TimedOut := True;
P.Terminate;
Break;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Terminate the whole process tree on timeout

When a shell command launches another process, the timeout only terminates the /bin/sh wrapper and then immediately exits the capture loop. In the Delphi/POSIX implementation, for example, TStdioProcess.Terminate is explicitly kill(FPid, SIGTERM), so a compiler, test runner, or even sleep 100 spawned by the shell can continue running after PasClaw reports exit=124. Start the child in a process group and terminate that group (and apply equivalent tree termination on the other platforms) so the wall-clock bound actually stops the command.

Useful? React with 👍 / 👎.

Comment thread src/pkg/config/PasClaw.Config.pas Outdated
Comment on lines +2870 to +2872
{ The shell wall-clock bound lives in PasClaw.Platform, which every shell
path (local, docker exec, skills) runs through. }
SetShellTimeoutMs(C.ShellTimeoutSec * 1000);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Scope the shell timeout to tool commands

Applying this value as a process-wide default inside the generic RunOneShot primitive also caps unrelated callers, not just the documented shell_exec, execute_code, and shell-skill paths. In particular, PasClaw.Apps.Runner uses RunOneShot for application builds and PasClaw.Cmd.Profile uses it for whole benchmark-agent runs, so the new default silently kills either operation after 600 seconds and reports it as a build/experiment failure. Pass the timeout through the shell backend/tool paths instead, or give non-tool callers an explicit opt-out.

Useful? React with 👍 / 👎.

Two findings, both real, both now pinned by tests verified to fail
without the fix.

Terminate the whole process tree (P1). Every shell command runs as
`/bin/sh -c <cmd>`, so terminating the child signalled the wrapper and
nothing else: a compiler, a test runner or a bare `sleep 100` underneath
it kept running while PasClaw had already reported exit=124. The wall
clock has to stop the work, not the wrapper.

New TerminateProcessTree walks /proc for the descendants of the pid,
signals deepest-first so a parent cannot reap-and-respawn past us,
SIGTERM, then SIGKILL whatever survives a short grace. Windows hands it
to `taskkill /T /F` -- the documented tree kill, and no Toolhelp32
snapshot whose declarations differ between the two compilers. All five
timeout sites use it, and still signal the direct child afterwards so
the pipe closes and the capture loop is never left hanging.
TStdioProcess gained a ProcessId accessor (and Delphi/Windows now keeps
PI.dwProcessId) because a tree kill needs the pid, not the handle.

Bound the tool shells, not every caller (P2). The timeout was a
process-wide default that RunOneShot read directly, so it capped
callers that are not tool commands at all: PasClaw.Apps.Runner builds
an app through that primitive and PasClaw.Cmd.Profile runs a whole
benchmark agent through it, and a 600 s shell default silently killed
either and reported it as that job failing.

EffectiveShellTimeoutMs now returns the per-thread override and nothing
else. The configured default is stored by SetShellToolTimeoutMs and
applied by the *ViaBackend wrappers in PasClaw.Shell.Backend -- which
is exactly what shell_exec, execute_code and shell skills run through,
and nothing else does. An explicit per-call bound still wins, and the
borrowed override is restored on the way out so one tool call cannot
leak its bound into the next thing the thread runs.

Verified on Linux/FPC: a grandchild that records its pid and sleeps 30 s
is gone 700 ms after its shell times out (and survives when the tree
kill is reverted); a bare RunOneShot runs its full 2 s past a 700 ms
tool default (and is killed at 700 ms when the scoping is reverted);
the tool path is still bounded. The Windows and Delphi arms are written
but not executed here -- no dcc64 in this container. Full make test
green. Docs corrected: they claimed every shell path was bounded and
that "the child" was killed.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KYD1zZPD7GuM8pF1btwi2U
@FMXExpress
FMXExpress merged commit 39d9b41 into main Oct 22, 2026
FMXExpress pushed a commit that referenced this pull request Oct 22, 2026
Only docs/configuration.md conflicted: this branch added the
mcp_codemode_default and mcp_servers[].codemode rows directly above the
shell_timeout_sec row that #608 rewrote in main. Kept both new rows and
main's corrected timeout row.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KYD1zZPD7GuM8pF1btwi2U
FMXExpress pushed a commit that referenced this pull request Oct 23, 2026
docs/configuration.md and docs/tools.md conflicted: both sides touched
the shell_timeout_sec row and the shell_exec timeout paragraph -- #608's
tree-kill wording in main against this branch's background-jobs rows.
Kept both, with the tree-kill wording, and said that cancelling a
background job kills the tree too (which the next commit implements).

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KYD1zZPD7GuM8pF1btwi2U
FMXExpress pushed a commit that referenced this pull request Oct 23, 2026
…fe to tear down

Three review findings on the background-jobs PR, plus a Delphi build
break the review did not mention.

**The Delphi build of this branch did not compile.** A stray `if S <> ''
then Flash(S); end;` sat at the top level of PasClaw.TUI.pas, left behind
when a routine header was deleted. It is inside the file's big
{$IFNDEF FPC} block, so FPC never parsed it and `make test` was green;
only dcc64 would ever have seen it. Deleted, and
scripts/check-pascal-shape.py (which `make test` already runs through
test-desktop) gained the rule that would have caught it: after a line
that is exactly `end;` in column 0, the next line of code must start a
new declaration in column 0, not an indented statement. Clean across
every .pas and .dpr in the tree; the rule stays narrow because this
file's own notes record that a begin/end balance check was tried here and
removed for crying wolf.

**Cancel and timeout killed only the shell wrapper.** Everything the
command had started -- compiler workers, a `make -j`, anything launched
with `&` -- kept running after spawn_cancel reported the job killed,
still writing files with nothing holding a handle to them. All three
exits of the job loop (cancel, timeout, output cap) now go through
TerminateProcessTree, the same call PasClaw.Platform's own one-shot
timeouts use.

Codex asked for an isolated process group instead. There is no portable
way to get one here: FPC's TProcess has no POSIX process-group option
(poNewProcessGroup is Windows-only) and `setsid` is not a binary to count
on (util-linux ships one, macOS does not). The parent-link walk catches
every descendant that has not deliberately re-parented itself, and on
Windows is `taskkill /T /F`.

While there: PasClaw.Platform's own output-cap exits had the same leak --
#608 fixed the timeout exit and left the cap signalling the shell alone,
in RunOneShot, RunOneShotWithEnv and RunArgvCapture. Worse than it looks,
because the orphaned flooder keeps writing into a pipe nobody reads any
more and RunOneShot never returns.

**Clearing the completion hook did not wait for a callback in flight.**
`if Assigned(GBackgroundDoneHook) then GBackgroundDoneHook(...)` has a
window between the test and the call. The TUI installs a method of the
TTUI object and clears the hook on its way to freeing that object, so a
job finishing during an ordinary shutdown could run a method of freed
memory. The hook now lives behind SetBackgroundDoneHook /
FireBackgroundDone, which take the same lock: clearing it blocks until a
running handler returns and no new one can start. The lock is nilled but
never freed at finalization, for the same reason the TUI leaks
FToolActivityLock -- a worker handed to the OS by FreeOnTerminate may
still be on its way in. With the teardown now ordered, TTUI.Destroy can
free FBgFlashLock properly, at the end rather than before the thread
joins.

**The FPC TUI never showed a completion.** BackgroundDone parked the
line, but DrainBackgroundFlash was only called from the Delphi frame
loop, so the FPC branch of it was dead code and the operator was told
nothing. The line REPL now drains at the two moments it is looking at the
prompt: before printing it, and right after the operator's Enter.

Tested (test-subagent-bg, test-shell-timeout), each fix negative-verified
by reverting it:

  - cancel and timeout: a grandchild records its pid and sleeps 45 s;
    both exits must leave it dead. Reverting the tree kill fails on the
    cancel case.
  - hook teardown: a handler that sleeps 600 ms, caught mid-call, then
    the clear is timed. Reverting the lock fails -- the clear returns
    while the handler is still running.
  - the output cap, in shell_timeout_tests: `yes` floods past 1 MiB with
    a grandchild recorded. Reverting this one does not fail, it HANGS,
    which is the second half of the bug.
  - both TTUI.Run bodies are checked to call the drain, since neither
    loop can be driven from a test (one positions a console, the other
    blocks in ReadLn). The check strips comments first -- its first cut
    passed on a body that only mentioned draining in a comment.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KYD1zZPD7GuM8pF1btwi2U
FMXExpress pushed a commit that referenced this pull request Oct 23, 2026
Four conflicts, all from both sides touching the same lines:

  Makefile / docs/configuration.md -- this branch's new rows and target
  sit where #608's tree-kill rewording landed. Kept both.

  PasClaw.Config.pas -- ApplyConfigGlobals: main renamed the shell
  timeout setter to SetShellToolTimeoutMs, this branch added the
  permission-rule wiring right beside it. Kept both.

  PasClaw.TUI.pas -- TTUI.Destroy. #610 moved FBgFlashLock.Free to the
  end (after the thread hand-off) and this branch had added the ask
  state's Free beside it at the top. Resolved by not freeing the ask
  lock or event at all: a worker parked in AskPermission leaves it
  within a poll slice of FQuit, but the bounded wait hands the thread to
  FreeOnTerminate after the same 250 ms, so Destroy cannot know it has
  left -- the same reasoning the file already records for
  FToolActivityLock.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KYD1zZPD7GuM8pF1btwi2U
FMXExpress pushed a commit that referenced this pull request Oct 23, 2026
main now carries #608 through #613, which this branch was stacked on.
One conflict, in the Makefile: this branch's new test-skill-args and
test-instructions targets sat beside test-runfile, which #613 made
depend on $(BIN). Both kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KYD1zZPD7GuM8pF1btwi2U
FMXExpress pushed a commit that referenced this pull request Oct 23, 2026
main moved on by #608 through #614 since this branch was cut. Five
conflicts, all two independent additions side by side, all kept:

  - Cmd.Gateway / Cmd.Serve / Cmd.TUI uses clauses: this branch's
    PasClaw.MCP.Disclosure (for the --no-mcp registration) beside
    main's PasClaw.Gateway.RunFile, and in the TUI beside Worktree,
    Cmd.Attach and Client.Api.
  - docs/configuration.md: the builtin_progressive_disclosure row beside
    main's code-mode, background-jobs, permissions, worktree, cli.attach
    and shell-timeout rows.
  - docs/mcp.md: "Built-in long tail" beside main's "Code Mode".

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KYD1zZPD7GuM8pF1btwi2U
FMXExpress pushed a commit that referenced this pull request Oct 26, 2026
main moved on by #608 through #615 since this branch was cut. Two
conflicts:

  - Makefile, the .PHONY list and the `test` prerequisites: main's lines,
    plus this branch's one target, test-workspace-listing (which the
    branch's .PHONY line also carried twice).
  - PasClaw.Agent.Prompt interface: this branch's WorkspaceTopLevel /
    SafeEntryName beside #614's BuildInstructionsSection. Both kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KYD1zZPD7GuM8pF1btwi2U
FMXExpress pushed a commit that referenced this pull request Oct 26, 2026
main moved on by #608 through #616 since this branch was cut. One
conflicted file, the Makefile, in three places: the .PHONY list and the
`test` prerequisites take main's lines plus this branch's one target,
test-steering-fastpath; its recipe sits beside #616's
test-workspace-listing, where both had been added.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KYD1zZPD7GuM8pF1btwi2U
FMXExpress pushed a commit that referenced this pull request Oct 26, 2026
main moved on by #608 through #617 since this branch was cut. Five
conflicted files, all two independent additions side by side, all kept:

  - Makefile: main's .PHONY and `test` lists plus test-verify; its
    recipe beside #617's test-steering-fastpath.
  - Cmd.Agent BuildLoopConfig: the --scenarios / verification block
    beside the permissions OnAsk wiring.
  - Config: the Verification field, its defaults and its loading beside
    shell_timeout_sec, mcp_codemode_default, background_jobs_max,
    permissions, worktree, cli and instructions.
  - ToolLoop: ScenariosDir / VerifyMaxRounds beside OnAsk and
    Workspace; PasClaw.Tools.Sandbox listed once, for both uses.
  - docs/configuration.md: the two verification rows after main's.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KYD1zZPD7GuM8pF1btwi2U
FMXExpress pushed a commit that referenced this pull request Oct 26, 2026
… it, output is data

Four review findings on #618.

**P1: an empty scenario set passed.** RunScenarios started from True
and looped over nothing, so a misspelled, missing or empty
verification.scenarios -- or one holding only README and hidden files
-- came back Verified: /v1/chat said ok, the CLI printed a green "0/0
scenarios passed". The exact false success the feature exists to
prevent, from a typo. Nothing to run is now False, with its own summary
("verification FAILED: no scenarios to run in <dir> -- check
verification.scenarios ..."), and it is not fed back to the model,
which has nothing to fix.

**P1: /v1/chat/completions and /v1/responses never said a check
failed.** Every gateway chat path runs verification, but only /v1/chat
read the result; the OpenAI-compatible routes returned the model's
answer with an ordinary completed status. Both now end the answer text
with "[<summary> -- this answer is NOT verified: the operator's
held-out checks did not pass]" when the last round failed, streamed or
not -- a client that ignores unknown fields still sees it -- and a
non-streaming reply carries the same `verification` object /v1/chat
returns. A verified answer is untouched. /v1/responses only runs the
loop without client-supplied tools, and only then reports.

**P2: a hanging scenario.** Already bounded once main was merged in:
RunOneShotViaBackend applies shell_timeout_sec (#608) and kills the
scenario's process tree on expiry with exit 124, a failed result. Now
said where the call is, documented, and tested.

**P2: scenario output went into a user turn unscanned.** A failing
assertion echoes workspace files and fixtures, which the checkout
controls, and the feedback turn is a USER message. The output now goes
through MaybeFlagPromptware like every tool result, under a label
saying it is the check's output, quoted as data.

Tested, each negative-verified:

  - verify_tests: a missing, an empty and a README/hidden-only
    directory each fail RunScenarios; through the loop the empty set is
    not verified, says why, and feeds nothing back (one model call). A
    `sleep 30` scenario under a 1.5 s timeout fails with exit 124 in
    under 10 s -- with the timeout off it runs out and passes. Output
    carrying "Ignore all previous instructions" is bannered and
    labelled, and the real failure line still arrives. The notice is ''
    when verified or never run. Reverting each fix fails its case.
  - verify_routes_e2e.py (new, `make test-verify-routes`, real binary):
    a scratch gateway with the relay provider and one held-out scenario.
    Failing: chat/completions and responses, streamed and not, all end
    with the notice, and the JSON says verification.ok false. Passing:
    no notice, ok true. With the gateway wiring reverted the answer is
    the bare "all done" and the test fails.

docs/gateway.md: the two routes' rows say how they report verification
(and /v1/responses streams, which the row denied). docs/configuration.md:
the timeout, the scan, and that an empty set fails.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KYD1zZPD7GuM8pF1btwi2U
FMXExpress pushed a commit that referenced this pull request Oct 26, 2026
Three Delphi-only compile errors in PasClaw.Gateway.RunFile (from #613),
none of which FPC sees -- two are in the Windows branch and the third is
an FPC-only RTL function:

  - E2003 PROCESS_QUERY_LIMITED_INFORMATION: dcc64's Winapi.Windows does
    not declare it. Declared here as RUNFILE_PROCESS_QUERY_LIMITED
    ($1000) under MSWINDOWS -- our own name, so it cannot collide with a
    Windows unit that does.
  - E2003 LocalTimeToUniversal: FPC's DateUtils only. started_at now
    comes from PasClaw.Utils.NowIsoUtc, which already picks
    TTimeZone.Local.ToUniversalTime on Delphi (as Agents and MemoryFetch
    do) and quotes its separators: the old format string left ':' bare,
    which FormatDateTime replaces with the locale's time separator.
    DateUtils is no longer used and leaves the uses clause.
  - E2010 DeleteFile: Winapi.Windows comes after SysUtils in scope on
    Delphi, so its DeleteFile(PWideChar) won over SysUtils.DeleteFile.
    Now SysUtils.DeleteFile, by name.

A scan of the units #608 through #618 touched found no other unguarded
FPC-only identifier and no other Windows-shadowed RTL call.

Tested: FPC build, test-runfile (now also checks started_at is ISO 8601
UTC with literal separators). Not run: dcc64 -- there is no Delphi
compiler in this environment, and no win64 RTL for FPC either, so the
Windows branch is unbuilt here.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KYD1zZPD7GuM8pF1btwi2U
FMXExpress pushed a commit that referenced this pull request Oct 26, 2026
dcc64 stopped in PasClaw.Backup with E2003 on GetProcessID (lines 697
and 786, the stage and restore temp dirs), so PasClaw.Maintain and
everything above it failed with F2063. GetProcessID is FPC's SysUtils
only.

PasClaw.Platform gains CurrentPid: GetProcessID on FPC, and on Delphi
GetCurrentProcessId / getpid from Winapi.Windows / Posix.Unistd, which
Platform already uses. It lives there rather than as a fourth private
copy (Cmd.Relay, Tools.RPC and Gateway.RunFile each have one) because
the alternative for Backup -- Winapi.Windows in its own uses clause --
would let Windows' DeleteFile and friends shadow SysUtils' in a unit
that deletes and copies files, the error #620 fixed in RunFile. Backup
lists Platform ahead of its other PasClaw units, and Platform exports
no RTL name, so nothing it already resolved changes.

The same scan, over all of src this time rather than only the units
#608-#618 touched (Backup predates them, which is how #620's scan
missed it), found one more: the gateway's permission-ask id called
GetTickCount64, which PasClaw.Cmd.Relay records as dcc64 E2003. The id
now takes its prefix from DateUtils.MilliSecondOfTheDay, same
resolution and same purpose -- a restarted gateway's ids stay apart
from ones a stale web UI tab may still answer. Not Random: nothing in
the gateway calls Randomize, so its sequence repeats every restart.
With these, the scan finds no unguarded FPC-only identifier in src.

Tested: FPC build; test-backup, test-maintain, test-permissions. Not
run: dcc64 -- no Delphi compiler here.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KYD1zZPD7GuM8pF1btwi2U
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.

2 participants