Skip to content

[Other] refactor model configuration and per-model storage layout out of root - #279

Open
berkkarahan wants to merge 1 commit into
simplexai-labs:mainfrom
berkkarahan:bka/refactor-model-config-storage
Open

berkkarahan wants to merge 1 commit into
simplexai-labs:mainfrom
berkkarahan:bka/refactor-model-config-storage

Conversation

@berkkarahan

Copy link
Copy Markdown
Contributor

Problem and result

Running setup and launching models previously wrote per-model generated artifacts directly into the install/repository root (strata-*.json, strata-*.shared-settings.json, strata-*.json.bak, strata-*.log, run-*.bat / run-*.sh, *.warm-start*, *.tool-media), accumulating root clutter as additional models were configured.

After this change:

  • Per-model artifacts are organized under dedicated subdirectories inside <home> (configs/, logs/, scripts/), keeping the repository and install root clean as multiple models are installed and run.
  • Per-model startup scripts move to <home>/scripts/ (with --no-scripts opt-out in terminal/setup.py and engine/metal/setup_mac.py), alongside unified launch commands (python terminal/polystrata.py start <name>, strata run <model>, strata serve --model <model>).
  • Existing root-folder configs, shared settings, backups, scripts, warm-start files, models.json overlays, and profile references can be migrated idempotently (setup.py --migrate, strata models migrate, layout.migrate_legacy_layout()), while unmigrated legacy installs remain discoverable read-only and --config <path> remains compatible.

Related discussion

none (searched open and closed issues and pull requests on simplexai-labs/PolyStrata for config, sqlite, folder, layout, and clutter; no existing thread covered this refactor)

Approach

Storage format evaluation (SQLite vs. structured JSON files)

We evaluated SQLite against structured JSON files in dedicated subdirectories across setup, CLI, discovery/control, server, and MCP components, and kept structured JSON files under <home>/configs/ via a shared layout module (terminal/strata_control/layout.py):

  • Schema & editability: Preserves arbitrary nested/unknown keys (setup.py:carry_over()), human-editable utf-8-sig JSON files, and user_args diffing without schema migrations.
  • Compatibility & safety: Keeps the direct --config PATH contract, per-file source_sha256 attestation (<= 1 MiB non-symlink regular file), mtime-based MRU ordering, atomic .bak backups with single-model corruption isolation, zero-write read-only discovery (discovery.py, models.py), and stdlib-only operation for tools/strata_mcp.py.

Implementation summary

  • Canonical layout module (terminal/strata_control/layout.py): Centralizes configs/, logs/, and scripts/ path resolution, strict tag validation, precedence-ordered read-only config iteration (configs/ before legacy flat root), atomic JSON writes/backups, and idempotent/collision-safe/symlink-safe migrate_legacy_layout().
  • Unified readers & writers: Updated terminal/setup.py (including poly_setup), terminal/strata_control/ (setup_config.py, discovery.py, models.py, models_move.py, tune_apply.py), terminal/serve/ (server.py, models.py, runconfig.py, appendlog.py, server_parts/http_api.py), terminal/strata_cli/ (cli.py, ram_budget_move.py, launch/catalog.py, launch/runner.py), engine/metal/setup_mac.py, engine/sycl/setup_intel.py, terminal/tools/ (strata_mcp.py, strata_bench.py, calibrate.py), tools/docker/entrypoint.sh, and terminal/polystrata.py.
  • Startup options & compatibility: Relocated run-*.bat/run-*.sh into scripts/, added --no-scripts, added unified CLI entry points (polystrata.py start <name>, strata run <model>, strata serve --model <model>), preserved --config <path> and models.json overlays, and updated 15 config snapshot golden files (log path <REPO>/strata-*.log -> <REPO>/logs/strata-*.log only).
  • Hygiene & test isolation: Updated .gitignore for the new layout directories, updated 6 docs (AI_SETUP.md, DETAILS.md, INSTALL.md, MCP_SERVER.md, TERMINAL.md, TROUBLESHOOTING.md), and isolated setup/unit/E2E tests into temporary directories so repository roots remain untouched.

Validation

Environment: Windows 11, branch bka/refactor-model-config-storage (81a8a4780, rebased on upstream/main 1a41ff673), .venv Python 3.13.15.

Passed:

  • Core unit & regression suites (cd terminal && ..\.venv\Scripts\python.exe -B -m unittest tests.terminal.test_layout_storage tests.terminal.test_m2_writers_and_runtime tests.terminal.test_m3_migration tests.terminal.test_discovery tests.terminal.test_profiles tests.terminal.test_models_move tests.terminal.test_migration tests.terminal.test_intel_app_install tests.terminal.test_model_id_dot tests.terminal.test_file_in_use serve.test_runconfig.Apply serve.test_models.Registry serve.test_models.Start -v in isolated temp home/appdata env, run after final edit at 81a8a4780): Ran 183 tests in 35.963s — OK (skipped=2).
  • E2E + Tier 5 adversarial suite (.venv\Scripts\python.exe -B -m unittest discover -s terminal/tests/e2e -p "test_*.py" -v, run before the 3-line cwd=str(base) test-probe edit in test_m2_writers_and_runtime.py and test_m3_migration.py; no production/E2E files changed since): Ran 70 tests in 17.373s — OK from repo root, and Ran 70 tests in 16.164s — OK from terminal/.
  • Snapshot suite (cd terminal && ..\.venv\Scripts\python.exe -B -m unittest tests.snapshot.test_config_snapshot tests.snapshot.test_strix_reserve tests.snapshot.test_drafting_word_restart -v, run before the 3-line test-probe edit): Ran 31 tests in 162.450s — OK.
  • Setup & calibrate spot check (cd terminal && ..\.venv\Scripts\python.exe -B -m unittest tools.test_setup_layout_move_over tools.test_setup_choices tools.test_setup_golden tools.test_setup_mac tools.test_setup_sycl tools.test_setup_run_script_newlines tools.test_calibrate, run before the 3-line test-probe edit): Ran 203 tests in 8.258s — OK (skipped=2).
  • Repo checks (run before the 3-line test-probe edit):
    • .venv\Scripts\python.exe -B tools/check --only docs: docs passed (6 passed, 0 failed, 0 skipped).
    • .venv\Scripts\python.exe -B tools/test_dropped_paths.py -v: Ran 2 tests in 0.049s — OK.
    • .venv\Scripts\python.exe -B tools/test_check_links.py -v: Ran 4 tests in 1.199s — OK.
    • .venv\Scripts\python.exe -B tools/test_path_length.py -v: Ran 1 test in 0.040s — OK.
    • polystrata_names.py delta check vs upstream/main on all modified/new eligible files: 0 new hits.

Failed:

  • none observed

Not run:

  • python -m pytest terminal/tests/terminal and python tools/check --only py-tools: pytest, textual, and rich are not installed in the local .venv (unittest was used for runnable suites; GitHub Actions CI will run the pytest steps).
  • Process-spawning tests in terminal/tools/test_strata_mcp.py: blocked in the local Windows sandbox (CreatePipe WinError 5, loopback socket restrictions).
  • Live macOS Metal (setup_mac.py), Linux Intel SYCL (setup_intel.py), and Docker (tools/docker/entrypoint.sh) runtime execution: executed on a Windows host without macOS/Intel SYCL/Docker hardware (covered via unit mocks and static inspection; no C++/CUDA/HIP/SYCL/Metal engine binaries were modified).

Limits

  • Local verification ran on Windows 11 using .venv without pytest/textual/rich installed and without macOS, Intel SYCL, or Docker runtime execution; full CI workflows (check.yml, snapshot.yml, docs.yml, terminal-minimal-server.yml) will validate Linux/Windows/macOS runners.
  • Pre-existing polystrata_names.py --check hits on upstream/main remain unchanged (0 new hits added by this branch).
  • Existing legacy root-folder installs stay discoverable read-only until migrated explicitly via setup.py --migrate or strata models migrate.

@berkkarahan

Copy link
Copy Markdown
Contributor Author

@VecSzn file/folder structure overhaul

@VecSzn

VecSzn commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

too much to take in one PR, the new layout, migration, MCP changes and 5 tiers of e2e tests are all in 79 files. can you split it: the new layout first, then migration, MCP and the e2e tests in separate PRs? thanks for the work on this

@berkkarahan

Copy link
Copy Markdown
Contributor Author

@VecSzn 👋🏻 file/folder structure changes are better off merged in a single PR. It is a big change but please take a look

@berkkarahan

Copy link
Copy Markdown
Contributor Author

I intend to build a simple gui for configuring the models after this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants