Skip to content
C.W.K.
Stream
Lesson 04 of 05 · published

The Scope Seal Sits in Front of the Tool

~12 min · scope, seal, containment, tools

Level 0Trace
0 XP0/36 lessons0/12 achievements
0/100 XP to next level100 XP to go0% complete

A prompt is not a fence

A brief can say change only this fragment while a brain reads neighbors or a helper expands a broad glob. Instructions communicate intent; they do not remove capability. Memory boundaries are too expensive to depend on goodwill.

A scope seal binds allowed vault, path prefix, and operation to the claim and checks immediately before every read or write tool call. A mistaken prompt still cannot open a forbidden path.

Seal reads too

Write containment alone allows one protected vault to be read and mixed into the claimed target. Confidentiality and contamination fail at read time. The seal must separately govern read, search, related, and write.

Even a global index query filters results through the seal before snippets enter brain context. Out-of-scope paths do not leave the index.

Normalize before comparison

Prefix guards are vulnerable to parent traversal, symlinks, Unicode normalization, and echoed vault prefixes. Convert input to a canonical relative path, define symlink policy, and compare path components.

Normalizing one known harmless echo differs from forgiving arbitrary traversal. Remove only an expected duplicate prefix and deny every other strange form explicitly.

A seal violation is a contamination incident

Once a forbidden read reaches output, continuing with a warning is unsafe because later judgment now contains closed context. Preserve valid edits, record the incident, and resume in a fresh context.

A blocked write is not proof of no leak. Memory can propagate through context, logs, and a provider at read time. No-write success is not no-disclosure evidence.

Scope must be a shape of tool capability, not a sentence in a prompt. Check canonical paths for read and write, and treat a forbidden read as a fresh-context incident.

Code

Check scope by path components·python
from pathlib import PurePosixPath

allowed = PurePosixPath("memory/project")

def in_scope(raw):
    path = PurePosixPath(raw)
    if ".." in path.parts:
        return False
    return path == allowed or allowed in path.parents

assert in_scope("memory/project/note.md")
assert not in_scope("memory/project-old/note.md")
assert not in_scope("memory/project/../secret.md")

External links

Exercise

Add allowed vault, path, and operations to a task seal. Test traversal, sibling-prefix, symlink, and termination after a forbidden read.
Hint
Follow search and Related payloads, not only write tools.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.