Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 11 additions & 23 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ Implemented:
`docs/spec/done/0018-fs-token-auth-and-config-free-access.md`
- Server-backed Filesystem token lifecycle management from
`docs/spec/done/0030-file-system-token-lifecycle-management.md`
- Filesystem layer fork, ancestry, deletion, and historical mount workflows
from `docs/spec/done/0032-filesystem-layer-fork-workflows.md`
- Historical filesystem layer workflows
from `docs/spec/done/0032-filesystem-layer-fork-workflows.md`, updated by
`docs/spec/done/0032-ext01-layerfs-v36.md`
- install and update distribution from
`docs/spec/done/0012-install-and-update-distribution.md`
- English PingCAP Preview documentation from
Expand Down Expand Up @@ -136,12 +137,9 @@ Implemented:
- `ti fs create-layer`
- `ti fs list-layers`
- `ti fs fork-layer`
- `ti fs list-layer-chain`
- `ti fs describe-layer`
- `ti fs diff-layer`
- `ti fs create-layer-checkpoint`
- `ti fs delete-layer`
- `ti fs rollback-layer`
- `ti fs merge-layer`
- `ti fs commit-layer`
- `ti fs mount-file-system`
- `ti fs drain-file-system`
Expand Down Expand Up @@ -293,8 +291,8 @@ For ti fs data-plane and mount runtime, the live suite creates uniquely named
remote paths, exercises real file create/read/list/copy/move/delete flows,
range reads, append, resume, recursive local/remote copy, stdin/stdout copy,
tags/descriptions, chmod, symlink, hardlink, pack/unpack, real public layer
create/list/describe/diff/checkpoint/rollback/commit flows, layer-aware
copy/find where Drive9 exposes it, vault create/read/replace/delete, delegated
create/list/describe/fork/delete/merge flows, layer-aware
copy where Drive9 exposes it, vault create/read/replace/delete, delegated
vault grant reads, vault mount read on macOS/Linux hosts when available,
journal create/append/read/search/verify, public Git clone/hydrate/worktree
flows, mount and drain through the companion runtime, and explicit WebDAV
Expand Down Expand Up @@ -629,20 +627,15 @@ Implemented command behavior:
- `ti fs create-symlink --target README.md --link-path /workspace/README.link`
- `ti fs create-hardlink --source-path /workspace/README.md --link-path /workspace/README.hard`
- `ti fs search-file-content --path /workspace --pattern "hello"`
- `ti fs search-file-content --path /workspace --pattern "hello" --layer-id layer-1`
- `ti fs find-files --path /workspace --file-name-pattern "*.md"`
- `ti fs find-files --path /workspace --file-name-pattern "*.md" --layer-id layer-1`
- `ti fs create-layer --layer-id layer-1 --base-root-path /workspace --layer-name task --durability-mode restore-safe --tag task=auth`
- `ti fs create-layer --base-root-path /workspace --layer-name task --ttl 1h --tag task=auth`
- `ti fs list-layers`
- `ti fs list-layers --output text`
- `ti fs fork-layer --parent-layer-ref layer-1 --layer-name child --checkpoint-id cp-1`
- `ti fs list-layer-chain --layer-ref child --output text`
- `ti fs fork-layer --parent-layer-ref layer-1 --layer-name child --ttl 30m`
- `ti fs describe-layer --layer-id layer-1`
- `ti fs diff-layer --layer-id layer-1`
- `ti fs copy-file --from-local ./README.md --to-remote /workspace/layered.md --layer-id layer-1`
- `ti fs create-layer-checkpoint --layer-id layer-1 --checkpoint-id cp-1 --label before-commit`
- `ti fs delete-layer --layer-ref child`
- `ti fs rollback-layer --layer-id layer-1`
- `ti fs merge-layer --layer-id layer-1`
- `ti fs commit-layer --layer-id layer-1`
- `ti fs pack-file-system --local-root ~/.ti/local/fs/demo --remote-root /workspace --mount-profile portable`
- `ti fs pack-file-system --mount-path ./workspace`
Expand All @@ -656,7 +649,6 @@ Implemented command behavior:
- `ti fs mount-file-system --file-system-id <file-system-id> --mount-path ./workspace --driver fuse --cache-dir ~/.ti/cache/workspace --write-back-cache=false`
- `ti fs mount-file-system --file-system-id <file-system-id> --mount-path ./workspace --driver fuse --durability close-sync`
- `ti fs mount-file-system --file-system-id <file-system-id> --mount-path ./workspace --remote-path /workspace --driver fuse --layer-ref layer-1`
- `ti fs mount-file-system --file-system-id <file-system-id> --mount-path ./workspace-v1 --remote-path /workspace --driver fuse --layer-ref layer-1 --checkpoint-id cp-1`
- `ti fs drain-file-system --mount-path ./workspace`
- `ti fs drain-file-system --mount-path ./workspace --timeout 30s`
- `ti fs unmount-file-system --mount-path ./workspace`
Expand Down Expand Up @@ -735,12 +727,9 @@ Registered command surface:
- `ti fs create-layer`
- `ti fs list-layers`
- `ti fs fork-layer`
- `ti fs list-layer-chain`
- `ti fs describe-layer`
- `ti fs diff-layer`
- `ti fs create-layer-checkpoint`
- `ti fs delete-layer`
- `ti fs rollback-layer`
- `ti fs merge-layer`
- `ti fs commit-layer`
- `ti fs pack-file-system`
- `ti fs unpack-file-system`
Expand Down Expand Up @@ -1207,8 +1196,7 @@ ordinary mount keeps its documented behavior instead of following the engine's
combination. FUSE mounts forward the tier, including `--driver auto` mounts on
platforms whose automatic choice is FUSE; WebDAV mounts forward none and reject
every explicit tier except `auto` with `fs.webdav_durability_unsupported`;
checkpoint mounts are read-only, force `auto`, and reject any other explicit
tier. Report the effective tier as `durability` in the mount result and do not
report the effective tier as `durability` in the mount result and do not
reintroduce the removed `write_back_cache` boolean.

Do not implement or expose ti commands for Drive9 internal APIs that are not
Expand Down
31 changes: 11 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,28 +215,22 @@ Use `ti update` or reinstall ti if the local capability check reports an incompa

Mount readiness means the mounted path is readable: `ti fs mount-file-system` and `ti fs-vault mount-vault` keep polling the mount path until directory listing succeeds, bounded by `--ready-timeout` (default `30s`). If the mount path never becomes readable in time, the command fails with `fs.mount_ready_timeout`, the background mount is left running, and the mount locator is preserved so the matching unmount command can stop it.

When a mount unpacks a local overlay (auto-unpack with a non-`none` mount profile whose effective pack paths are non-empty — `portable` supplies `/` by default, and the companion's mount accepts no extra pack paths of its own — while `--no-auto-unpack` is not set, or an explicit `--unpack-archive-path`), it runs the same overlay symlink audit as `ti fs unpack-file-system`: ti resolves the local overlay before the companion runs, snapshots it, audits it after the mount becomes readable, and also when readiness times out, removes links that escape the overlay, stops the mount, and reports the error. The audited root is the companion's own default overlay root, so existing overlays keep their location; an explicit `--local-root` is passed through and audited as given. If the audit rejects the overlay or an unpack-capable mount never becomes ready, ti stops the mount instead of leaving it running (an exception to the usual timeout behavior, because unpack may still be completing). If the mount cannot be stopped, the error says so and the mount locator is kept so `ti fs unmount-file-system` can retry; before the locator exists there is nothing to keep, so the error instead names the companion's own `ti-drive9 umount` with the resource-scoped HOME. A mount that would unpack into an overlay ti cannot resolve is refused with `fs.mount_unpack_requires_profile`. A mount that unpacks nothing at the companion, including one that only names `--local-root`, is not audited; ordinary mounts keep their previous behavior. The predicate counts the effective pack paths rather than the companion's unpack decision, so a `coding-agent` mount with `--pack-path` still runs the audit even though that profile carries no unpack paths of its own. Links that land outside an audited run window are treated as pre-existing local state. The extra `--pack-path` values are recorded in the mount locator (together with the mount's local root) and replayed as repeated `drive9 umount --pack-path` when the mount is unmounted, because the companion's `mount` has no flag for them and `umount --pack-path` is what feeds the automatic pack; without the replay the mount succeeds while the archive silently omits those local overlay paths. They are overlay paths: a value that is absent from `<local-root>/overlay` at unmount is skipped with a check in the unmount output rather than failing the pack after the mount is already detached, and a WebDAV mount (which has no local overlay) refuses `--pack-path` at mount time. `--pack-archive-path` adds an archive instead of choosing the only one: without `--no-auto-pack` the companion packs both the profile's default archive and the named one; an explicit archive keeps the replay even together with `--no-auto-pack`, because the pack still runs; `--no-auto-pack` alone suppresses the replay along with the automatic pack. `--pack-path` is refused at mount time for a WebDAV mount and for a value the pack cannot accept (`\` or a `.`/`..` segment, and a relative value may not contain an empty segment; a blank value is dropped, and an absolute value may repeat slashes). Restoring the archive is still the mount profile's decision: only a profile that carries automatic unpack paths, such as `portable`, unpacks it at the next mount, a `coding-agent` mount never does, and `ti fs unpack-file-system` (or an explicit `--unpack-archive-path`) is how to restore it deliberately.
When a mount unpacks a local overlay (auto-unpack with a non-`none` mount profile whose effective pack paths are non-empty — `portable` supplies `/` by default, and the companion's mount accepts no extra pack paths of its own — while `--no-auto-unpack` is not set, or an explicit `--unpack-archive-path`), it runs the same overlay symlink audit as `ti fs unpack-file-system`: ti resolves the local overlay before the companion runs, snapshots it, audits it after the mount becomes readable, and also when readiness times out, removes links that escape the overlay, stops the mount, and reports the error. The audited root is the companion's own default overlay root, so existing overlays keep their location; an explicit `--local-root` is passed through and audited as given. If the audit rejects the overlay or an unpack-capable mount never becomes ready, ti stops the mount instead of leaving it running (an exception to the usual timeout behavior, because unpack may still be completing). If the mount cannot be stopped, the error says so and the mount locator is kept so `ti fs unmount-file-system` can retry; before the locator exists there is nothing to keep, so the error instead names the companion's own `ti-drive9 umount` with the resource-scoped HOME. A mount that would unpack into an overlay ti cannot resolve is refused with `fs.mount_unpack_requires_profile`. A mount that unpacks nothing at the companion, including one that only names `--local-root`, is not audited; ordinary mounts keep their previous behavior. The predicate counts the effective pack paths rather than the companion's unpack decision, so a `coding-agent` mount with `--pack-path` still runs the audit even though that profile carries no unpack paths of its own. Links that land outside an audited run window are treated as pre-existing local state. The extra `--pack-path` values are recorded in the mount locator (together with the mount's local root) and replayed as repeated `drive9 umount --pack-path` when the mount is unmounted, because the companion's `mount` has no flag for them and `umount --pack-path` is what feeds the automatic pack; without the replay the mount succeeds while the archive silently omits those local overlay paths. They are overlay paths: a value that is absent from `<local-root>/overlay` (under the layer-specific root for a layer mount) at unmount is skipped with a check in the unmount output rather than failing the pack after the mount is already detached, and a WebDAV mount (which has no local overlay) refuses `--pack-path` at mount time. `--pack-archive-path` adds an archive instead of choosing the only one: without `--no-auto-pack` the companion packs both the profile's default archive and the named one; an explicit archive keeps the replay even together with `--no-auto-pack`, because the pack still runs; `--no-auto-pack` alone suppresses the replay along with the automatic pack. `--pack-path` is refused at mount time for a WebDAV mount and for a value the pack cannot accept (`\` or a `.`/`..` segment, and a relative value may not contain an empty segment; a blank value is dropped, and an absolute value may repeat slashes). Restoring the archive is still the mount profile's decision: only a profile that carries automatic unpack paths, such as `portable`, unpacks it at the next mount, a `coding-agent` mount never does, and `ti fs unpack-file-system` (or an explicit `--unpack-archive-path`) is how to restore it deliberately.

`ti fs-vault run-with-secret` reads the named secret through the companion and runs the command from ti itself. The child receives only the secret fields plus an environment with ti credentials removed: the filesystem bearer token, the vault token, the organization API key pair, and the filesystem AI provider key are never inherited. Field names are exported with the same environment-key conversion as `ti fs-vault read-secret --format env` (ASCII letters upper-cased, digits and `_` kept, a leading digit prefixed with `_`, and every byte outside `A-Z`, `a-z`, `0-9`, and `_` replaced with `_`), so accented characters produce one underscore per UTF-8 byte; two fields that convert to the same key fail with a usage error instead of overwriting each other. A field that converts to a process-configuration variable is rejected with `vault.env_key_forbidden` instead of injected, because whoever can write a secret's fields could otherwise choose what the child loads or runs; the error lists every rejected field and what it would have configured: `PATH`, `PATHEXT`, `COMSPEC`, `SHELL`, shell startup and evaluation names such as `ENV`, `BASH_ENV`, `SHELLOPTS`, `PS4`, and `IFS`, dynamic-loader names such as `LD_PRELOAD`, `LD_LIBRARY_PATH`, `DYLD_INSERT_LIBRARIES`, and `GCONV_PATH`, language-runtime names such as `PYTHONPATH`, `PERL5OPT`, `NODE_OPTIONS`, `RUBYOPT`, `JAVA_TOOL_OPTIONS`, and `LUA_INIT`, and helper-selection names such as `SSH_AUTH_SOCK`, `GIT_SSH_COMMAND`, `GIT_CONFIG_GLOBAL`, and `PAGER`. The check matches exact names after conversion, except that a few families whose suffix the field name chooses are matched by prefix (`DYLD_*`, `LD_32_*`, `LD_64_*`, `GIT_CONFIG_KEY_<n>`, `GIT_CONFIG_VALUE_<n>`), and that trailing all-digit version segments are stripped before the lookup, so versioned spellings such as `LUA_INIT_5_4`, `LUA_PATH_5_4`, `LUA_CPATH_5_4`, and `LD_PRELOAD_32` hit the same entries as their base names (Lua reads the versioned name first, and the Solaris loader reads the 32/64-bit one). Names that merely resemble a rejected one, such as `SSH_PRIVATE_KEY`, `GIT_TOKEN`, `LD_PRELOAD_BACKUP`, or `DB_URL_2`, remain injectable. `ti fs-vault read-secret --format env` still converts those names, because it only prints values and never spawns a child. On Windows, an inherited variable that differs from an injected field only by letter case is replaced, because the platform resolves environment names case-insensitively.

Filesystem layers can fork copy-on-write child timelines without copying a workspace. Layer and checkpoint mounts require FUSE; checkpoint mounts are always read-only. Drive9 does not support combining recursive copy with a layer, so seed a directory tree through a writable layer mount, drain it, and then create the checkpoint:
Create a layer to try changes in an isolated working directory. Seed it with a recursive copy, then fork its current contents for an independent experiment. Create and fork accept TTLs in whole seconds or a duration such as `5m`. Each `--tag key=value` must have a unique key. An unpack-capable layer mount stops if its local overlay directory cannot be audited.

```shell
~~~shell
export TI_FS_FILE_SYSTEM_ID="<file-system-id>"
ti fs create-directory --path /research/q3-market
ti fs create-layer --base-root-path /research/q3-market --layer-name research-base
SEED_MOUNT="$(mktemp -d)"
ti fs mount-file-system --mount-path "$SEED_MOUNT" --remote-path /research/q3-market --driver fuse --layer-ref research-base
tar -C . -cf - . | tar -C "$SEED_MOUNT" -xf -
ti fs drain-file-system --mount-path "$SEED_MOUNT"
ti fs unmount-file-system --mount-path "$SEED_MOUNT"
rmdir "$SEED_MOUNT"
ti fs create-layer-checkpoint --layer-id research-base --checkpoint-id seed
ti fs fork-layer --parent-layer-ref research-base --layer-name experiment-a --checkpoint-id seed
ti fs list-layer-chain --layer-ref experiment-a --output text
```
ti fs create-directory --path /research
ti fs create-layer --base-root-path /research --layer-name research-base --ttl 1h
ti fs copy-file --from-local ./seed --to-remote /research/seed --recursive --layer-id research-base
ti fs fork-layer --parent-layer-ref research-base --layer-name experiment-a --ttl 30m
ti fs describe-layer --layer-ref experiment-a
~~~

Use `ti fs delete-layer --layer-ref experiment-a` to abandon a rejected leaf. Deleting a layer with live descendants fails unless `--cascade` is supplied explicitly. Layer names are not durable unique identifiers because abandoned layers remain visible; automation should capture returned layer IDs and use run-unique checkpoint IDs.
Use `ti fs merge-layer --layer-ref experiment-a` to publish the selected layer or `ti fs delete-layer --layer-ref experiment-a` to discard it. Scripts can use the server-generated `layer_id` returned by create or fork. Layer mounts require FUSE. Their local overlays are scoped by the SHA-256 of that ID under `<local-root>/views/<hash>/overlay`.

`ti fs list-regions` lists the Filesystem regions published by TiDB Cloud Filesystem, with their cloud provider, display name, state, and regional service address. It uses TiDB Cloud credentials, always asks the API, and refreshes the recorded `service_address` of locally stored File System credentials. The catalog request is Digest-authenticated with the organization API key pair, so `ti` follows a redirect only when it keeps the same scheme and host and otherwise fails with `api.fs_regions_redirect_refused`; the catalog endpoint itself must be `https` (plain `http` is accepted only for a loopback test server) and must not embed credentials, a query, or a fragment:

Expand Down Expand Up @@ -406,12 +400,9 @@ ti fs find-files
ti fs create-layer
ti fs list-layers
ti fs fork-layer
ti fs list-layer-chain
ti fs describe-layer
ti fs diff-layer
ti fs create-layer-checkpoint
ti fs delete-layer
ti fs rollback-layer
ti fs merge-layer
ti fs commit-layer
ti fs pack-file-system
ti fs unpack-file-system
Expand Down
Loading