Skip to content

Embedder health from a real embedding, update beside a running serve, and the procprotect test that could not exit (TEN-555, TEN-556, TEN-557) - #93

Merged
Dog279 merged 9 commits into
mainfrom
fix/procprotect-test-exit-hang
Nov 27, 2026
Merged

Dog279 merged 9 commits into
mainfrom
fix/procprotect-test-exit-hang

Conversation

@Dog279

@Dog279 Dog279 commented Nov 27, 2026

Copy link
Copy Markdown
Owner

Three tickets, one commit each, plus a merge of main and the docfacts refresh.

TEN-557: the procprotect test binary that sat 22 minutes after PASS

Test files only; Protect itself is unchanged.

  • Cause. TestNowReadsTheStateAgain called TerminateThread on a thread about 10 ms after CreateThread. A thread ended while it is still starting inside ntdll leaves the loader's lock and the process heap's lock held for good, and the process can then start no thread, load no library and not exit.
  • Fix. The threads those tests end are created suspended and never run. The test binary ends itself with TerminateProcess, and its clean-up has a one-minute limit and says on stderr which step it is in, so a hang would now name itself.
  • Evidence. The unchanged binary, held to two processors with one kept busy, was still alive 20 s after PASS in 5 of 25 runs. With only the suspended threads: 400 of 400 exited. With the whole fix: 400 of 400.
  • Not checked here. An elevated run. CI's Windows runner is elevated, so this pull request's Windows job is that check.

TEN-555: "embeddings OK" from a real embedding

  • Start-up asked the embedder's /v1/models and called that "OK". A server that takes connections and returns no embedding passed. serve and the terminal UI now ask for a real embedding at start and every five minutes, and say embeddings OK, embeddings SLOW or EMBEDDINGS NOT ANSWERING with the reason.
  • New events: system 3110 (the embedder has not answered for five minutes, repeated every thirty) and 1110 (it answers again). New built-in alert rule embedder-silent.
  • tenant doctor gives the embedder 30 seconds and then fails with what to restart, where it used to wait for ever.
  • Checked against a real serve and a fake model server that hangs, answers, or answers slowly.

TEN-556: tenant update beside a running serve

  • Windows. The backup an update takes first failed on the lock files a running Tenant holds ("another process has locked a portion of the file"). Empty *.lock files are now left out of a backup; a non-empty one (a yarn.lock in a work folder) is kept.
  • An update that restarts nothing, because tenant service installed nothing, now lists the processes still running the old version and, on Windows, the scheduled tasks that start this binary, with the commands to restart each. It restarts none of them itself.
  • A development build's refusal now says how to move to a release (tenant update --force).
  • Checked with a unit test that holds a real lock (it fails without the fix, with the same error) and against a real serve. Not checked on macOS.

Checks

Local mirror on 9147205: build and vet for windows, linux and darwin; gofmt; go generate with no drift; smoke eval; go test -timeout 20m -p 3 ./... (96 packages ok, 0 failed); docfacts current. Linux -race under WSL for internal/backup, internal/logs/alerts, internal/config, internal/procprotect and cmd/tenant: ok. gitleaks and govulncheck were not run locally.

Documentation

CHANGELOG.md, docs/EVENTS.md, docs/LOGGING.md, docs/ARCHITECTURE.md and docs/serve-runbook.md are in this pull request. The public pages (first-launch/doctor.md, dashboard/logs.md, setup/requirements.md, setup/update.md, setup/backup.md) are written on a findtime-net branch that is not pushed yet: its HTML still has to be built. That pull request follows and merges when this one does.

🤖 Generated with Claude Code

Dog279 and others added 9 commits November 26, 2026 01:12
… the process could then not exit (TEN-557)

On CI's Windows runner the procprotect test binary printed PASS and then
sat, saying nothing, until go test killed it 22 minutes later (run
45771970023, the Windows job of PR 89).

TestNowReadsTheStateAgain started a thread and ended it with
TerminateThread about 10 ms later. A thread that has just started is still
inside ntdll: it holds the loader's lock and takes memory from the process
heap. Ended in that moment it leaves those locked for good, and the process
can then start no thread, load no library and not exit: ExitProcess waits
for the same locks. On an idle machine the thread is long past its start
by then; on a busy one it is not always. Held to two processors with one
of them kept busy, the test binary as it was did this in 3 runs of 22:
PASS, and still there 20 seconds later.

- The threads these tests end are created suspended and never resumed
  (neverRuns): a thread that never ran holds nothing. The victim that ends
  one of its own threads had the same fault.
- After the tests, TestMain says on stderr which step it is in, gives the
  clean-up a minute, and on Windows ends the process with TerminateProcess
  and not ExitProcess, so that nothing a test did to its own process can
  keep the binary from ending.
- TestAProtectedProcessExitsByItself: a protected process whose main
  returns exits the ordinary way. The test binary's own exit no longer
  shows that, so it is a test of its own.

Nothing in Tenant changes: Protect is not the cause (a program that never
calls it hangs the same way), and Tenant calls TerminateThread nowhere.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
docs/ARCHITECTURE.md is main's here; its generated facts are regenerated
in a later commit, once the branch's other changes are in.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…hen the embedder stops answering (TEN-555)

The two things PR 89 left open on TEN-555.

The launch line "embeddings OK" came from the embedder's model list, which
an embedder stuck on a request still answers: on the R340 it said OK while
no embedding had come back for hours. Tenant now asks for one small
embedding beside start-up and says what happened: "embeddings OK" with how
long it took, "embeddings SLOW" over 5 seconds, "EMBEDDINGS NOT ANSWERING"
after 30. Start-up does not wait for it.

The same question is put every five minutes while serve or the TUI runs.
An embedder that has given no embedding for five minutes is system 3110
(an error, written again every 30 minutes while it lasts), and the new
built-in alert rule embedder-silent fires on it; system 1110 says when it
answers again. Asking keeps the embedding model loaded while Tenant runs.

tenant doctor's two embedding checks get the same 30-second limit: they
waited for ever on such an embedder.

Checked against a real serve and a model server whose embeddings never
come back, come back, and come back after 7 seconds.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…at restarts nothing says what to restart (TEN-556)

On the R340, where two scheduled tasks of the operator's own start Tenant,
`tenant update` failed at its backup while serve ran, and with serve
stopped it swapped the binary and restarted nothing.

The backup: a master holds fleet.holder.lock for as long as it runs,
Windows does not let another process read a locked file, and the walk
stopped there ("another process has locked a portion of the file").
`tenant backup create` beside a running master failed the same way. Empty
lock files are now left out: they hold nothing and are made again. A lock
file with something in it (a package manager's, in a work folder) is kept.

The restart: `tenant update` restarts the unit `tenant service` installed
and knew of nothing else. With no such unit it now lists the processes
that run the old binary and, on Windows, the scheduled tasks whose action
names it, with their arguments and the two commands that restart a task.
It restarts none of them itself: ending a task is a hard stop.

The refusal on a development build names the running build and
`tenant update --force [--version vX.Y.Z]`.

Checked for real on Windows: a backup beside a running serve with the
fleet lock held succeeds, and the same binary without the fix fails with
the R340's error; the task scan was run over this machine's task list.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…service manager's runner (TEN-556)

CI's macOS job failed TestProcessesOfFindsAnotherProcessOfTheSameBinary:
the list came back empty. Where there is no /proc, processesOf asked ps
through runCmd. runCmd is the way to the service manager, and the test
binary closes it so that no test rewrites this machine's own service; ps
was refused with it. Outside the tests the call worked.

ps is now run directly: a list of processes changes nothing. Each column
has its own -o, which every ps reads the same way.

ps names a process by what it was started as. A process started by a bare
name (`tenant serve` typed in a shell) was not matched to the binary; its
name is now looked up on PATH.

TestProcessesByPS runs that path on Linux too, where ps gives bare names.
With the old call it fails there as it did on CI's Mac.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
@Dog279
Dog279 merged commit dbe72b4 into main Nov 27, 2026
7 of 8 checks passed
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.

1 participant