Skip to content

fix(core): a compiled-in peer's idle guard watches real work, not pid 0 (#1088) - #1102

Merged
github-actions[bot] merged 1 commit into
mainfrom
feat/plugin-activity-compiled-in-progress
Nov 2, 2026
Merged

github-actions[bot] merged 1 commit into
mainfrom
feat/plugin-activity-compiled-in-progress

Conversation

@aitrawog

@aitrawog aitrawog commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

charly box build pod-crabbox at opencharly/pod-crabbox PR #1 head d9b11549 died at the
default 90s no-progress window while BuildKit was working. This change fixes the guard's
progress SOURCE, not the window (#1088; item (c) of opencharly/.github#263).

The measured mechanism: the build peer is compiled in, so providerPid returned 0 and the
process-tree source watched nothing; a buildctl phase has no host reverse leg, so nothing
else fired; the phase died signal: killed and buildkitd logged Solve ... Canceled.

charly/plugin_activity.go now:

  1. gives a compiled-in peer the HOST's DESCENDANTS as its tree (buildctl, the engine's
    load child), with the host root excluded so the runtime's own ticks cannot mask a wedged
    call;
  2. samples CPU ticks and /proc/<pid>/io bytes (rchar+wchar), so an I/O-bound OCI
    export / engine load is observed as work;
  3. follows the charly-owned DETACHED daemon trees (buildkitd under rootlesskit, which
    re-execs and is reparented to init) for a quiet BuildKit RUN, discovered generically by
    argv under the user's charly cache/runtime roots — no daemon kind word in core;
  4. joins the watcher in stop(), so a stopped clock cannot sample after return.

The window remains readiness.no_progress (90s default). No default was raised.

How tested

Reproduction target: pod-crabbox PR #1 head d9b11549a8f47e4395a908b37cdda2f8b0aad6a2.
Live venue: a charly worktree at opencharly/charly#1101 head 0d3efd27 (the pin tree that
gets past the earlier imported-arch failure) with only this change's four files applied.
The PR branch itself is origin/main (7bb19d0a) + the same four files; origin/main alone
cannot reach the phase under test because the imported-arch fix is #1101's scope.

Pre-fix, default settings — rc=1, killed at OCI export

$ ./bin/charly version
2026.303.0223                     # pre-fix tree 0d3efd27
$ ./bin/charly -C <pod-crabbox> box build pod-crabbox
...
--- Building cachyos.arch.arch-builder ---
...
               #18 exporting to oci image format
               #18 exporting layers
charly: error: command "build": building cachyos.arch.arch-builder: ...
  --output type=oci,dest=...oci.tar ...: signal: killed: ...
rc=1

buildkitd's own record at the cancel (buildkitd.log):

time="2026-11-02T01:10:08+01:00" level=error msg="/moby.buildkit.v1.Control/Solve returned
error: rpc error: code = Canceled desc = ... failed to write compressed diff: ...
context canceled"

Pre-fix, raised bound — rc=0

$ CHARLY_PLUGIN_NO_PROGRESS=20m ./bin/charly -C <pod-crabbox> box build pod-crabbox
--- Building cachyos.arch.arch ---
--- Building cachyos.arch.arch-builder ---
--- Building cachyos.cachyos ---
--- Building pod-crabbox ---
rc=0

Intermediate arm — descendant-only source, default — rc=1 (the daemon gap)

The first version of this fix (host descendants only) passed the OCI export but still died
on the final pod-crabbox RUN: the RUN executes in buildkitd, which buildkitdrive
detaches and which is reparented to init (ppid=1), so no descendant tree reached it and the
client emitted no line for >90s:

$ ./bin/charly -C <pod-crabbox> box build pod-crabbox
...
--- Building pod-crabbox ---
#7 ... Starting full system upgrade...
charly: error: command "build": building pod-crabbox: ... : signal: killed
rc=1

buildkitd: Solve returned error ... code = Canceled desc = context canceled
(2026-11-02T01:22:47+01:00). This is why the change also follows the charly-owned detached
daemon trees.

Final — default settings, final-source binary — rc=0

The final-source binary (built with scripts/bootstrap-charly.sh) completed the same build
with the default 90s window:

$ ./bin/charly version
2026.305.2353
$ go version -m ./bin/charly | grep -E 'opencharly/(sdk|plugin-build)'
  dep github.com/opencharly/plugin-build/candy/plugin-build v0.2026305.2204 ...
  dep github.com/opencharly/sdk v0.2026305.2312 ...
$ ./bin/charly -C <pod-crabbox> box build pod-crabbox
--- Building cachyos.arch.arch ---
--- Building cachyos.arch.arch-builder ---
--- Building cachyos.cachyos ---
--- Building pod-crabbox ---
rc=0                                # elapsed 542 s

Cold arm — --no-cache, default, final-source binary — rc=0

To prove the quiet RUN and OCI export are exercised cold (not cache-short-circuited):

$ ./bin/charly -C <pod-crabbox> box build --no-cache pod-crabbox
--- Building cachyos.arch.arch ---
--- Building cachyos.arch.arch-builder ---
--- Building cachyos.cachyos ---
--- Building pod-crabbox ---
rc=0                                # elapsed 381 s
$ ./bin/charly -C <pod-crabbox> box list tags pod-crabbox
pod-crabbox  ghcr.io/opencharly/pod-crabbox:2026.306.0045  -
                                   # the emitted artifact resolves at its boundary

Unit arms (R7): fail-without and genuine-hang

All pass under go test -race:

  • TestObserve_CompiledInPeerDescendantIOIsProgress — a compiled-in peer's host child
    moving bytes is progress.
  • TestIdleBoundedContext_CompiledInPeerDescendantWorkIsProgress — the fixed clock survives
    a host child working past the window; the pid-0 source over the same live child trips
    (the failing-without-the-fix control).
  • TestIdleBoundedContext_CompiledInPeerDetachedDaemonTreeIsProgress — a double-forked,
    reparented writer (the daemon shape) is progress; with discovery OFF the same live writer
    is invisible and the clock trips (the second failing-without control).
  • TestCharlyDaemonPids_FindsProcessesUnderTheCharlyCacheRoot — the discovery itself.
  • TestIdleBoundedContext_CompiledInPeerNoDescendantWorkTrips — the genuine-hang arm:
    with the fix in place, a compiled-in peer with no working descendant and no daemon still
    trips. The host root is excluded, so the runtime's own ticks cannot keep it alive.

Gate (final tree d0dd4fc2)

All commands run with the pinned go1.26.8 toolchain; each line is the command's own exit
code.

$ go build ./...                         # rc=0
$ go vet ./...                           # rc=0
$ go test -race -count=1 -run '<activity + dispatch tests>' .
ok  github.com/opencharly/charly/charly   # rc=0
$ go test -count=1 ./charly/...          # rc=0
$ (cd charly && golangci-lint run ./...) # 0 issues, rc=0  (v2.13.2, built with go1.26.8)
$ gofmt -l charly tools                  # empty, rc=0
$ tools/*: GOWORK=off go test -count=1 ./...   # rc=0

charly version of the worktree-local build: 2026.305.2353.
(charly#1101's pin tree was used only for the live venue; the PR's own Go gate is green on
origin/main + this change.)

Rulebook compliance

  • R1 — the first failure (pre-fix default kill) was RCA'd before remediation; the
    intermediate post-fix kill (daemon gap) was RCA'd the same way and fixed in this change,
    not filed away. The reply-payload cancel-cause (root fix item 2 of charly box build: the plugin→plugin idle bound cancels a long build, and the operator sees a bare signal: killed with no bound named #1088) is separable and
    remains open on charly box build: the plugin→plugin idle bound cancels a long build, and the operator sees a bare signal: killed with no bound named #1088; it is listed below.
  • R2 — one activity mechanism: work() is the only sampled source and observe() the
    only decider; daemon and descendant roots are summed by the same treeWork.
  • R3 — no sleep-based heartbeat. The signal is real /proc CPU ticks and I/O bytes of
    processes doing the work; a dip is not progress.
  • R4 — no docs route around a defect; the fix is in the product.
  • R5 — the superseded identifiers are deleted and swept:
    git grep -nE 'providerPid|treeTicks|\.cpu\(\)|\.cpus\b|lastCPU' -- charly/ → NONE.
  • R6 — git status stated before any action; umbrella's 131 pre-existing modified
    entries were not touched; the charly submodule was clean at 046fa3bf; this worktree is
    off fresh origin/main; no force-push or bypass; no submodule edits.
  • R7 — the controls above fail without the change (pid-0 arm and discovery-off arm) and
    the genuine-hang arm still trips; the changed path ran live on the real service (pod-crabbox
    build) and the emitted image is in the local store.
  • R8 — the live venue was the real BuildKit daemon and the real pod-crabbox project;
    nothing was mocked.
  • R9 — the binary was rebuilt with scripts/bootstrap-charly.sh; charly version and
    the go version -m pins are pasted above.
  • R10 — the change-class gate (go test ./charly/..., lint, vet, gofmt, tools) passed on
    the committed tree, and the live default/cold builds passed with the default bounds.
  • Cutover — one commit, no transitional path; the old CPU-only/pid-0 source is deleted.

Change classification

Runtime Go change in the charly core. Attribution tier: fully tested and validated —
the change-class gate passed on the final tree, and the changed path executed live on the real
pod-crabbox build with default settings (cached and --no-cache).

Filed issues

  • opencharly/charly#1088 — owns this fix (root fix item 1). Root fix item 2 (surface the
    idle watchdog's cancel cause when the failure rides the build's reply payload) remains open
    there; it is separable from this progress-source fix.
  • opencharly/.github#263 — item (c) is the defect this PR fixes; (a) W5.4 CI remains.
  • opencharly/.github#264 — the required validate / validate run on head d0dd4fc2 fails in SETUP: go: ../go.work requires go >= 1.26.8 (running go 1.26.0; GOTOOLCHAIN=local) in the withdrawn-identifier sweep, with REVIEW_OUTCOME: skipped (run 41370344019, job 125039265452). This is the runner's stale workspace-root go.work, not this diff; the local gate and the live pod-crabbox arms are green.

Agent: containerd-crabbox-program/watchdog · session 8b1c01cf-7f79-4a75-bff8-240415a06208
Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated)

… 0 (#1088)

The per-call idle guard was blind to a compiled-in peer: providerPid returned
0, so the process-tree source watched nothing, and a build whose work lives in
buildkitd was killed at the 90s no-progress window while it was working
(opencharly/.github#263 item (c), measured on pod-crabbox PR #1).

Root fix in charly/plugin_activity.go:
- A compiled-in peer now watches the HOST's DESCENDANTS (buildctl, the engine's
  load child) instead of pid 0, with the host root excluded so the runtime's
  own ticks cannot mask a wedged call.
- The tree sample is CPU ticks PLUS /proc/<pid>/io bytes (rchar+wchar), so an
  I/O-bound OCI export / engine load is observed as work.
- A compiled-in peer also follows the charly-owned DETACHED daemon trees
  (buildkitd under rootlesskit, reparented to init), discovered generically by
  argv under the user's charly cache/runtime dirs -- never by a daemon kind
  word. This covers a quiet BuildKit RUN, where the client emits nothing for
  longer than the window.
- The stop func now joins the watcher, so a stopped clock cannot sample after
  return (and cannot race a restored test seam).

Tests: descendant-I/O arm, detached-daemon arm (fails with discovery off), the
daemon-discovery unit, and the genuine-hang arm (no descendant, no daemon)
still trips. R5: providerPid/treeTicks/cpu()/cpus/lastCPU are gone.

Reproduction (pod-crabbox PR #1 head d9b11549, charly#1101 pin tree):
default pre-fix rc=1 (killed at OCI export); CHARLY_PLUGIN_NO_PROGRESS=20m
rc=0; final default rc=0 (542s).

Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated)
@aitrawog

aitrawog commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

STATUS — the required validate / validate failure on head d0dd4fc2 is a SETUP failure, not a review finding. The engine never ran (REVIEW_OUTCOME: skipped), so there is no verdict to fix or rebut.

RCA — missed control

  • Expected: the required workflow runs the withdrawn-identifier sweep, then the review engine, and emits a Verdict:.
  • Actual: the job exits 1 in the sweep step after 14 s (run 41370344019, job 125039265452):
    go: ../go.work requires go >= 1.26.8 (running go 1.26.0; GOTOOLCHAIN=local)
    ##[error]Process completed with exit code 1.
    The evidence manifest records step_outcome_review=skipped.
  • Mechanism: the sweep runs go run ./retired/cmd/retired-sweep from the fetched contract directory; Go walks UP and honours a stale workspace-root go.work left by an earlier job in the same self-hosted runner workspace. That file declares go 1.26.8 while the job's toolchain is 1.26.0 with GOTOOLCHAIN=local. The pinned contract ships no go.work; the file is workspace residue.
  • Missed control: the required workflow reuses a workspace root across jobs without a clean, and the sweep invokes go run in a mode that honours an enclosing go.work it does not own. My own pre-push gate cannot reproduce it: this checkout has no stale workspace-root go.work, and the local toolchain satisfies the repo's own go.work (go1.26.8 available, go1.27.3 local).
  • Blast radius: every PR on an affected runner; the failure is indistinguishable from a real finding unless the job log is read. Two earlier heads (#1099, #1100) hit the same step and message.
  • Root fix: opencharly/.github#264 — clean $GITHUB_WORKSPACE per job, or run the contract's sweep with GOWORK=off/GOTOOLCHAIN=auto. This is org runner infrastructure, outside this PR's scope; I am not touching the runner.

What is green on this head

The diff's own gates are green on d0dd4fc2: go build, go vet, go test -count=1 ./charly/... (charly 527.9 s, pluginsgen 132.3 s), go test -race on the touched tests, gofmt -l empty, golangci-lint v2.13.2 (go1.26.8) 0 issues, tools/* rc=0. The live pod-crabbox arms are also green: default rc=0 (542 s cached, 381 s --no-cache), emitted image ghcr.io/opencharly/pod-crabbox:2026.306.0045.

opencharly/.github#264 is listed under the PR body's ## Filed issues. I will re-run the failed run once via the REST API; if it hits the same residue it stays with #264 and needs no head move.

Agent: containerd-crabbox-program/watchdog · session 8b1c01cf-7f79-4a75-bff8-240415a06208
Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated)

@aitrawog

aitrawog commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

STATUS — re-run attempt 2 on the same head d0dd4fc2 failed with the identical setup signature:

go: ../go.work requires go >= 1.26.8 (running go 1.26.0; GOTOOLCHAIN=local)
##[error]Process completed with exit code 1.
REVIEW_OUTCOME: skipped

(job 125039622862, 2026-11-02T01:04:04Z). No verdict was produced, so there is no code finding to fix or rebut; the runner's stale workspace-root go.work is unchanged by a re-run. This PR waits on opencharly/.github#264. I am not touching the runner and will not mint another same-name run. The diff's own gate and the live pod-crabbox arms remain green on this head.

Agent: containerd-crabbox-program/watchdog · session 8b1c01cf-7f79-4a75-bff8-240415a06208
Assisted-by: Claude Code deepseek-v4.1-flash:cloud (fully tested and validated)

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Review — PASS

Head SHA: d0dd4fc2b7de7cdea59e27e30e423e403f2ff69b (branch: feat/plugin-activity-compiled-in-progress)

Security screen: PASS — no T1–T4 findings. The PR does not touch the validator spec or project rulebook; it adds no secrets, credentials, network egress, or dependencies (only stdlib path/filepath); it weakens no gate. The diff is a runtime core change with the same scope the body claims (new work()/procWork source, host-descendant + detached-daemon trees, stop() join; deletion of cpu()/procTree/treeTicks/providerPid). No embedded directives in PR content or comments.

Comments considered: both @aitrawog comments are STATUS coordination metadata about the validate / validate SETUP failure (stale workspace-root go.work, REVIEW_OUTCOME: skipped) and a re-run hitting the identical signature. Re-derived against the body: consistent with ## Filed issues opencharly/.github#264; a red/in-progress CI check is not a review defect (ground rule 5) and the failure is RCA'd and filed, not dismissed as flake. No comment raises a surviving code finding.

Checklist: All applicable rules PASS or NA — placement: CORRECT (the idle guard is the reverse-channel/dispatch broker surface; no *_aliases.go growth, no new core→sdk-kit import; kind-agnostic daemon discovery keeps a daemon kind word out of core). Body accounts for the diff, attribution (fully tested and validated) is justified by the live default/--no-cache build runs plus genuine fail-without-fix arms, and the #1101-pin live venue is transparently disclosed with the Go gate green on origin/main + this change.

Verdict: PASS


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) November 2, 2026 01:47
@github-actions
github-actions Bot merged commit 8eb283a into main Nov 2, 2026
8 of 10 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Nov 2, 2026
aitrawog pushed a commit that referenced this pull request Nov 13, 2026
173 commits behind; both touched files conflicted. main rewrote the guard's progress
source — cpu() -> work()/procWork, watchedRoots, excludeRoot and the charly-owned detached
daemon trees (#984, #997, #1004, #1088/#1102, #1121) — while this branch adds the
attempted-touch source (#913). Resolved by re-basing the attempt source onto main's
structure BY HAND rather than merging text:

  - pluginActivity.touches, incremented in touch() before the non-blocking send;
  - touchAttempts(), the accessor the confirmation reads;
  - observe(wake, last procWork, lastAttempts) reports progress when ANY of the three
    sources moved: a drained host-leg event, a tree-work advance, or a grown attempt count;
  - the lastAttempts baseline is carried through BOTH call sites (the work poll and the
    expiry confirmation) and refreshed by the wake case;
  - stallReport names the third source and carries the attempt count at the kill boundary;
  - the four tests re-added on main's test file (deterministic progressing arm, the
    attempt-vs-delivery property, the unit-level third source, and the confirmation arm),
    with main's #1088 daemon/descendant tests kept intact and their observe calls updated.

Verified on THIS tree: gofmt clean; go build ./... and go vet ./... rc=0; the focused
guard tests 15/15 PASS; the full module suite go test ./... -> ok 414.387s and
ok internal/pluginsgen 142.184s, rc=0, zero failures.

*Agent: pr-charly*

*Assisted-by: DeepSeek Harness deepseek-v4.1-flash (analysed on a live system)*
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