Skip to content

feat(installer): load ext/ code only from the repos the env's record names - #200

Merged
mik-now merged 2 commits into
intel:release-2.0from
mik-now:feat/env-scoped-ext
Dec 1, 2026
Merged

mik-now merged 2 commits into
intel:release-2.0from
mik-now:feat/env-scoped-ext

Conversation

@mik-now

@mik-now mik-now commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #196. Configs were already picked from env/<env>/.solutions.yaml, but roles and components came from every components.yaml under ext/, and all envs share ext/. So an old clone (or one another env uses) could add components to a run or shadow its roles. That's what broke the upgrade path after the rename.

What changes:

  • ensure_repos sets ENV_REPOS from the env's record. The roles path, the merged registry (_target_exists, show_table) and preflight (as _env_repos) all read only those repos through one helper, _ext_manifests. A run on an env with no record reads no ext clones, and an ext-only layer still gets the "not provisioned, run init" error. Unset (show, init, direct playbook runs) means all of ext/, as before.
  • If a recorded repo doesn't match the manifest's dest: anymore, the run stops and says which init <layer> --upgrade fixes it. This replaces the hard-coded list of old folder names from rebranding: rename ext/ clones to inference-toolkit and chatbot-toolkit #196.
  • When init moves a layer to a new repo, ext/<old>/ paths in that env's configs are repointed to ext/<new>/ (e.g. deployment_dir in config.erag.yaml) before the new record replaces the old one. If the repoint fails, the old record stays and re-running init finishes it. Other envs are left alone until their own init.
  • The missing-repo error names the layer that seeded the row, so it no longer loops on init inference when erag's repo is the one missing.

Tested locally on a copy of an old env (records enterprise.ai-*, old clone still on disk): the run is refused with the right command, init erag --upgrade moves both layers and fixes deployment_dir, and validate then only loads chatbot-toolkit and inference-toolkit. Unit tests in src/tests/unit/test_env_repos.py: a real init against a local git repo, a failed repoint followed by a retry, a run with no record, and the preflight filter.

@mik-now
mik-now requested review from a team December 1, 2026 12:58
@sys-aibot

sys-aibot commented Dec 1, 2026 •

Copy link
Copy Markdown

Claude finished @mik-now's task in 1m 7s —— View job


Verdict: needs changes

Correctness

  1. toolkit_manager.sh:263-271: _merged_components still reads every components.yaml under ext/. The comment this PR removes at the old _ext_roles_dirs said roles and _merged_components use the same discovery. After this change they don't. _target_exists (:2140), _discover_layers and show_table still merge every clone, including ext/enterprise.ai-erag or a clone that belongs to another env. Two problems follow:

    • A target that exists only in another env's clone passes the shell check, and the failure only shows up later in preflight.
    • With an old clone next to the new one, *+ appends both copies, so the table lists components twice.

    Scope _merged_components to solution_repos the same way. Keep the all-of-ext/ fallback only when no record exists, matching ensure_repos and preflight. Fix this →

  2. toolkit_manager.sh:996-1001: the new _init_reconcile_pins paths have no tests. Two behaviours were added there:

    • plain init refuses a repo move;
    • --upgrade queues the move and, through _init_seed_layer, rewrites the record's repo:.

    test_env_repos.py only calls _init_move_repo_paths directly. Add tests for both paths: plain init fails with the --upgrade hint, and init --upgrade ends with .solutions.yaml naming the new dest and the configs repointed. There is also no test that preflight's _env_repos filter (preflight.yaml:109-124) narrows _ext_manifests, including the case where an empty _env_repos skips the find.

  3. toolkit_manager.sh:1026-1028 with :1239-1240: configs are rewritten before anything is cloned. _init_move_repo_paths runs inside _init_reconcile_pins, before ensure_repos "$layer" --clone and before the record is replaced. If the clone or seeding fails, the env's configs point at ext/<new>/ while .solutions.yaml still names ext/<old>. Re-running --upgrade recovers, since sed is idempotent, but until then the env is half-moved. That is the state the function's header comment says it avoids ("an init this env cannot accept changes nothing at all"). Do the move after the clone succeeds, next to the mv "$sol_new" "$sol".

Readability / comments

  1. toolkit_manager.sh:867: # No recorded repo: only Toolkit Manager's own roles. restates the next line. Drop it.
  2. toolkit_manager.sh:854: # init <seeded_by> re-provisions the row… explains a variable fallback. Calling the variable seeded_by instead of by would make the comment unnecessary.
  3. playbooks/includes/preflight.yaml:107: the new comment repeats what the header block (:11-12) already says about _env_repos. Keep one of the two.

@mik-now
mik-now force-pushed the feat/env-scoped-ext branch from d2e0518 to deff577 Compare December 1, 2026 13:21
@sys-aibot

sys-aibot commented Dec 1, 2026 •

Copy link
Copy Markdown

Claude finished @mik-now's task in 1m 8s —— View job


Verdict: needs changes

Correctness

  1. toolkit_manager.sh:2213-2218: the "not provisioned, run init" error can no longer be reached for layers that live only in ext/. ensure_repos now always sets ENV_REPOS. With no record, the [[ -f "$f" ]] && … substitution at :867 sets it to "", which is set but empty. So _target_exists and known_layers only see the env's own repos. erag is defined only in ext/chatbot-toolkit/components.yaml, not in configs/components.yaml. Take an env that was inited only for inference, or a fresh env, and run install erag --env x. It now fails with Unknown target 'erag'. Layers: …, and that list leaves out erag. Before this PR it failed with env/x was not provisioned for layer 'erag'. Run: init erag --env x. To fix it, run the layer_manifest/solution_layers check before _target_exists, or let a layer that has a manifest pass _target_exists. Also add a test that goes through this path. The current test_without_a_record_scope_every_clone_is_read never calls ensure_repos, so it doesn't exercise what a real run does. Fix this →

  2. toolkit_manager.sh:860 with docs/deployment/upgrade.md:12-15: the code no longer requires --upgrade, but the error message and docs still do. test_init_moves_the_record_and_repoints_only_this_envs_configs is parametrized over upgrade=false/true and expects both to move the record and repoint configs. Nothing in _init_reconcile_pins or _init_seed_layer refuses a repo move, so plain init does the move too. Meanwhile:

    • the ensure_repos error says init <layer> --upgrade;
    • the docs say the env "is refused until you run init <layer> --upgrade";
    • the PR body says "Plain init refuses a repo move".

    Choose one behaviour. If plain init should move the repo, drop --upgrade from the error message and the docs. If it should not, restore the refusal and make the upgrade=false case expect a non-zero exit.

  3. toolkit_manager.sh:1253-1255: a failed repoint can't be retried. mv "$sol_new" "$sol" runs before _init_move_repo_paths. If sed -i fails partway (permissions, a read-only file), the record already names ext/<new>. On the next init, prev_repos equals the new repo, so the configs that still hold ext/<old>/ are never repointed, and nothing reports it. Repoint the configs before the mv, with the old repo taken from $sol and the new one from $sol_new. Then a failure leaves the old record in place and re-running init fixes it.

Readability / comments

  1. toolkit_manager.sh:706-708: this comment is now stale. The _ext_roles_dirs header still says "roles/ beside every ext components.yaml". It now only reads the repos in ENV_REPOS. Update it or drop it, since _ext_manifests already describes the scope.

  2. toolkit_manager.sh:276: this line is hard to read. roots=(${roots[@]+"${roots[@]/#/${EXT_DIR}/}"}) packs the empty-array guard and the prefixing into one expansion. A plain for r in …; do roots+=("${EXT_DIR}/$r"); done loop over the split list reads more easily and handles the empty case the same way.

  3. toolkit_manager.sh:45-46: the ENV_REPOS semantics are documented in three places. They appear here, in the ensure_repos header (:832-835) and in the preflight.yaml header (:11-13). Keep the preflight header and the ensure_repos note, and drop the comment above unset ENV_REPOS.

@AhmedSeemalK AhmedSeemalK left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

…names

Configs already came from env/<env>/.solutions.yaml, but roles and components were
discovered from every components.yaml under ext/, which every env shares. An old clone,
or one another env uses, could add components or shadow roles. ENV_REPOS (set by
ensure_repos from the record) now scopes the roles path, the merged registry and
preflight (as _env_repos); unset, all of ext/ is read as before.

A record naming a repo the manifests now clone elsewhere is refused, naming the init
that fixes it. After init writes the record, a layer whose repo changed gets
ext/<old>/ paths in that env's configs (e.g. deployment_dir) repointed to ext/<new>/,
so the hard-coded pre-rename guard is no longer needed.

Signed-off-by: Nowicki, Mikolaj <mikolaj.nowicki@intel.com>
@mik-now
mik-now force-pushed the feat/env-scoped-ext branch from deff577 to fcd1fa2 Compare December 1, 2026 14:50
@sys-aibot

sys-aibot commented Dec 1, 2026 •

Copy link
Copy Markdown

Claude finished @mik-now's task in 52s —— View job


Verdict: needs changes

Correctness

  1. toolkit_manager.sh:1254-1255: a failed repoint still can't be retried. This was point 3 in the last review and is unchanged. mv "$sol_new" "$sol" runs before _init_move_repo_paths. With set -euo pipefail, a sed -i that fails partway (read-only file, permissions) stops init after the record already names ext/<new>. On the next init, prev_repos already equals the new repo, so the configs that still hold ext/<old>/ are never repointed. ensure_repos won't catch it either, because it only compares the record with the manifest's dest:. The run then loads stale ext/<old>/ paths such as deployment_dir and nothing reports it. To fix it, read the old repo from $sol and the new one from $sol_new, and repoint before the mv. Then a failure leaves the old record in place and re-running init finishes the move. Fix this →

  2. src/tests/unit/test_env_repos.py:58: the test name doesn't match what it tests. test_without_a_record_scope_every_clone_is_read never calls ensure_repos, so it only covers ENV_REPOS being unset. In a real run with no record, toolkit_manager.sh:376 sets ENV_REPOS="", and that run reads no ext clones. Rename the test to say it covers the unset case (show, direct playbook runs). Also add a case that goes through ensure_repos with no .solutions.yaml and asserts _merged_components holds only the core components.

Readability / comments

  1. toolkit_manager.sh:707-709: this comment is still stale (point 4 last time). The _ext_roles_dirs header still says "roles/ beside every ext components.yaml". It now only reads the repos in ENV_REPOS. Drop the header, since _ext_manifests already describes the scope.

  2. toolkit_manager.sh:272: this line is hard to read (point 5 last time). roots=(${roots[@]+"${roots[@]/#/${EXT_DIR}/}"}) packs the empty-array guard and the prefixing into one expansion. A plain loop does the same and handles the empty case:

    local -a names; IFS=, read -ra names <<< "$ENV_REPOS"
    roots=(); for r in "${names[@]}"; do roots+=("${EXT_DIR}/$r"); done
  3. toolkit_manager.sh:45-46: the ENV_REPOS semantics are still documented three times (point 6 last time). They appear here, in the ensure_repos header (:837-840) and in the preflight.yaml header (:11-13). Drop the comment above unset ENV_REPOS.

A failed repoint now keeps the old record, so re-running init retries it.
Also: test a run with no record, drop stale/duplicate comments, plain loop
in _ext_manifests.

Signed-off-by: Nowicki, Mikolaj <mikolaj.nowicki@intel.com>
@sys-aibot

sys-aibot commented Dec 1, 2026 •

Copy link
Copy Markdown

Claude finished @mik-now's task in 55s —— View job


Verdict: needs changes

Correctness

  1. toolkit_manager.sh:2215-2216 with :2200: the "Unknown target" error tells the user to run show, and show lists the target. show returns from main before ensure_repos runs, so ENV_REPOS stays unset and show_table merges every components.yaml under ext/. A run, on the other hand, now only reads the env's recorded repos. Take an env inited only for inference with ext/chatbot-toolkit on disk, and run install <an erag component> --env x:

    • the layer check at :2209 doesn't fire, because the target is a component, not a layer;
    • _target_exists fails, so the run stops with Unknown target '<component>' … run './toolkit_manager.sh show' for components;
    • show then lists that component.

    For a layer target, the fix in :2209-2212 already points to init. A component target still gets the misleading message. Two ways to fix it:

    • scope show the same way when --env names an env that has a record;
    • or, when _target_exists fails, look the name up unscoped (ENV_REPOS unset). If it is found there, report the layer it belongs to and init <layer> --env <env> instead of "Unknown target".

    Add a test next to test_unprovisioned_layer_says_init_not_unknown that uses a component name instead of a layer name. Fix this →

@jpiaseck jpiaseck left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mik-now
mik-now merged commit 1db4b25 into intel:release-2.0 Dec 1, 2026
11 checks passed
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.

4 participants