<feed xmlns='http://www.w3.org/2005/Atom'>
<title>newos4/modules/test/test-chat-concurrency.js, branch main</title>
<subtitle>newOS4 - the browser terminal that runs WebX11 user spaces</subtitle>
<id>https://newos.webx11.duckdns.org/newos4/atom?h=main</id>
<link rel='self' href='https://newos.webx11.duckdns.org/newos4/atom?h=main'/>
<link rel='alternate' type='text/html' href='https://newos.webx11.duckdns.org/newos4/'/>
<updated>2026-11-02T19:55:56+00:00</updated>
<entry>
<title>perf(newos4): delegated agent runs no longer serialise; a waiter can't steal a lock</title>
<updated>2026-11-02T19:55:56+00:00</updated>
<author>
<name>Agando</name>
<email>roduccomm@gmail.com</email>
</author>
<published>2026-11-02T19:55:56+00:00</published>
<link rel='alternate' type='text/html' href='https://newos.webx11.duckdns.org/newos4/commit/?id=5427042d86f8e6a08a684a0315932c306472e7f8'/>
<id>urn:sha1:5427042d86f8e6a08a684a0315932c306472e7f8</id>
<content type='text'>
Closes the second half of STEER-20261102-201045-ab08.

- chat() gated the main-turn lock on nothing, so orchestrate-parallel's fan-out
  (each sub-task calling chat() on the same instance with its own agentTag) ran
  strictly one at a time. Measured 2x300ms delegated runs: 617ms before, 306ms
  now; the two 200ms user turns still take 400ms (main path stays serialised).
- the 10s lock timeout called this._chatLock = false and printed "force
  released", which cleared a lock the waiter did not own - that released the
  main turn's lock while it was still running. A waiter now throws and the owner
  is the only writer.
- delegated runs no longer clear the user's cancel flag on entry (an agent start
  used to reset this._cancelled, disarming a Stop the user had pressed).
- tool-log entries carry the run they belong to and _recentToolLog(tag, n) is
  what feeds the run log line and _postRunReview, so concurrent runs no longer
  consume each other's entries.

Known limit, unchanged: _currentTag is a single field, so under true concurrency
an entry can be attributed to the wrong run (telemetry only - the answers are
per-session). Namespacing it properly needs per-call state threading.

Test: modules/test/test-chat-concurrency.js, 7 assertions, RED before
(H1 617ms, H3 force-released, H5 no tags) and GREEN now; maintain 24/24.
</content>
</entry>
</feed>
