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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ The format follows Keep a Changelog and the package uses semantic versioning.

## Unreleased

- Matched local object listings by lexical key prefix, including partial names,
same-prefix siblings and exact files. Append `/` for directory-boundary
matching. Traversal prunes unrelated subtrees and retains staging-file and
namespace filtering. Prefixes beneath files return no descendants.
Existing local path/case limitations remain; parent enumeration can add I/O.
No write, locking, storage format or cloud adapter policy changes.

- Initiated best-effort cancellation of discarded HTTP object and bundle
response bodies. Missing/fallback/error outcomes, successful consumption,
conditional reads and request policy are preserved. Cancellation promises
Expand Down
3 changes: 3 additions & 0 deletions benchmarks/local-lexical-prefix-listing/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.gitattributes text eol=lf
*.mjs text eol=lf
results/*.svg text eol=lf
217 changes: 217 additions & 0 deletions benchmarks/local-lexical-prefix-listing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
# Local lexical prefix listing

## Decision

Merge-worthiness: 91/100. Recommend the scoped change after full normal Linux
CI and CodeQL pass on the current pull request head and required review is
complete. Every hard gate remains mandatory regardless of score.

The local provider previously treated a list prefix as a directory path.
Partial names missed existing objects, an exact directory name could omit
same-text siblings, and an exact file prefix threw native `ENOTDIR`.
The candidate returns lexical matches, including exact files, while pruning
directories that cannot contain a match.

All 28 candidate contracts pass versus 12/28 historically. All twelve
root/slash-ended/missing/empty directory controls preserve complete measured
work and state. Corrected listings perform more directory/metadata work;
this is not a performance improvement claim.

## Scope and compatibility

| Boundary | Revision |
| --- | --- |
| Historical main, including merged P25 | `6915343baa0f6ac20f3be96f92aae494ee24c6e8` |
| Initial protocol before production edits | `f739a8da826b84d4ad1a56e7bd714997433792a4` |
| Authoritative preparation clarification before freeze | `282b4a5b93ab71ab97a8bf4c0c0c75ad3b0d9baa` |
| Frozen implementation, fixtures, collector, verifier and tests | `7b7047a80074556a2ef7b05aefaa45a326f7bb6f` |

Only `src/stores.ts` changes in production: local list-prefix interpretation,
file filtering and an existing private walker's directory predicate.
No get/put/delete, write condition, locking, cache, storage/encryption format,
API, option, dependency, infrastructure or cloud adapter changes.
P26/P24/P22/P19/P7 remain parked unchanged.

A non-slash-ended prefix is lexical, not directory-only. For example,
`group` matches `group-a.json`, `group-extra/item.json` and `group/item.json`.
Use `group/` to exclude same-text siblings. Exact files are eligible keys;
a prefix beneath an existing file has no local descendants and returns `[]`.

The adapter keeps existing local key validation and path canonicalisation.
It starts in the relevant parent, filters files and descends only where
the directory/prefix relationship can produce a match. Staging names remain
hidden. The existing scoped wrapper still filters foreign namespaces.

Existing host path/case resolution remains. On a case-insensitive filesystem,
an existing parent can be found with different casing and returned keys can
retain that requested parent spelling. Filename-prefix filtering is ordinal
and case-sensitive on those returned logical names. Case-distinct cloud keys,
file/directory name collisions and every cloud key syntax are not faithfully
representable by a filesystem. This is not complete provider equivalence.

Partial-prefix queries can read more parent/sibling metadata. Unrelated
subtrees are pruned, but a large relevant parent remains expensive.
Use slash-ended prefixes for directory-boundary workloads. Listing is not
a transactional snapshot, cross-process lock or network-filesystem guarantee.

## Method and evidence

The [prospective protocol](protocol.json) fixes fourteen prefixes for both raw
and real `PrefixObjectStore` views: 28 cases per arm, 56 original observations.
Each fresh owned root contains ten logical objects, an empty directory,
reserved staging fixtures and, for scoped cases, foreign same-text namespace
siblings. Real LocalObjectStore writes seed exact UTF-8 bytes.

The retained seven-module public `providers/local` graphs use a common,
hashed Node `fs/promises` observation adapter. It forwards actual native
`readdir` calls, entries and errors; it supplies no simulated filesystem
results. It records source requests, completions, relative paths, Dirent
names/kinds, error codes/syscalls and full original native error bindings.
Initial/final complete directory/file contents and hashes prove read-only
behaviour.

The sole scored comparison ran from detached frozen source, from
19:56:13.129Z to 19:56:17.458Z on 5 December 2026. Environment: Windows x64
10.0.26300, Node 22.22.2, TypeScript 5.9.3 and esbuild 0.28.2.
Timestamps are provenance, not latency samples.

Independent verification checks 172 frozen inputs, rebuilds both complete
seven-module API graphs and common adapter, exactly replays all 56 native
filesystem observations, reconciles twelve complete-work controls and checks
every CSV cell and both graphs' counts, labels and geometry.
Actual temporary roots and full native error messages remain in raw bindings.
Comparison removes their non-deterministic binding plus global event/token
order; relative paths, operations, entries/kinds, error code/syscall, counts
and complete state remain.

The driver allocates a fresh positively owned root per case, awaits source
work, restores only its observer, unlinks owned regular files and removes
empty directories non-recursively. Source listing performs no mutation.
Setup, driver snapshots and cleanup are outside source filesystem counters.
Path/string/predicate work and fs-internal/physical I/O are not measured.

| Artifact | Contents |
| --- | --- |
| [Scored capture](results/local-2026-12-05.json) | All 56 rows, native bindings/states and both full API/adapter graphs |
| [Per-trial CSV](results/local-2026-12-05-trials.csv) | Every prefix contract and measured source cost |
| [Desired-contract graph](results/local-2026-12-05-success.svg) | Raw and scoped native cases |
| [Enumeration graph](results/local-2026-12-05-work.svg) | Source readdir starts, not physical IOPS |
| [Qualification manifest](results/qualification-2026-12-05.json) | Frozen/artifact/original-log identities, exact outcomes, test results and cleanup scope |

## Results

Eight prefixes per facade expose historical deficiencies; six are complete
directory/root controls.

| Facade | Historical desired contracts | Candidate desired contracts | Historical/candidate public errors | Historical/candidate returned keys |
| --- | ---: | ---: | ---: | ---: |
| Raw | 6/14 | 14/14 | 2/0 | 19/37 |
| Scoped | 6/14 | 14/14 | 2/0 | 19/37 |
| Total | 12/28 | 28/28 | 4/0 | 38/74 |

![Desired controlled local prefix contracts](results/local-2026-12-05-success.svg)

The returned-key column totals all queries, including overlaps; it is not a
distinct-object count. Four historical exact-file queries throw `ENOTDIR`.
The remaining twelve target cases omit lexical matches. No candidate query
exposes staging files or foreign scoped keys, enters an unrelated subtree,
or changes any fixture bytes/directories.

All twelve root/slash-ended/missing/empty controls preserve complete measured
source work and final state. In particular, scoped empty-prefix listings
retain their slash boundary and do not include `scopes/app-foreign`.

### Complete measured source work

Values aggregate all 28 cases per arm.

| Metric | Historical | Candidate |
| --- | ---: | ---: |
| Readdir starts | 44 | 60 |
| Readdir completions | 30 | 58 |
| Readdir errors | 14 | 2 |
| Returned entry metadata | 62 | 198 |
| Returned directory metadata | 22 | 84 |
| Returned file metadata | 40 | 114 |

![Source native directory enumerations](results/local-2026-12-05-work.svg)

The candidate adds sixteen directory enumerations and returns 136 additional
entry metadata records. This is useful traversal for previously incomplete
listings, not reduced I/O. Returned metadata counts include repeated entries
and reserved entries subsequently filtered by the walker.
All sixteen original native error bindings remain available.

Resident/temporary memory, allocation, CPU, throughput, latency, physical
disk IOPS, cloud requests and production incidence remain unmeasured.
No browser, cloud-provider or matched Linux performance result is claimed.

## Other checks and platform limits

The final focused suite passes 52 real-filesystem cases. Exact historical
substitution passes 34 and fails the eighteen targeted expectations.
The broader run passes 247 cases in twenty files, with five pre-existing
platform-conditional skips. These cover local atomic replacement, stores,
namespaces, envelopes, engines, migrations, retention and exports.
All new candidate cases must also run in normal Linux CI on the exact
publication head.

An initial preparation test assumed cloud-like case sensitivity when resolving
an existing parent directory. Native Windows probes show the prior local
path alias retains requested parent spelling. The original failure and
probe are retained; a published preparation clarification and filename-level
case test preserve that host limit rather than introducing a new path policy.
The measured prefix cohort remains unchanged.

Before freezing, preflight exercises the authoritative published-protocol
identity guard, independent cohort/count checks, all 28 instrumented candidate
cases and candidate-only CSV/SVG cell/geometry validation. Repository,
Studio, Worker and explicit fixture types pass.
Package build, isolated packed-consumer/browser isolation and all 28 complete
built `providers/local` observations pass. Built probing forwards native
operations through an isolated-process builtin observer and restores it.

Windows observations qualify this host/filesystem only. Required Linux CI
provides additional candidate functional coverage, not a paired Linux
filesystem benchmark. It does not establish NFS/SMB behaviour, atomic list
snapshots, shared-root multi-process correctness, symlink isolation or cloud
key equivalence. There is no new symlink/security policy.

| Component | Score | Basis |
| --- | ---: | --- |
| Correctness and fit | 37/40 | Partial/exact prefixes and namespace boundaries reconcile; production incidence unmeasured |
| Compatibility and work | 22/25 | Directory controls preserved; non-slash interpretation changes and parent I/O increases |
| Reproduction | 19/20 | Complete native graphs/bindings, 172 inputs, exact replays/derivatives and built probes; no cloud/cross-OS paired campaign |
| Simplicity | 13/15 | One production module/private predicate; canonicalisation and pruning add branches |
| Total | 91/100 | Recommend only with every mandatory gate and required review |

## Reproduction

Use the frozen source, lockfile/dependencies and measured Windows Node
environment for exact same-runtime filesystem replay. Preserve original
evidence paths.

```powershell
npx --no-install tsx benchmarks\local-lexical-prefix-listing\run.mjs --preflight
npx --no-install tsx benchmarks\local-lexical-prefix-listing\verify.mjs benchmarks\local-lexical-prefix-listing\results\local-2026-12-05.json
npx --no-install vitest run tests\local-prefix-listing.test.ts
```

The first command validates source-independent protocol and candidate
artifact-format guards without creating a scored capture.
The verifier rebuilds both exact-Git graphs and replays all observations.
Ordinary functional tests can run on Linux, but do not reinterpret a different
host's filesystem errors or operation bindings as a matched Windows replay.

## Research basis

- [S3 ListObjectsV2 Prefix](https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html#API_ListObjectsV2_RequestParameters),
checked 5 December 2026: general-purpose bucket prefix selection matches the
beginning of keys. Directory-bucket restrictions are distinct.
- [Azure List Blobs prefix](https://learn.microsoft.com/en-us/rest/api/storageservices/list-blobs#uri-parameters),
checked 5 December 2026: flat listings filter names beginning with a prefix;
hierarchical-namespace restrictions are distinct.

The existing S3/Azure adapters already forward such prefixes. These references
motivate local canonical-key parity, not a claim that filesystems implement
all cloud key, consistency or performance semantics.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {execFileSync} from "node:child_process";
import {readFileSync} from "node:fs";
import path from "node:path";
import {fileURLToPath} from "node:url";
import {defineConfig} from "vitest/config";
const root=fileURLToPath(new URL("../../",import.meta.url));
const {baseline}=JSON.parse(readFileSync(new URL("./protocol.json",import.meta.url),"utf8")) as {baseline:string};
const file=path.join(root,"src","stores.ts").replaceAll("\\","/"),source=execFileSync("git",["show",`${baseline}:src/stores.ts`],{cwd:root,encoding:"utf8"});
export default defineConfig({root,plugins:[{name:"exact-local-prefix-baseline",enforce:"pre",load(id){return id.replaceAll("\\","/").split("?")[0]===file?source:null}}],test:{include:["tests/local-prefix-listing.test.ts"]}});
Loading