Skip to content

feat(harness): add a generic artifact-offload module - #101

Merged
senamakel merged 1 commit into
mainfrom
harness-artifacts
Aug 13, 2026
Merged

feat(harness): add a generic artifact-offload module#101
senamakel merged 1 commit into
mainfrom
harness-artifacts

Conversation

@senamakel

Copy link
Copy Markdown
Member

Lands the generic half of the artifact-offload convention as harness::artifacts, ported from OpenHuman's agent/harness/artifact_offload/ under plan-agents.md Phase 5.

It is the first family in that phase's order (artifact_offloadrun_queueparse/tool_callingsubagent_runnersession/turnsession/{builder,runtime,types}), chosen because its inbound coupling is the lowest of the set: 4 call sites host-side.

Independent of #100 — no shared files, no ordering constraint.

Why it could not move as written

Two decisions inside the module are host policy, and a redistributed crate cannot make either. They become injected traits rather than imports:

Trait Answers Was
ArtifactPathPolicy which paths are off limits SecurityPolicy::{is_workspace_internal_path, workspace_dir}
ArtifactRedactor what is scrubbed before bytes hit disk memory::store::safety::sanitize_text

Both are gates the runtime calls, never behaviour the runtime is trusted to have performed — RFC §2 rule 5. That is why redaction is a trait returning the stored body rather than a bool the caller sets: callers surfacing any part of an artifact back into a model's context must render it from the returned value, and the API makes the raw input the inconvenient thing to reach for.

A None redactor stores bytes verbatim. That is a legitimate configuration and it is documented as a security decision rather than an absence of one, with a test pinning it so the default cannot quietly become "scrub something" and give false assurance.

What deliberately did NOT move

  • The prompt contract. It is OpenHuman prompt text naming OpenHuman tools, which plan-agents.md §6 lists as not publishable. It stays host-side. For the same reason render_artifact_pointer takes the read-tool name as a parameter — a hard-coded file_read would put a tool the host may not have into its prompts.
  • The two-way internal-path split. is_workspace_internal_path and the workspace_dir containment check survive as two separate policy methods producing two distinct errors, because a host wants to tell "under the internal root" apart from "a specific state location" in a log. The specific check runs first, so its more precise error wins when a path trips both — that ordering is load-bearing when a host has configured its artifact root inside its internal root, and it is pinned by a test.

The subtle part, preserved as-is

The resolver's checks are necessarily lexical: the target usually does not exist when they run, so canonicalize is unavailable. That means a pre-existing symlink (outputs -> /elsewhere) would still be followed by the write. So the real parent is re-validated after create_dir_all and before the write — the first moment the link-resolved location can be checked at all. This is carried over unchanged, with a test that asserts nothing was written through the link.

Naming

action_dirroot throughout, since "action dir" is host vocabulary. relative_to_action_dirrelative_to_root; OffloadError::{WorkspaceTarget, WorkspaceInternal}{InternalRoot, InternalState}, which say what they mean without naming a host concept.

Dependency note

tokio's fs feature is now required. It enables more of tokio rather than adding a package, so OpenHuman's kernel-floor package count is unaffected.

Verification

  • cargo test --all-features --lib1754 passed, 0 failed (44 new)
  • cargo clippy --all-features --all-targets — clean
  • cargo fmt --check — clean

The tests worth reading, because each pins something that fails silently:

Test Guards
abstract_is_built_from_the_redacted_body_not_the_raw_output the load-bearing one. The pointer goes straight into a parent's context; building the abstract from raw text re-exposes the credential just scrubbed out of the file, while the file itself still looks correct
offload_failure_keeps_the_inline_payload_for_the_host_backstop a disk problem turning into data loss — a refused offload must never cost the caller its content
write_refuses_a_parent_that_symlinks_out_of_the_convention_root the lexical/real gap above
rejects_host_internal_state_paths_with_the_specific_error the check ordering losing the useful error
a_policy_free_resolve_still_enforces_containment policy: None widening traversal, not just the host checks
write_without_a_redactor_stores_bytes_verbatim the documented no-redactor consequence
scratch_resolves_under_the_artifact_root_not_the_internal_root workspace the subdir vs workspace the host state root — same word, different places
build_abstract_never_splits_a_multibyte_character a byte-indexed cut panicking rather than misformatting
extract_artifact_paths_ignores_non_pointer_and_malformed_lines an empty path= yielding the next field as the path

Follow-up

The host-side change — rewriting agent/harness/artifact_offload/ as a thin wrapper that supplies the two policies and keeps the prompt contract, in the same shape run_queue already uses — follows in openhuman once this merges and the vendor pointer can move.

🤖 Generated with Claude Code

Long-horizon runs accumulate context: summarising one oversized payload at
a time shrinks each result but never stops the aggregate from growing, and
it can never restore full fidelity. The fix is to put large results on disk
and hand the next step a path.

This lands the generic half of that convention as `harness::artifacts`,
ported from OpenHuman's `agent/harness/artifact_offload/` under
`plan-agents.md` Phase 5. It is the first family in that phase's order,
chosen because its inbound coupling is the lowest of the set.

Two host decisions are the whole reason this could not move as written,
and both become injected policy rather than imports:

- `ArtifactPathPolicy` — which paths are off limits. A host keeps internal
  state somewhere and an agent write must never land in it; only the host
  knows where that is.
- `ArtifactRedactor` — what gets scrubbed before bytes touch disk.
  Credential and PII patterns are a host's compliance surface, not a
  library's.

Both are gates the runtime calls, never behaviour the runtime is trusted to
have performed (RFC section 2 rule 5). A `None` redactor stores bytes
verbatim, which is documented as a security decision rather than an absence
of one.

Two things deliberately did NOT move:

- The prompt contract. It is OpenHuman prompt text naming OpenHuman tools,
  which `plan-agents.md` section 6 lists as not publishable. It stays host-side,
  and `render_artifact_pointer` takes the read-tool name as a parameter for
  the same reason — a hard-coded tool name would put a tool the host may
  not have into its prompts.
- The `is_workspace_internal_path` / `workspace_dir` split. It survives as
  two separate policy methods producing two distinct errors, because a host
  wants to tell "under the internal root" apart from "a specific state
  location" in a log. The specific check runs first so its more precise
  error wins when a path trips both.

The symlink re-validation is preserved as-is and is the subtle part: the
resolver's checks are necessarily lexical because the target does not exist
when they run, so the real parent is re-checked after `create_dir_all` and
before the write.

`tokio`'s `fs` feature is now required. It enables more of tokio rather
than adding a package, so the kernel-floor package count is unaffected.

44 tests, covering the happy path, the soft-failure path (a refused offload
must never cost the caller its content), and the fail-closed hardening.
The load-bearing one is that the abstract is built from the redacted body
and never from the raw output — the pointer goes straight into a parent's
context, so rendering it from raw text would re-expose the credential just
scrubbed out of the file, while the file itself still looked correct.

Co-authored-by: Medulla <medulla@tinyhumans.ai>
@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@senamakel, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 49 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f76c3e1a-5c4a-4f7a-a363-9fefa0b50a69

📥 Commits

Reviewing files that changed from the base of the PR and between c15d783 and 5e42554.

📒 Files selected for processing (8)
  • Cargo.toml
  • src/harness/artifacts/mod.rs
  • src/harness/artifacts/ops.rs
  • src/harness/artifacts/paths.rs
  • src/harness/artifacts/policy.rs
  • src/harness/artifacts/test.rs
  • src/harness/artifacts/types.rs
  • src/harness/mod.rs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@tinysweeper tinysweeper Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tinysweeper found nothing blocking. Approving.

             $0.0856 · 114,057 in / 28,295 out · 73,069 cached (64%) · z-ai/glm-5.2
critique:    $0.0413 · 33,570 in  / 18,697 out · 24,997 cached (74%) · z-ai/glm-5.2
security:    $0.0265 · 33,400 in  / 5,481 out  · 13,571 cached (41%) · z-ai/glm-5.2
tests:       $0.0081 · 22,933 in  / 1,691 out  · 16,894 cached (74%) · z-ai/glm-5.2
description: $0.0098 · 24,154 in  / 2,426 out  · 17,607 cached (73%) · z-ai/glm-5.2

@tinysweeper

tinysweeper Bot commented Aug 13, 2026

Copy link
Copy Markdown

What this change touches

8 files, +1603 -1 across 3 components. The code graph knows nothing about these files yet — normal for newly added files, and a cold index otherwise.

flowchart LR
  n0["src/harness/artifacts<br/>6 files +1598 -0"]:::changed
  n1["root<br/>1 file +4 -1"]:::changed
  n2["src/harness<br/>1 file +1 -0"]:::changed
  classDef changed fill:#0d4429,stroke:#238636,color:#e6edf3
  classDef impacted fill:#161b22,stroke:#6e7681,color:#c9d1d9
  classDef flagged fill:#5a1e02,stroke:#d93f0b,color:#ffffff
  classDef blocking fill:#67060c,stroke:#f85149,color:#ffffff
Loading

Green: changed. Grey: untouched, reached through an import or a call. Orange: has findings. Red: has a finding that blocks the merge.

Component Files Lines Findings
src/harness/artifacts changed 6 +1598 -0
(root) changed 1 +4 -1
src/harness changed 1 +1 -0
Changed files

src/harness/artifacts

  • src/harness/artifacts/mod.rs
  • src/harness/artifacts/ops.rs
  • src/harness/artifacts/paths.rs
  • src/harness/artifacts/policy.rs
  • src/harness/artifacts/test.rs
  • src/harness/artifacts/types.rs

(root)

  • Cargo.toml

src/harness

  • src/harness/mod.rs

tinysweeper 0.1.0

@tinysweeper tinysweeper Bot added the priority: p3 Whenever. Cosmetic, a nicety, or a cleanup with no user visible effect. label Aug 13, 2026
@senamakel
senamakel merged commit 30d6b3b into main Aug 13, 2026
8 checks passed
@senamakel
senamakel deleted the harness-artifacts branch August 13, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: p3 Whenever. Cosmetic, a nicety, or a cleanup with no user visible effect.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant