メインコンテンツへスキップ

AFS

Core contract

Use the AFS path operations through the capabilities declared by the provider that owns each path.

AFS exposes path operations. The provider responsible for a path supplies the operation and its behavior. Do not model the API as one universal filesystem with mandatory support for every verb.

Evidence for this page: packages/core/src/type.ts (AFSModule, AFSRoot), packages/core/src/afs.ts, packages/core/src/capabilities/types.ts (OperationsDeclaration), packages/core/src/error.ts, checked against ARC source 44fbd616f and CLI arc 2.0.0-beta.28.

Operation families

OperationModule method (core)PurposeCapability boundary
listlist?Enumerate entries under a pathOptions and listing semantics are provider-defined; unsupported list flags may be best-effort
read / batch readread?, optional batchRead?Read one or more resourcesDepends on provider and path; visibility: "meta" returns meta only
write / batch writewrite?, optional batchWrite?Create or change contentWritable is not implied by path existence; write modes include replace/append/prepend/patch/create/update
delete / batch deletedelete?, optional batchDelete?Remove resourcesRecursive and predicate options are provider/feature-specific
renamerename?Move/rename within provider rulesNot every CLI surface exposes rename; check core/API and provider
statstat?Inspect metadataShared result envelope; fields inside are provider-defined
searchsearch?Free-text retrievalCoverage and ranking are provider-defined; see Search and query
execexec?Invoke an action at a pathRequires explicit action path, args, and permission/severity policy
explainexplain?Report how a path resolvesUse for routing and ownership inspection
queryquery? (optional)Typed collection query via /.actions/queryOptional and strict; declare fully or not at all

Optional methods on AFSModule are real: a provider that omits a method does not implement that operation. Root AFSRoot requires the common ops at the dispatcher level and still routes through mount capabilities.

Capability declaration

Providers declare operations through OperationsDeclaration (boolean or { supported, features }):

FieldNotes
read, list, write, delete, search, exec, stat, explainCore op flags
query?Mirrors the standard collection-query action for tooling
batchWrite?, batchDelete?Often derived; pushdown needs method presence + features.batchPushdown
subscribe?, interact?Optional event / human-elicitation capabilities

Sub-capability features (examples):

FeatureMeaning when declared
write.features.ifMatchOptimistic concurrency via opaque meta.version; must enforce or reject, not silent degrade
list.features.orderByServer-side list ordering
delete.features.wherePredicate delete

Read live declarations when available:

bash
arc afs read <mount>/.meta/.capabilities

Access mode and visibility

ConceptValuesEffect
accessModereadonly · create · append · readwriteConstrains which mutations are allowed at the module/mount
visibilityfull · metameta: read returns metadata only; search denied

Do not assume readwrite from the fact that a path lists children.

Error codes (selected)

From packages/core/src/error.ts. Applications should branch on code, not English message text alone.

CodeClassTypical cause
AFS_NOT_FOUNDAFSNotFoundErrorPath does not exist
AFS_UNSUPPORTEDAFSUnsupportedErrorOperation not supported
AFS_VALIDATION_ERRORAFSValidationErrorBad args or strict query/spec failure
AFS_READONLYAFSReadonlyErrorMutation against readonly surface
AFS_ACCESS_MODEAFSAccessModeErrorViolates mount access mode
AFS_ACCESS_DENIEDAFSAccessDeniedErrorSubstrate access denied
AFS_FORBIDDENAFSForbiddenErrorPolicy forbid
AFS_AUTH_REQUIREDAFSAuthRequiredErrorMutating action needs auth
AFS_CONFLICTAFSConflictErrorifMatch version mismatch
AFS_ALREADY_EXISTSAFSAlreadyExistsErrorCreate/collision
AFS_MOUNT_FAILEDAFSMountErrorMount check failed
AFS_ACTION_NOT_FOUNDAFSActionNotFoundErrorUnknown action

CLI observation on beta.28: missing path via arc afs read prints ERROR: Path not found: … and exits 5.

CLI vs core surface

SurfaceOps commonly exposed
arc afs (beta.28)ls, read, write, delete, stat, exec, explain, search, mount
Core AFSModuleAbove plus rename, optional query, optional batch pushdown, subscribe, etc.

If you need an operation that is in core types but missing from the CLI group, use the programmatic/RPC surface or check whether a root /.actions/* action covers it. See arc afs.

Provider authors

Implement an AFSModule (typically via AFSBaseProvider and operation decorators), expose only operations you can enforce, and run shared conformance tests. Continue with Author a provider.