Skip to content

docs: write down trust boundaries, security review scope, and startup-path gates - #4679

Merged
thymikee merged 18 commits into
mainfrom
docs/security-guide
Nov 18, 2026
Merged

thymikee merged 18 commits into
mainfrom
docs/security-guide

Conversation

@thymikee

@thymikee thymikee commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Summary

#4584 took many review rounds because three things were not written down: who is trusted for which filesystem decision, where a security PR's scope ends, and which gates fire on import shape. This PR writes them down. It is docs only and touches 13 files.

  • New docs/agents/security.md, routed from AGENTS.md. It states trust boundaries (script publication takes no path from the daemon; capture delivery still can, open in Verify and enforce client-owned destinations for remote capture stop and report #4518), what applies today (ADR 0016 judges caller-named script destinations on POSIX against the writing process's uid; both script publishers stage and commit inside the judged directory; remote script delivery caps bytes), and the rules proposed in Private writes for credentials and client state #4669, which apply once approved: the ADR 0016 walk for caller output and name validation for peer-named entries, with ADR 0016 staging and byte caps as migration candidates. It names the write sites that do not follow them yet.
  • The elevated-writer, descriptor, and path-dialect rules are not in the guide. They are proposed for approval in this #4669 comment.
  • review.md: a design-review trigger for a new trust boundary, plus a scope rule.
  • gates.md: one pointer sentence to ADR 0027 and test/wire-compat/README.md, which now carry the commands.
  • ADR 0016: a corrected caller-named destination section, smaller than on main.

Why a separate guide, not a section in ADR 0016: ADR 0016 decides script publication only. The guide routes any task that writes at a path another party chooses, including the sites #4669 still has to decide, so its home is the agent-doc router.

Removed agent-doc lines (the minimum the 40,000-byte budget needs) and where each rule still lives

Every other unrelated agent doc is identical to main.

Removed Still lives in
review: "never replace with text matching" AGENTS.md working rules
gates: "For execution, read validation"; test-audit: validation and isolated-experiments links; issue-tracker: triage-labels link AGENTS.md task router
selector-capture: repeated stabilization line first bullet of the same file
test-authoring: split files beside module code-ownership.md
cli-flags: projectConfig/recorded meanings and requirement flag-types.ts types and JSDoc
cli-flags: CLI input readers line step 2 of the same file
cli-flags: schema derivation line Partial prose loss: the authoring route survives in step 1; how command metadata and family schemas combine now lives only in command-schema.ts and command-overrides.ts
web-backend: Windows .cmd and CVE detail; Windows npm setup detail agent-browser-tool.ts and agent-browser-install.ts comments
web-backend: Node 24, --state-dir, first-run flow website installation and commands docs

AGENTS.md keeps every rule; its wording is tightened in six places to fit the new row.

ADR 0016 migration ledger
Old paragraph Outcome
Intro (routes, relative refusal, one call, POSIX-only) Intro, Path input, Walk, Platform limits
Acceptance rule; "So the guarantee is" Guarantee, corrected for the shared-sticky exception
Walk emulation, lstat, hop limit Walk; realpath and stat are under Rejected
Creation, concurrency, 0700, 0600 files Creation, with what a refusal can leave; modes under Answer and staging; recursive mkdir and refusing concurrent directories are under Rejected
Answer used as it stands, staging beside the spelling, dev:ino, openat Answer and staging, with the two remote refusal reasons; openat is under Rejected
Sticky bit, link judging, aliases Sticky directories, with the link-owner rule and the subdirectory a walk may create
Group-writable, systemd membership Group-writable directories, with the exposure order; also Rejected
"Shapes this closes" list Case table of accepted and refused invariants; the owning tests are atomic-file-ancestry.test.ts, atomic-file-parent.test.ts, atomic-file-decisions.test.ts, and daemon-artifacts-script-ancestry.test.ts (#4671 trims the last)
State directory out of scope Kept, links fixed
ACLs, network filesystems, mounts Kept; the Linux ACL mask, and when remote confirmation notices a mount
Typed failures, batch receipt, Rejected Unchanged

Validation

Head 8d14fe0196. pnpm check:agent-guidance (5 pass), pnpm check:adr-citations (2 pass), and pnpm check:doc-prose (clean) pass, and pnpm format gives no diff. docs/agents is at 39,961 of 40,000 bytes and AGENTS.md at 3,999 of 4,000. The ADR 0016 subsection is 11,164 bytes from its heading to the next heading (11,214 on main). Runtime tests do not apply because no code changed. The base comparison and host checks are posted as a PR comment.

🤖 Generated with Claude Code

thymikee and others added 3 commits November 18, 2026 10:53
Each removed line is already owned elsewhere: the AGENTS.md task router,
another agent doc, code comments, type declarations, tests, or
CONTRIBUTING.md. This makes room for security guidance within the
agent-docs byte budget.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…gger

Write down who is trusted for which filesystem decision, the rules for
a file written at a path another party chooses, and the destination
classes. Add a design-review trigger and a scope rule to the review
guide, and the startup-path and wire checks to the gates guide.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Group the walk into labeled rules, move the path-shape examples into one
case table with owning tests, and list the rejected alternatives. Record
that the local file is exactly 0600 while the remote client requests
0600 under the umask, and that resolveUserPath folds relative and ~/
spellings before the walk. Point #4649 and #4620 at their issues.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@apex-sentinel-staging

This comment has been minimized.

thymikee and others added 2 commits November 18, 2026 11:15
Split security.md into what ADR 0016 implements today and the rules for
new or migrated write sites, with destination classes marked as the
#4669 proposal. Add publication-ID binding, privileged-writer authority,
link ownership in sticky directories, and the before-commit limit on
keeping the previous file.

Restore the npm onboarding rule for every new public package, the
node_modules and regression-proof routes in test-experiments, snapshot
cache and Apple runner routing, the selector guide's scope and key
ownership, the ts-expect-error retention rule, and the audit route to
authoring criteria. Give the gates commands their context. Tighten
wording across agent docs to stay within the byte budget.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
State that the sticky exception lets others add names, that the remote
mode is subject to the umask, when the local file reaches exact 0600,
and what a refusal after creation can leave. Rewrite the case table
from the tests as they are, describe remote coverage by what it
asserts, and narrow the ACL and mount limits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@apex-sentinel-staging

This comment has been minimized.

thymikee and others added 8 commits November 18, 2026 11:32
Restore every agent doc that the wording pass changed to its text on
main, keeping only the pure duplicate deletions. Pay for the restored
text by shrinking security.md, the review trigger, and the gates note.
State that the current walk judges against the writing process's uid,
and keep caller-scoped authorization for new write sites.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Name the subdirectory a walk may create in a sticky directory, the
requested 0600 on the remote and generic routes, and the conditions
under which remote confirmation notices a mount. Reduce the case table
to the accepted and refused invariants.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Say where a new write site stages, when to verify a descriptor, and when
to overwrite. Restore the isolated-experiments route in the gates guide
and the command-family metadata rule in the CLI flag guide. Shorten the
security guide to stay within the agent-docs budget.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A missing private subdirectory under a trusted sticky directory is
created; a script entry directly in a shared parent is refused. Mark the
world-writable cases as non-sticky and list both effects of the accepted
sticky case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lure rules

Commit inside the judged parent, not only stage there. Apply the
caller's uid only when an elevated process writes for a caller, and
state that authentication grants no filesystem authority. Separate a
first-publication replace, which needs --force, from later revisions,
and keep the action result on any delivery failure. Reduce the gates
note to one pointer sentence to make room.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refuse a direct entry only in a shared sticky parent, and qualify the
world_writable rows by mode and by this user's or root's ownership.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ADR 0027 and the wire ledger README now carry the commands that the
gates guide points to. The security guide states first publication in
terms of the caller's overwrite grant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ownership is checked before the sticky bit, then world and group write.
Name the owner conditions for shared_parent and planted_link, and the
reason each appeared-level shape returns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 6.40 MB 6.40 MB 0 B
Package (unpacked) 6.40 MB 6.40 MB 0 B
Package (download) 1.94 MB 1.94 MB +6 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 37.1 ms 45.3 ms +8.2 ms
CLI --help 67.1 ms 80.0 ms +12.9 ms

@thymikee

Copy link
Copy Markdown
Member Author

This review covers 99f4f28; 2630f13 landed while it ran and gets its own delta review. I found one problem to fix in 99f4f28: the new write rules in docs/agents/security.md read as settled policy, but #4669 has not approved them. The diff changes only markdown, so the pending checks cannot come from it, and none has failed. There are no conflicts.

docs/agents/security.md:7 states the 'New or migrated writes (#4669)' rules as imperatives. #4669 is open and lists 'Decisions needed before implementation': the accepted paths for each caller-output site, the overwrite and mode rules for each class, Windows, and opt-outs. It also asks for an approved inventory before any code change. The doc already fixes several of those decisions ('replace an existing destination only on --force', 'commit by exclusive create, link, or same-filesystem rename at the restrictive mode', 'judge each directory as ADR 0016 does'). It also adds rules that appear in none of #4669, #4649, #4620 or #4584: an elevated writer authorizes against the caller's uid, verify the descriptor before append or truncate, and explicit path.posix/path.win32. It never says that screenshot --out, JUnit, the auth session, the capture store and the other write sites do not follow these rules today. A worker who migrates the cropped-screenshot write would read this text and change behavior that #4669 marks as undecided. The rule the doc must satisfy: it states only what the cited issues and ADR 0016 support, and it says what is proposed and what is applied. Please mark the list 'Proposed in #4669; applies once approved' and keep only the rules with a source (the ADR 0016 walk, staging and commit inside the judged parent, validated entry names, bounded bytes). Move the elevated-writer, descriptor and path.posix/path.win32 rules to a #4669 comment for approval, or drop them. Add one sentence that names the other write sites as not yet covered.

Would a smaller change do the same job? The corrected ADR 0016 section traces to code and fixes real inaccuracies, so I would keep it. The trust-boundary summary could be a short section at the top of ADR 0016, or one bullet in docs/agents/review.md, with the AGENTS.md row pointing to the ADR. ADR text sits outside the 40,000-byte agent-doc budget, so the new security.md, the other 11 files and the AGENTS.md rewording might not be needed. The #4669 rules for new writes could stay in the issue until its decisions are approved, then go once into the host-kit ADR. If a new agent doc is still wanted, would you split the 'Scope expansion' deletions into their own PR with the budget reason, so this PR reviews as one idea? Before the doc can state rules, someone needs to decide whether the budget grows for a security router or the policy lives in ADR 0016, and #4669 needs its decisions approved.

Not blocking, take or leave: the ADR 0016 case-table row for a remote destination replaced during download gives parent_replaced to both a walk rejection and a changed dev:ino, but a rejection throws script_ancestor_untrusted and only an identity mismatch throws script_ancestry_replaced (the 'Answer and staging' sentence has the same merge); the case-table row for a missing level created meanwhile omits the non-sticky world-writable level (world_writable) and the sticky group-writable one (shared_parent); pull-requests.md keeps 'Report missing devices or commands.' with no antecedent and lost its pointer to the check procedure; removing the --json sentence from cli-flags.md is not covered by the kept rules, so restore it or soften the 'exact duplicate' claim; several security.md, review.md and AGENTS.md sentences do not meet ASD-STE100 (colon lists, undefined 'first landing', 'peer' and 'result-keeping failures', dropped articles); 'Stage new entry files first' in gates.md names no gate and duplicates the AGENTS.md layering-scan line; and the PR body ledger row about a per-case test inventory in ADR 0016 describes text this head does not contain.

The validation claims (check:agent-guidance, check:adr-citations, check:doc-prose and the rest) come from the PR body. A sentence-by-sentence comparison of all 13 files with the base, which docs/agents/review.md asks for on a bulk prose rewrite, has not been done yet, and the POSIX ACL mask and 0775 home statements have not been checked on a host. Before merge, resolve the security.md finding, get that base comparison from another model provider, and settle the single-ADR question above.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
thymikee and others added 4 commits November 18, 2026 12:06
…docs

Split security.md into what applies today and the rules proposed in
#4669, keep only rules with a source, and name the write sites that do
not follow them yet. The elevated-writer, descriptor, and path-dialect
rules move to #4669 for approval. Restore every unrelated agent doc to
its text on main except the minimum duplicate deletions the byte budget
needs, and point the gates guide to ADR 0027 and the wire README.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A refusal from the confirming walk is script_ancestor_untrusted, and a
changed dev:ino alone is script_ancestry_replaced. Describe the
group-write case by its mode bits and keep the subsection below main's
size.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Capture delivery can still take a path from the daemon response, which
is open in #4518. Attribute staging and byte caps to ADR 0016 as
migration candidates, and scope name validation to peer-named entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The client's staging directory is requested at 0700 and the umask can
narrow it. Describe the refused home as one configured as 0775.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thymikee

Copy link
Copy Markdown
Member Author

Base comparison against origin/main

Location Deleted or changed sentence Survival and strength
AGENTS.md:8 Follow other links only when they apply. Equivalent. "Only as needed" keeps the relevance condition.
AGENTS.md:13 Route "Read architecture decisions" to the ADR index. Broader trigger, same destination.
AGENTS.md:30 A daemon edit outside live device behavior requires no device run. Equivalent, head line 31.
AGENTS.md:36 Examine other platforms only when the task requires it. Equivalent, head line 37.
AGENTS.md:43 Keep CONTEXT.md as a glossary only. Equivalent, head line 44.
AGENTS.md:48 Install and build before testing in a new worktree. Equivalent, head line 49.
AGENTS.md:50 Source the main checkout's credentials file by its absolute path. Equivalent, head line 51.
AGENTS.md:51 Give each parallel worker different files and a different device. Equivalent, head line 52.
AGENTS.md:55 The validation lock reclaims provably dead owners; an unknown owner blocks. Equivalent, head line 56.
AGENTS.md:56 On timeout, report the printed owner and the lock state. Equivalent, head line 57.
AGENTS.md:60 Write one instruction in each sentence. Equivalent, head line 61.
AGENTS.md:62 Put specialized rules in the owning task document instead of agent memory. Equivalent, head line 63.
cli-flags.md:11-13 projectConfig and recorded are required and what they mean. Equivalent, type-enforced in flag-types.ts; the opt-in conditions remain in head lines 11-12.
cli-flags.md:34 CLI input readers live in cli-grammar/. Equivalent in step 2, head line 13.
cli-flags.md:48 Schema metadata derives from command metadata, family declarations and the schema-only override path. Partial prose loss: the authoring route survives in head lines 8-10; the composition lives in command-schema.ts and command-overrides.ts.
gates.md:3 For execution, read testing.md. Equivalent through AGENTS.md routing.
issue-tracker.md:18 Read triage-labels.md for labels and state flow. Equivalent through AGENTS.md routing.
review.md:21 Never replace typed reasons with text matching. Equivalent in AGENTS.md working rules.
selector-capture.md:33 Disable direct iOS selector shortcuts while stabilization is pending. Equivalent in head lines 7-8.
test-audit.md:5, :31 Use testing.md for checks; use test-experiments.md for mutations. Equivalent through AGENTS.md routing.
test-authoring.md:54 Keep split files beside their source module. Equivalent in code-ownership.md:38.
web-backend.md:10-21 State-dir handling, Node 24 and Node 22 baselines, and Windows spawn details. Equivalent in website commands.md and installation.md, and in the agent-browser-install.ts and agent-browser-tool.ts comments.
web-backend.md:23-33 First-run example sequence. Exact example removed; website commands.md covers every step.
security.md:4-5 (new file) The client takes no path from a daemon. Narrowed in this round to script publication; capture delivery is named as open in #4518.
security.md:15-20 (new file) Staging, byte limits and name validation listed as #4669 proposals. Changed in this round: #4669 proposes the ADR 0016 walk for caller output and name validation for peer-named entries; ADR 0016 staging and byte caps are migration candidates.
ADR 0016:201 The staging directory is 0700. Corrected in this round: requested at 0700, and the umask can narrow it, as for the file.
ADR 0016:233 A stock Ubuntu or Debian home is 0775. Corrected in this round: a home directory configured as 0775, even with a per-user group.

code-ownership.md, device-foldable.md, device-verification.md, pull-requests.md, test-experiments.md, testing.md and triage-labels.md have no diff against origin/main.

Host checks on macOS: a 0775 directory is refused as shared_group_writable; 0755 and 0750 are accepted. The Linux ACL-mask statement in ADR 0016 was checked against acl(5).

@apex-sentinel-staging

Copy link
Copy Markdown

Apex Sentinel · ✅ Approve · review of 5968f41

Warning

The isolation lease for this review ended before the review finished (an artifact of the staging environment). There is a chance that some of its findings are unverified, or that something was missed. Comment @apex-sentinel-staging review to run it again.

Since the review of 449f9ff: 1 new · 0 still open · 0 no longer raised

1 finding(s): 1 minor.

🟡 Minor (1)

Where Finding
docs/agents/security.md:15 🆕 security.md routes unapproved #​4669 rules as if binding, contradicting AGENTS.md approval rule

Reviewed with this repository's own Sentinel configuration (1c6e81cba89b).

💬 Talking to Sentinel

In a finding's thread, reply with:

Command What it does
@apex-sentinel-staging note <context> Adds context; Sentinel re-checks the cited code
@apex-sentinel-staging pivot <why> Says the finding is wrong; Sentinel re-checks the cited code
@apex-sentinel-staging like Marks the finding as useful
@apex-sentinel-staging dislike <why> Marks it as not useful, so it is not raised again

On this conversation, comment @apex-sentinel-staging review to run a full review once again.

@apex-sentinel-staging apex-sentinel-staging 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.

Apex Sentinel: 1 new finding on 5968f41. The verdict and the full list are in the summary comment.

Comment thread docs/agents/security.md Resolved
@thymikee

Copy link
Copy Markdown
Member Author

This PR is ready at 5968f41. I read the docs against the code and found nothing that needs a change, and there are no conflicts. CI is still running: all nine jobs are in progress and none has failed, and the diff is markdown only, so Repo Guards & Compatibility is the one job that could fail, through a byte budget or prose rule (AGENTS.md has 1 byte of headroom, docs/agents has 5). Not blocking, and you can take or leave these: the sentence at https://github.com/callstack/agent-device/blob/5968f41/docs/agents/security.md#L19 about ADR 0016's staging and byte-cap rules sits under "Proposed in #4669", but the #4669 body does not name them, so it could say that the #4669 comment proposes them, or be dropped; in https://github.com/callstack/agent-device/blob/5968f41/docs/agents/web-backend.md#L13 "A shell would reintroduce hazards from argument quoting" now has no antecedent, and adding "because the shim needs a shell on Windows" would fix that if the byte budget allows; and the PR body says AGENTS.md was tightened in "six places" while the diff edits eleven sentences. The check results and the macOS and Linux permission statements come from the PR and the posted base comparison. Nothing else from this review stands in the way of merging.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 18, 2026
@thymikee
thymikee merged commit aa600e9 into main Nov 18, 2026
18 of 20 checks passed
@thymikee
thymikee deleted the docs/security-guide branch November 18, 2026 11:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant