Commit Graph
2481 Commits
Author SHA1 Message Date
Alexandre Teixeira e1bc13b634 test: retain ownership of sockets and subprocess groups 2026-10-03 03:46:52 +01:00
Alexandre Teixeira 6eb0bbfe70 test: isolate pytest runtime defaults across workers and runs 2026-10-03 03:46:52 +01:00
Alexandre Teixeira a52c657150 test(web): repair negative security witnesses 2026-10-03 03:46:52 +01:00
Alexandre Teixeira decfab12f9 fix(tests): preserve bootstrap reference locations 2026-10-03 03:46:52 +01:00
Alexandre Teixeira 9fd6919ee9 fix(tests): isolate database and module state 2026-10-03 03:46:52 +01:00
Alexandre Teixeira 3468ad36d7 Merge pull request #62 from pewdiepie-archdaemon/feature/effects-provenance-wave4
feat(runtime): add durable effect provenance and truthful completion
2026-10-03 03:10:58 +01:00
Alexandre Teixeira 7563d859bc fix(effects): close independent review correctness gaps 2026-10-03 02:55:31 +01:00
Alexandre Teixeira da4bf3531f Merge frozen lab b1666951 (Wave 3) into Wave 4 effects provenance
Integrates the merged and frozen Wave 3 lab commit
b1666951faf8285054e1ca90f11533b0fb53fb57 with a normal merge, preserving
every Wave 4 commit unchanged.

Conflict: src/agent_runtime/resources.py. Wave 3's _control_plane_snapshot()
/ _control_plane_path(path, *, snapshot=None) split is kept. The snapshot adds
the effect-store directories to its prefix set after the recursive job-dir
inventory and no longer references path (the auto-merged prefix check would
have raised NameError there). _control_plane_path calls _aliases_effect_store
after its os.stat, only for multiply linked files, so single-link files never
list the store.

Semantic reconciliation (no textual conflict): bg_monitor keeps launch
settlement right after the first successful validate_job and before the
authority check, with Wave 3's post-drain revalidation intact. The
deleted-session branch, terminal before linkage validation, now settles a
validated launch too: that job is later pruned and its publication retired,
which would otherwise leave its effect RUNNING. Regression tests cover the
snapshot form of the effect-store check and both deleted-session linkage
outcomes.
2026-10-03 01:13:36 +01:00
Alexandre Teixeira 3e43809ed6 docs(effects): record corrective pass and Wave 3 rebase checklist 2026-10-03 01:00:18 +01:00
Alexandre Teixeira 4d07e2da2d test(effects): close Wave 4 adversarial regressions
Real-seam coverage for each corrective fix, each checked by mutation:
requested edit/patch states (CRLF-exact, unrelated change contradicts,
partial read and underivable targets stay unverified, superseded effects are
history); directory and launch-index fsync order observed via real fsync
targets; dispatch refused when the directory fsync fails; independent
objects, threads and processes never reuse positions; settle-once and
recovery against another writer; torn-tail repair; unbound tools cannot
manufacture RUNNING/cleanup/facts or settle launches; external effects never
complete as satisfied, are always disclosed, and passing tests stay test
facts; verifier staleness and RUNNING launches without obligations;
known-scope child effects leave unrelated parent evidence fresh; browser page
refusal survives a matching approval and child authority with no claim, no
execution id and no producer call; effect-store hardlinks are caught without
scanning the store.

Replaces the uncommitted tests that asserted a CONTENT_CHANGED predicate and
blocking on any RUNNING effect.
2026-10-03 00:58:32 +01:00
Alexandre Teixeira 7267341d49 fix(effects): protect provenance control state efficiently
A hardlink into the effect store was protected only by the log's own nlink
refusal, which an agent could undo by removing the alias after writing
through it. Adding the store to the recursive control-plane inventory would
make every path check cost grow with accumulated runs. _aliases_effect_store
instead uses the store's invariants: logs and launch indexes refuse
st_nlink != 1 and the store is flat, so only a multiply linked regular file
on the store's device is compared by inode against one non-recursive listing.
Single-link files cost nothing and the store is never rglob-inventoried. The
helper takes a stat result so it plugs into Wave 3's scan-local snapshot after
the rebase.
2026-10-03 00:58:32 +01:00
Alexandre Teixeira b23c6d40b3 fix(effects): require evidence for external completion claims
Effect obligations were consulted only for declared artifacts, and reported
external success could be presented as done. Now, regardless of declared
artifacts:

- the latest effect on any changed file contradicted by a fresh readback
  fails the run (a superseded earlier effect is history, not a contradiction);
- a passing verifier followed by an effect that may have changed state
  without settled evidence is stale (BLOCKED);
- executed external effects that are not VERIFIED cap the decision at
  UNVERIFIED, and the answer always carries server-authored facts for them
  ("reported success; any external change it made was not independently
  verified", "reported failure", "unknown outcome").

The disclosure is structural and does not depend on recognizing the model's
wording. When it is the only change, the model's answer events are released
unchanged and the disclosure follows as one delta (and in round_texts).
Prose filtering is also tightened (remote verbs are mutation claims, an
unnamed "I updated it" cannot borrow the single required artifact, bare
"Done." is a terminal claim beside unverified external effects). A passing
verifier still supports test claims; it never speaks for the external effect.

Replaces the uncommitted attempt that blocked every run with any RUNNING
effect: a background launch with no declared obligations completes
UNVERIFIED.
2026-10-03 00:58:32 +01:00
Alexandre Teixeira 682b44a3ec fix(effects): preserve producer trust boundaries
Result-dictionary keys could set lifecycle state for any producer: a dynamic
or registry tool returning bg_job_id/detached became RUNNING, teardown became
verified cleanup, and timed_out/failure_kind/mutation_attempted/containment
were copied from untrusted results. Facts are now scoped to the producer the
dispatcher actually bound. An unbound tool contributes its exit status alone.
RUNNING requires a bound process producer (and an exact launch reservation
for bg_job_id), cleanup is attested only by a bound process producer, and job
observations and launch settlement only by a bound manage_bg_jobs operation
on exactly one Wave 3-validated job. External/remote-acknowledged facts come
from the captured ExternalResource, not from the result.
2026-10-03 00:58:32 +01:00
Alexandre Teixeira 04da2f04e8 fix(effects): make journal sequencing crash and concurrency safe
Sequence positions were allocated from each EffectLog object's in-memory
counter, so two objects, threads or processes could reuse a position or
settle one effect twice; replay then failed closed for the whole log. Every
append now takes an exclusive flock, merges the durable records other writers
appended (truncating a torn tail a crashed writer left), allocates from that
merged tail, rejects records the merged history makes invalid (a second
settlement, recovery of a claim another writer settled or marked running),
then appends, fsyncs and releases. history() merges others' records under a
shared lock. An incremental consistency index keeps appends O(1).

The first append of each log object fsyncs the log's directory, and every
directory created for it is fsynced in its parent, all under the lock before
the claim returns. A failed write or directory fsync truncates the record
back, so dispatch is refused and nothing unacknowledged is later merged. The
launch index writes and fsyncs a temp file, replaces it, then fsyncs the
directory. flock and directory fsync are POSIX-only and not claimed
elsewhere.
2026-10-03 00:58:32 +01:00
Alexandre Teixeira f79c2aba7e fix(effects): make postconditions prove intended mutations
edit_file and apply_patch update claims asserted only existence (or, in the
uncommitted corrective attempt, any content change), so an unrelated write
could verify them. Each filesystem postcondition is now the exact content the
producer's own transformation writes from the identity-checked pre-state:
edit_file through the extracted pure _edit_file_text (no newline
translation), apply_patch updates through _apply_patch_hunks on the
universal-newline pre-state. An oversized, replaced or undecodable pre-state,
a non-matching hunk, or an underivable write_file body leaves the whole claim
without postconditions (UNVERIFIED) instead of letting derivable targets
verify the operation or falling back to existence.
2026-10-03 00:58:11 +01:00
Alexandre Teixeira 071e4ec957 Merge pull request #60 from pewdiepie-archdaemon/feature/runtime-resource-authority
feat(runtime): bind runtime resources to authority
2026-10-03 00:32:35 +01:00
Alexandre Teixeira 6cd6ee43c3 docs(runtime): record Wave 3 closure evidence and contracts 2026-10-03 00:20:15 +01:00
Alexandre Teixeira 55d5b1d10a test(runtime): use live local control transport credentials 2026-10-03 00:10:24 +01:00
Alexandre Teixeira 721b5ca831 fix(runtime): retain malformed launch publications safely 2026-10-02 23:57:57 +01:00
Alexandre Teixeira 3d7d32dbe2 fix(runtime): preserve in-flight foreground attachment state 2026-10-02 23:48:41 +01:00
Alexandre Teixeira 3db903c336 fix(runtime): retain publications when recovery state is unreadable 2026-10-02 23:39:13 +01:00
Alexandre Teixeira 3834cd72b1 fix(runtime): enforce local control across Cookbook wrappers 2026-10-02 23:39:13 +01:00
Alexandre Teixeira bcc0e54e1b fix(runtime): revalidate background linkage before delivery 2026-10-02 23:26:01 +01:00
Alexandre Teixeira 6f2ae056c0 chore(runtime): close Wave 3 review nits 2026-10-02 23:23:40 +01:00
Alexandre Teixeira aefdd35d9b fix(runtime): preserve resource denial diagnostics 2026-10-02 23:23:40 +01:00
Alexandre Teixeira fab3c6a15d fix(runtime): terminate invalid background followups 2026-10-02 23:22:42 +01:00
Alexandre Teixeira 8d5ff852de perf(runtime): bound process launch validation cost 2026-10-02 23:22:41 +01:00
Alexandre Teixeira b89d178291 fix(runtime): restore authorized local control paths 2026-10-02 23:15:51 +01:00
Alexandre Teixeira 6094e2abe6 fix(runtime): tolerate unobservable fast-exit process identity 2026-10-02 21:21:20 +01:00
Alexandre Teixeira 87952c864c test(runtime): resolve the live tool registry in effect dispatcher tests
The dispatcher imports src.agent_tools at call time. Binding TOOL_HANDLERS at
test-module import left patches on a stale dict after another test reloaded
the module, so two tests failed only in full-suite order.
2026-10-02 20:30:41 +01:00
Alexandre Teixeira 14b8be5492 docs(runtime): document Wave 4 effects integration on Wave 3 resources
Records the decision to recreate rather than cherry-pick 9012e208, the claim,
outcome, observation, invalidation and verification model, the durable log and
replay design, per-family adapters, completion-gate integration, browser and
background preservation, and residual P2 limitations.
2026-10-02 20:14:50 +01:00
Alexandre Teixeira 75243fe0b0 fix(runtime): restrict running effects to launch results and index history
Only the native detached launch (bg_job_id) or a bridge's explicit detachment
marks an operation's own work as RUNNING. A listing that reports some other
download/model/job as running settled normally; treating it as running left
the claim pending forever and could block required artifacts.

EffectHistory now indexes outcomes per effect once, removing a cubic scan in
assessment over long run lineages.

Adds adversarial coverage: browser page operations stay fail-closed through
the real dispatcher with effects enabled (no claim, never dispatched),
scheduler task triggers stay unverified admission, and assessment scales.
2026-10-02 20:13:24 +01:00
Alexandre Teixeira 3953ea2444 feat(runtime): settle background launch effects from validated job lifecycle
The background monitor already validates the exact Wave 3 job linkage
(job_from_record + validate_job) before continuing a session. At that point it
now records the job's settlement against the durable launch claim through the
launch-generation index, using typed lifecycle facts from the server-owned
record. Settlement is idempotent across deferred retries, is execution
evidence only, and never reads the delivered output: the injected report stays
attributed content. Failure to record leaves the claim running/unknown and
never blocks the follow-up.
2026-10-02 20:10:46 +01:00
Alexandre Teixeira 8402c388b4 feat(runtime): claim effects before dispatch and gate completion on them
Dispatcher seam: mark_dispatch, which runs inside the live Wave 3 binding
scope immediately before backend invocation, now durably claims a possible
effect before execution_id is assigned. If the claim cannot be persisted the
action stays undispatched and the dispatcher returns BLOCKED; dispatched()
closes the never-awaited coroutine. record_action appends the outcome
(including cancellation/interruption) and admitted-read observations before
the receipt reduction drops producer facts.

Adapters consume only the bound operations the dispatcher admitted:
filesystem bindings give exact scope and predicates (write_file content digest
after fence unwrapping, apply_patch add/delete, edit existence); bash/python
launches have unknown scope with the launch generation as lineage; job kills
scope the exact job and its processes; owned operations scope their exact
revisioned records; external backends are claimed as external and never
verified by acknowledgement; browser session_info yields session lifecycle
observations only, and a page binding is never effect scope. Complete
read_file re-reads the exact bound source to digest it; offset/limit,
truncation, extraction and listings are partial. Background launches stay
RUNNING until an admitted read of the exact job generation (via a durable
launch index, across continuation runs) reports settlement.

Producer seams: typed job lifecycle facts on manage_bg_jobs reads/kills, a
structured timed_out flag on containment timeouts, and mutation_attempted on
in-place write_file/edit_file failures after truncation.

Completion: the existing EvidenceLedger consumes effect assessments through a
single helper used for the decision, ask_user and prose filtering. A required
artifact is unsettled by a later unresolved effect that may have touched it,
a fresh contradicting readback fails the decision, and partial reads no longer
count as artifact validation. Ordinary conversation and read-only turns are
unchanged; no second completion policy is introduced.
2026-10-02 20:09:35 +01:00
Alexandre Teixeira 9c4ed24296 feat(runtime): add durable append-only effect log with interrupted replay
Claims are fsynced to a per-lineage JSONL log before a caller may invoke a
backend; a persistence failure raises EffectPersistenceError (a
ResourceIdentityError) so dispatch fails closed. Outcomes and observations are
appended; nothing is rewritten. Reload validates every record strictly, ignores
only a torn final write, and fails closed on corruption, forgery or hardlink
aliasing. recover_interrupted appends INTERRUPTED/possible-impact outcomes for
claims that never settled and leaves RUNNING background effects alone.

The effect store is added to Wave 3 control-plane paths (prefix check only;
the log itself refuses aliased files), so filesystem tools cannot forge it.
Tests redirect the store to a session tmp directory.
2026-10-02 20:02:31 +01:00
Alexandre Teixeira c57aa7ad5c feat(runtime): recreate Wave 4 effect contracts on exact Wave 3 resources
Recreate (rather than cherry-pick 9012e208) the effect/provenance foundation.
The historical types used opaque string resource keys, a may_have_changed flag
defaulting to no impact, and a single status mixing execution and verification.

Claims, outcomes and observations now reference only typed Wave 3 identities
(filesystem root/inode/ancestor chain, process PID+start token, job generation,
owned revision, external incarnation, browser session incarnation). Browser
page resources are refused. Known no-op is limited to refusal before
invocation; unknown scope stays conservative; verification is derived from
fresh, complete, post-settlement readback checked against an explicit
predicate, and unknown execution with matching state is reported as observed
state without causation. Cleanup is recorded separately from effect outcome.
2026-10-02 19:45:39 +01:00
Alexandre Teixeira 5dce6ae238 docs(config): refresh generated environment reference 2026-10-02 19:07:06 +01:00
Alexandre Teixeira b7182fff54 test(runtime): clean Wave 3 validation warnings 2026-10-02 18:57:53 +01:00
Alexandre Teixeira 7afa6e524d docs(validation): document Wave 3 corrective pass results and test classifications
Record metrics, triage, invariants, and classifications for the Wave 3
corrective implementation pass. Confirms 0 Wave 3 regressions remaining,
with 12358 tests passing across the repository.
2026-10-02 18:54:09 +01:00
Alexandre Teixeira 872888aa4a test(runtime): migrate Wave 3 legacy test suites to resource authority contracts
Migrate 28 legacy test failures to exercise behavior under valid sealed
RequestAuthority, native process reservations, sealed filesystem roots,
and external bridge contexts, or assert fail-closed unscoped behavior.
Preserves all design invariants without weakening production authority.
2026-10-02 18:54:09 +01:00
Alexandre Teixeira 29c31a4b24 test(runtime): verify deterministic refusal of unscoped remote scheduled SSH
Assert that raw scheduled remote SSH workloads without an exact external
backend binding fail closed deterministically with:
'Remote scheduled workload requires an exact external backend binding.'
2026-10-02 18:54:09 +01:00
Alexandre Teixeira 2a3d0c67d6 feat(security): sanitize subprocess environment inheritance and scrub credentials
Replace unscrubbed os.environ inheritance with an explicit allowlist
(_SAFE_SUBPROCESS_VARS) containing only variables necessary for bash/python
execution (PATH, locale, terminal, Python virtualenv/site-packages, Windows
essentials) and regex-based credential scrubbing (_SENSITIVE_PATTERN) to
prevent provider tokens, database URLs, and API keys from leaking into child
processes.
2026-10-02 18:54:09 +01:00
Alexandre Teixeira cc14151d10 fix(browser): clean up owned browser daemons on shutdown after cancellation
Shutdown cleanup must not depend on active record.session capability,
which is cleared on cancellation. Guard cleanup by socket directory
presence so all owned daemons are terminated.
2026-10-02 18:54:09 +01:00
Alexandre Teixeira 896e1f8233 fix(test-isolation): prevent scheduler test from poisoning database globals
Use monkeypatch.setattr for engine, SessionLocal, ScheduledTask, and TaskRun
in _setup_isolated_db to ensure pytest restores real database engine state on
teardown, preventing downstream test failures like no such table: documents.
2026-10-02 18:54:09 +01:00
Alexandre Teixeira ab89e3274a fix(runtime): exclude stale process resources during authority intersection
Catch ResourceIdentityError during intersection so that normal process exit
or background job termination does not crash child authority creation.
Stale or unverifiable observations are conservatively excluded from the
resulting authority while maintaining identity verification and preventing
PID reuse or renewal.
2026-10-02 18:54:09 +01:00
Alexandre Teixeira 525ae76df3 docs(runtime): correct Wave 3 validation xfails 2026-10-02 18:54:09 +01:00
Alexandre Teixeira e175bea752 feat(runtime): bind browser resources to authority 2026-10-02 18:54:09 +01:00
Alexandre Teixeira b648f9ddbe fix(runtime): isolate historical job lookup from PID reuse 2026-10-02 18:54:09 +01:00
Alexandre Teixeira db41d7e822 feat(runtime): bind process and job resources to authority 2026-10-02 18:54:09 +01:00
Alexandre Teixeira 7b8ac6f631 Merge lab after verified process lifecycle 2026-10-02 18:54:09 +01:00