Process a sequence of string commands against a flat cloud-storage namespace. Every command returns one result string.
Question
Process a sequence of string commands against a flat cloud-storage namespace. Every command returns one result string.
```python
def solution(queries: list[list[str]]) -> list[str]: ...
```
## Operations
- Add a file with a unique name and integer size; copy an existing file to a free name; query a file's size.
- Find files matching both a prefix and suffix, sorted by size descending and then name ascending.
- Add quota-limited users and add user-owned files only when capacity permits.
- Reduce a user's capacity, evicting that user's largest files first and using name order to break ties until usage fits.
- Compress an owned file by renaming it with a `.COMPRESSED` suffix and halving its even size.
- Decompress by restoring the name and size only if the destination is free and the owner's quota permits it.
An administrator owns files added without a user and has unlimited capacity. Copies retain the source owner and consume that owner's quota. Failures must not partially mutate state.
## Command interface
Each command is a list of strings; numeric arguments are decimal integers. File sizes and capacities are nonnegative, and compression inputs have even sizes. Ordinary users have IDs other than the reserved `admin`; capacity changes and compression commands concern ordinary users. Names are opaque strings, not paths to traverse.
- `ADD_FILE name size`: return `"true"` on creation, `"false"` if the name exists.
- `COPY_FILE source destination`: return `"true"` on success, otherwise `"false"` (missing source, occupied destination, or insufficient owner capacity).
- `GET_FILE_SIZE name`: return the decimal size, or `""` if absent.
- `FIND_FILE prefix suffix`: return matching `name(size)` entries joined by `", "`; return `""` if none.
- `ADD_USER user capacity`: return `"true"` for a new user, `"false"` for an existing ID.
- `ADD_FILE_BY user name size`: return remaining capacity on success, or `""` for unknown user, duplicate name or insufficient capacity.
- `UPDATE_CAPACITY user capacity`: return the number of files evicted, or `""` for unknown user. Evict by size descending then name ascending.
- `COMPRESS_FILE user name`: rename to `name + ".COMPRESSED"`, halve size and return remaining capacity. Return `""` for missing/wrong-owner file, a name already ending in `.COMPRESSED`, or occupied destination.
- `DECOMPRESS_FILE user name`: require a `.COMPRESSED` suffix, remove it and double size; return remaining capacity. Return `""` for missing/wrong-owner file, missing suffix, occupied destination or insufficient capacity. Suffix defines eligibility; a file added with that suffix is eligible too.
`run_case` is provided to pass a fixture's `queries` to your function. Each invocation starts with an empty store.
## Implementation approach
1. Implement flat file add, copy, size, and search.
2. Add ownership, quotas, and deterministic eviction.
3. Add atomic compression and decompression.
## Design discussion (not graded)
- Generalize opaque names into a hierarchical filesystem with directories and moves.
- Discuss concurrency, large metadata sets, durable storage, and quota reconciliation.
The public brief is identical for people and crawlers. Account access changes tools, not the indexed description.