bcbd1bdb22
Integ / changes (push) Has been skipped
Pre-commit / pre-commit (push) Failing after 1s
CLI exit codes / changes (push) Has been skipped
Test (Install) / changes (push) Has been skipped
Test (Python) / changes (push) Has been skipped
Test (TypeScript) / changes (push) Has been skipped
CLI exit codes / cli-gate (push) Has been cancelled
Test (Install) / test-install-gate (push) Has been cancelled
Integ / integ-gate (push) Has been cancelled
Test (Python) / test-python-gate (push) Has been cancelled
Test (TypeScript) / test-typescript-gate (push) Has been cancelled
Test (Install) / python-minimal (3.12) (push) Has been cancelled
Test (Install) / python-minimal (3.11) (push) Has been cancelled
Test (Install) / python-extra (agno, mirage.agents.agno) (push) Has been cancelled
Test (Install) / python-extra (chroma, mirage.resource.chroma) (push) Has been cancelled
Test (Install) / python-extra (pdf, mirage.core.filetype.pdf) (push) Has been cancelled
Integ / integ (push) Has been cancelled
Integ / integ-database (push) Has been cancelled
Integ / integ-database-ts (push) Has been cancelled
Integ / integ-data (push) Has been cancelled
Integ / integ-ssh (push) Has been cancelled
Integ / integ-ssh-ts (push) Has been cancelled
Test (Python) / audit (push) Has been cancelled
Test (TypeScript) / test (push) Has been cancelled
Test (TypeScript) / python-fs-shim (push) Has been cancelled
CLI exit codes / Python CLI (push) Has been cancelled
CLI exit codes / TypeScript CLI (push) Has been cancelled
CLI exit codes / Cross-language snapshot interop (push) Has been cancelled
Test (Python) / test (push) Has been cancelled
Test (Python) / import-isolation (deepagents, openai, mirage.agents.openai_agents) (push) Has been cancelled
Test (Python) / import-isolation (deepagents, pydantic-ai, mirage.agents.pydantic_ai) (push) Has been cancelled
Integ / integ-ts (push) Has been cancelled
Integ / integ-fuse (push) Has been cancelled
Test (Install) / python-extra (databricks, mirage.resource.databricks_volume) (push) Has been cancelled
Test (Install) / python-extra (deepagents, mirage.agents.langchain) (push) Has been cancelled
Test (Install) / python-extra (email, mirage.resource.email) (push) Has been cancelled
Test (Install) / python-extra (fuse, mirage.fuse.mount) (push) Has been cancelled
Test (Install) / python-extra (hdf5, mirage.core.filetype.hdf5) (push) Has been cancelled
Test (Install) / python-extra (hf, mirage.resource.hf_buckets) (push) Has been cancelled
Test (Install) / python-extra (lancedb, mirage.resource.lancedb) (push) Has been cancelled
Test (Install) / python-extra (langfuse, mirage.resource.langfuse) (push) Has been cancelled
Test (Install) / python-extra (mongodb, mirage.resource.mongodb) (push) Has been cancelled
Test (Install) / python-extra (nextcloud, mirage.resource.nextcloud) (push) Has been cancelled
Test (Install) / python-extra (openai, mirage.agents.openai_agents) (push) Has been cancelled
Test (Install) / python-extra (openhands, mirage.agents.openhands, 3.12) (push) Has been cancelled
Test (Install) / python-extra (parquet, mirage.core.filetype.parquet) (push) Has been cancelled
Test (Install) / python-extra (postgres, mirage.resource.postgres) (push) Has been cancelled
Test (Install) / python-extra (pydantic-ai, mirage.agents.pydantic_ai) (push) Has been cancelled
Test (Install) / python-extra (qdrant, mirage.resource.qdrant) (push) Has been cancelled
Test (Install) / python-extra (redis, mirage.resource.redis) (push) Has been cancelled
Test (Install) / python-extra (s3, mirage.resource.s3) (push) Has been cancelled
Test (Install) / python-extra (ssh, mirage.resource.ssh) (push) Has been cancelled
Test (Install) / ts-minimal (push) Has been cancelled
164 lines
6.7 KiB
Python
164 lines
6.7 KiB
Python
# ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
# ========= Copyright 2026 @ Strukto.AI All Rights Reserved. =========
|
|
|
|
import asyncio
|
|
import os
|
|
from pathlib import Path
|
|
|
|
from cases import run_not_found
|
|
|
|
from mirage import MountMode, Workspace
|
|
from mirage.resource.nextcloud import NextcloudConfig, NextcloudResource
|
|
from mirage.types import CommandSafeguard
|
|
|
|
DATA_DIR = Path(__file__).resolve().parent.parent / "data"
|
|
SEED_OBJECTS = [
|
|
"example.jsonl", "example.json", "example.parquet", "example.orc",
|
|
"example.feather"
|
|
]
|
|
URL = os.environ.get(
|
|
"NEXTCLOUD_URL",
|
|
"http://localhost:8080/remote.php/dav/files/admin/",
|
|
)
|
|
USERNAME = os.environ.get("NEXTCLOUD_USERNAME", "admin")
|
|
PASSWORD = os.environ.get("NEXTCLOUD_PASSWORD", "admin123")
|
|
MOUNT = "/nc"
|
|
|
|
# Read-only, deterministic commands mirroring integ/s3.py PER_MOUNT_CASES so
|
|
# Nextcloud exercises the same shell-command surface as the object stores.
|
|
# {m} is the mount root (/nc). The root `ls`/`tree` also list Nextcloud's
|
|
# default sample files; check_lines.sh matches substrings, so those extra
|
|
# entries are tolerated and only the seeded `data/` content is asserted.
|
|
PER_MOUNT_CASES: list[tuple[str, str]] = [
|
|
("ls", "ls {m}/"),
|
|
("ls_data", "ls {m}/data/"),
|
|
("tree", "tree {m}/data/"),
|
|
("stat", "stat -c '%s %n' {m}/data/example.json"),
|
|
("cat_head", "cat {m}/data/example.json | head -n 5"),
|
|
("head_1_jsonl", "head -n 1 {m}/data/example.jsonl"),
|
|
("head_3_jsonl", "head -n 3 {m}/data/example.jsonl"),
|
|
("tail_2_jsonl", "tail -n 2 {m}/data/example.jsonl"),
|
|
("wc_l_jsonl", "wc -l {m}/data/example.jsonl"),
|
|
("wc_c_json", "wc -c {m}/data/example.json"),
|
|
("grep_c_mirage", "grep -c mirage {m}/data/example.jsonl"),
|
|
("grep_m1_mirage", "grep -m 1 mirage {m}/data/example.jsonl"),
|
|
("grep_head", "grep mirage {m}/data/example.jsonl | head -n 3"),
|
|
("grep_queue_wc", "grep queue-operation {m}/data/example.jsonl | wc -l"),
|
|
("grep_rl_item", "grep -rl item {m}/data/"),
|
|
("rg_l_item", "rg -l item {m}/data/"),
|
|
("grep_rc_mirage", "grep -rc mirage {m}/data/"),
|
|
("grep_item_parquet", "grep item_5 {m}/data/example.parquet"),
|
|
("rg_item_glob_feather", "rg item_5 {m}/data/*.feather"),
|
|
("ls_glob_parquet", "ls {m}/data/*.parquet"),
|
|
("ls_file_json", "ls {m}/data/example.json"),
|
|
("find_json", "find {m}/ -name '*.json'"),
|
|
("find_type_f", "find {m}/data -type f | sort"),
|
|
("jq_version", "jq .metadata.version {m}/data/example.json"),
|
|
("jq_team_names",
|
|
"jq '.departments[].teams[].name' {m}/data/example.json"),
|
|
("pipe_sort_uniq_wc", "cat {m}/data/example.jsonl"
|
|
" | grep queue-operation | sort | uniq | wc -l"),
|
|
("md5_json", "md5 {m}/data/example.json"),
|
|
("sha256_json", "sha256sum {m}/data/example.json"),
|
|
("file_parquet", "file {m}/data/example.parquet"),
|
|
("file_orc", "file {m}/data/example.orc"),
|
|
("file_feather", "file {m}/data/example.feather"),
|
|
("du_multi", "du {m}/data/example.json {m}/data/example.jsonl"),
|
|
("file_multi", "file {m}/data/example.json {m}/data/example.jsonl"),
|
|
|
|
# ----- writes-key regression: a warm dir index must see touch/rm -----
|
|
("inv_ls_warm", "ls -1 {m}/data"),
|
|
("inv_touch", "touch {m}/data/inv_late.txt"),
|
|
("inv_ls_after_touch", "ls -1 {m}/data"),
|
|
("inv_rm", "rm {m}/data/inv_late.txt"),
|
|
("inv_gone", "cat {m}/data/inv_late.txt | wc -c"
|
|
" | sed s/^/inv_gone_bytes=/"),
|
|
|
|
# ----- cat cache poisoning: per-file cache keys after a concat cat -----
|
|
("poison_concat", "cat {m}/data/example.json {m}/data/example.jsonl"
|
|
" | wc -l"),
|
|
("poison_first_intact", "wc -l {m}/data/example.json"),
|
|
("poison_second_intact", "wc -l {m}/data/example.jsonl"),
|
|
("pipe_concat_head", "cat {m}/data/example.jsonl {m}/data/example.json"
|
|
" | head -n 1"),
|
|
|
|
# ----- safeguard: per-mount cap on cat (set to 20 lines below) -----
|
|
("safeguard_cat_truncates", "cat {m}/data/example.jsonl"),
|
|
("safeguard_cat_pipe_uncapped", "cat {m}/data/example.jsonl | wc -l"),
|
|
]
|
|
|
|
# Streaming byte accounting mirroring integ/s3.py STREAMING_CASES: clear the
|
|
# cache, run, and report lines + first line. Early-exit commands transfer far
|
|
# less than the full object. Byte counts are backend-specific so they are not
|
|
# asserted; the line counts and first-line content are deterministic.
|
|
STREAMING_CASES: list[tuple[str, str]] = [
|
|
("head_c100", "head -c 100 {m}/data/example.jsonl"),
|
|
("head_n1", "head -n 1 {m}/data/example.jsonl"),
|
|
("grep_m1", "grep -m 1 mirage {m}/data/example.jsonl"),
|
|
("cat_wc_full", "cat {m}/data/example.jsonl | wc -l"),
|
|
]
|
|
|
|
|
|
async def _seed(ws: Workspace) -> None:
|
|
await ws.execute(f"rm -rf {MOUNT}/data")
|
|
await ws.execute(f"mkdir -p {MOUNT}/data")
|
|
for obj in SEED_OBJECTS:
|
|
await ws.ops.write(f"{MOUNT}/data/{obj}",
|
|
(DATA_DIR / obj).read_bytes())
|
|
|
|
|
|
async def _run(ws: Workspace, name: str, cmd: str) -> None:
|
|
result = await ws.execute(cmd)
|
|
out = await result.stdout_str()
|
|
print(f"=== {name} ===")
|
|
print(out, end="" if out.endswith("\n") else "\n")
|
|
if "safeguard_" in name:
|
|
err = await result.stderr_str()
|
|
if err:
|
|
print(err, end="" if err.endswith("\n") else "\n")
|
|
|
|
|
|
async def _measure(ws: Workspace, name: str, cmd: str) -> None:
|
|
await ws.cache.clear()
|
|
result = await ws.execute(cmd)
|
|
out = await result.stdout_str()
|
|
lines = out.strip().splitlines()
|
|
first = lines[0][:48] if lines else ""
|
|
print(f"=== {name} ===")
|
|
print(f"lines={len(lines)} out0={first!r}")
|
|
|
|
|
|
def _set_cat_safeguard(ws: Workspace, max_lines: int) -> None:
|
|
sg = CommandSafeguard(max_lines=max_lines)
|
|
mounts = list(ws._registry._mounts)
|
|
for m in mounts:
|
|
m.command_safeguards["cat"] = sg
|
|
|
|
|
|
async def main() -> None:
|
|
resource = NextcloudResource(
|
|
NextcloudConfig(url=URL, username=USERNAME, password=PASSWORD))
|
|
ws = Workspace({MOUNT: resource}, mode=MountMode.WRITE)
|
|
await _seed(ws)
|
|
_set_cat_safeguard(ws, max_lines=20)
|
|
for name, tmpl in PER_MOUNT_CASES:
|
|
await _run(ws, name, tmpl.format(m=MOUNT))
|
|
for name, tmpl in STREAMING_CASES:
|
|
await _measure(ws, f"stream:{name}", tmpl.format(m=MOUNT))
|
|
await run_not_found(ws, MOUNT)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|