cccc icon indicating copy to clipboard operation
cccc copied to clipboard

Read-only primitives the reaper reconstructs externally

Open chriscoveries opened this issue 1 month ago • 4 comments

An external worktree reaper (cwf reap) reconstructs actor working directories by reading /proc/<pid>/cwd itself, because cccc actor list does not expose cwd.

Request: expose a cwd field on actor rows for actors the daemon started, so external tools stop reading process state.

Separately, request a path field on each Group's read-only scope entry: the filesystem path after the daemon resolves aliases, symlinks and relative forms, or null if the scope is non-filesystem or cannot be resolved. This lets an external tool resolve an actor's configured scope key to the daemon's filesystem path without reimplementing that resolution.

Constraints we accept: cwd is one fact for daemon-started actors only; it does not replace the inherited process-identity scan, and privilege/incomplete-scan constraints stay. The process-use inventory (including CARGO_TARGET_DIR) remains the tool's responsibility.

Thank you to the maintainer for #171's invitation to identify read-only gaps separately. We will not ask cccc to implement reaping policy or accept/reject decisions in core.

How we checked

On our staging instance (cccc 0.4.44; KVM guest, 8 vCPU Intel Skylake, 15 GiB RAM, Debian 13):

  • None of the five actor rows from actor_list has a cwd key.
  • Four of those actors were running with published PIDs, and each had a readable process cwd. The stopped actor had none, and we did not guess one.
  • Our reaper reads /proc/<pid>/cwd for each published PID today. The proposed field would replace exactly that read and nothing else.

chriscoveries avatar Oct 24 '26 20:10 chriscoveries

Thanks for the precise request and the staging check.

actor_list rows, and therefore cccc actor list, now include effective_scope: {scope_key, path, source}, or {} when it is unavailable. For a running actor that the daemon started, source is "runtime_launch" and path is the canonical directory it was launched in. We did not call it cwd: it is the immutable launch workspace, not a live reading of the process's current directory or of directories its child processes use. Managed actors that are not running report their next-start configuration instead ("actor_default" or "group_active"), and for Native Actors it describes only CCCC's tool scope, not the original application's working directory. A missing directory yields {} rather than a substitute path.

For scopes, we kept the existing url field rather than adding a separate path field. It contains the stored directory path: the canonical absolute directory recorded at attach time, which is the Git top-level when inside a work tree and otherwise the path itself. Reads return it as recorded. It is not a fresh existence check; effective_scope canonicalizes it again and reports a missing directory as unavailable. Note that scope_key derives from the normalized origin remote when there is one, so separate clones or worktrees of one remote share a key, and a Group binds each key to one directory at a time.

Both are documented in docs/standards/CCCC_DAEMON_IPC_V1.md. The field is a read-only observation: it is not persisted and grants no file or tool authority. This has been implemented and validated locally; it has not been committed or released yet.

ChesterRa avatar Oct 27 '26 08:10 ChesterRa

Thank you, effective_scope on actor_list rows covers most of this. One gap remains for an external cleanup tool: the field is the launch workspace, not the directory a running Actor's process or its children are working in now, so the tool still can't tell which on-disk working directory a running Actor is using without reading daemon internals.

Would you consider a read-only primitive for that, or should we treat the launch workspace as the supported contract? If it's the latter, we'll close this.

chriscoveries avatar Nov 04 '26 11:11 chriscoveries

Thank you for following up, and for stating the remaining gap so precisely.

Please treat the launch workspace as the supported contract. For a running actor that the daemon started, effective_scope.path with source: "runtime_launch" is the directory the daemon launched it in, and it does not change while that process runs.

We do not plan to add a live-directory primitive. The only generic live observation available would be the same process cwd your reaper reads today, and that does not show where the agent actually works: agents run their tools and commands in child processes with their own working directories. A field that looked authoritative but missed those directories would make cleanup less safe, not more. Your existing process scan remains the right source for directories that child processes use.

As you offered, please close this when you are ready. Thanks again for keeping the request read-only and for checking it against a real instance.

ChesterRa avatar Nov 04 '26 23:11 ChesterRa

Thank you, that settles it. We'll treat effective_scope.path with source: "runtime_launch" as the launch-workspace contract, and keep our process scan as the source for directories that child processes use. Closing.

chriscoveries avatar Nov 05 '26 22:11 chriscoveries