Skip to content

Commit 4553c4e

Browse files
authored
feat: Install supporting backend payload folders (#30)
This PR extends backend installation so a matched backend package layout can specify a primary payload folder plus additional “supporting” payload folders, and have all of them copied into the installed backend directory (while preserving CompoundPathChecker first-match semantics). Changes: Added BackendInfo.supporting_paths and threaded it through BackendInstallation into repository copy logic. Extended PackagePathChecker with supporting_subfolders resolution and added focused tests for supporting folder selection/rejection and CompoundPathChecker behavior. Added OpenSpec documentation/spec artifacts describing the expected package-installation behavior.
1 parent 3e21e30 commit 4553c4e

15 files changed

Lines changed: 648 additions & 2 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
schema: spec-driven
2+
created: 2026-05-07
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SPDX-FileCopyrightText: Copyright 2026, Arm Limited and/or its affiliates.
2+
SPDX-License-Identifier: Apache-2.0
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
## Context
2+
3+
`PackagePathChecker` currently resolves one `BackendInfo.backend_path`. That
4+
keeps existing installs simple, but cannot express a package layout where one
5+
matched root contains a primary backend payload plus large, nested supporting
6+
folders that also need to be installed.
7+
8+
`CompoundPathChecker` should remain first-match wins. Its checkers describe
9+
alternative layouts; the selected checker should return all payload folders for
10+
that one layout.
11+
12+
## Goals / Non-Goals
13+
14+
**Goals:**
15+
16+
- Preserve existing no-subfolder and single-subfolder behavior.
17+
- Let one matched package checker describe a primary install source plus
18+
supporting folders.
19+
- Copy supporting folders recursively while preserving their relative names.
20+
- Keep the behavior local to path resolution and repository copy logic.
21+
22+
**Non-Goals:**
23+
24+
- Change `PyPackageBackendInstallation`, download, archive extraction, or EULA
25+
behavior.
26+
- Add glob, wildcard, or per-file selection rules.
27+
- Merge results from multiple successful `CompoundPathChecker` entries.
28+
29+
## Decisions
30+
31+
1. Keep `BackendInfo.backend_path` as the primary install source for
32+
compatibility, and add metadata for supporting folders.
33+
2. Copy each supporting folder as a recursive directory tree into the installed
34+
backend directory under its relative folder name.
35+
3. Keep `CompoundPathChecker` as a first-match selector; multi-folder copying
36+
comes only from the selected checker result.
37+
38+
## Risks / Trade-offs
39+
40+
- Sequence-like subfolder input can be confused with a string. Normalize strings
41+
separately and test both forms.
42+
- Multi-folder copy adds a repository code path. Keep it narrow and test nested
43+
supporting folder contents.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SPDX-FileCopyrightText: Copyright 2026, Arm Limited and/or its affiliates.
2+
SPDX-License-Identifier: Apache-2.0
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
## Why
2+
3+
Some backend packages have one primary payload plus additional supporting
4+
folders under the same validated root. Today the path checker can validate that
5+
layout but returns only one install source, so supporting folders are not copied.
6+
7+
## What Changes
8+
9+
- Allow a matched path checker to return a primary install source plus
10+
additional supporting folders from the same package layout.
11+
- Extend `PackagePathChecker` for this metadata while preserving existing
12+
no-subfolder and single-subfolder behavior.
13+
- Keep `CompoundPathChecker` first-match semantics; it selects one complete
14+
layout rather than merging separate checker results.
15+
- Copy supporting folders recursively without requiring per-file configuration.
16+
17+
## Capabilities
18+
19+
### New Capabilities
20+
21+
- `backend-package-installation`: Defines how backend package layouts are
22+
validated and how primary and supporting payload folders are selected for
23+
repository installation.
24+
25+
### Modified Capabilities
26+
27+
None.
28+
29+
## Impact
30+
31+
- Core code: `src/mlia/backend/install.py`, backend repository copy logic, and
32+
backend installation tests.
33+
- Plugin configuration: callers that compose `PackagePathChecker` and
34+
`CompoundPathChecker`.
35+
- No new runtime dependencies are expected.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SPDX-FileCopyrightText: Copyright 2026, Arm Limited and/or its affiliates.
2+
SPDX-License-Identifier: Apache-2.0
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
## ADDED Requirements
2+
3+
### Requirement: Backend layout validation precedes payload selection
4+
5+
The system SHALL validate configured backend layout expected files before
6+
selecting any backend payload folder for installation.
7+
8+
#### Scenario: Valid package root with selected payload folders
9+
10+
- **WHEN** a backend package contains all configured package-root expected files
11+
and each configured payload folder exists
12+
- **THEN** the backend package is accepted as installable
13+
14+
#### Scenario: Missing expected file
15+
16+
- **WHEN** a backend layout is missing a configured expected file
17+
- **THEN** the backend layout is rejected before any payload folder is
18+
selected
19+
20+
### Requirement: Multiple backend payload folders can be installed from one matched layout
21+
22+
The system SHALL allow backend installation configuration to select multiple
23+
backend payload folders from the same matched package layout.
24+
25+
#### Scenario: Installing primary and supporting payload folders
26+
27+
- **WHEN** a backend package is configured to install a primary payload folder
28+
and an additional supporting payload folder from the same package root
29+
- **THEN** the installed backend repository entry contains both configured
30+
payload folders from that package
31+
32+
#### Scenario: Installing deeply nested supporting payload folder
33+
34+
- **WHEN** a configured supporting payload folder contains nested directories
35+
and many files
36+
- **THEN** the installed backend repository entry contains the complete
37+
supporting payload folder tree
38+
39+
#### Scenario: Missing configured payload folder
40+
41+
- **WHEN** a backend layout is configured with multiple payload folders and any
42+
configured payload folder is missing or is not a directory
43+
- **THEN** the backend layout is rejected as not installable
44+
45+
### Requirement: Compound path checking selects one complete layout
46+
47+
The system SHALL keep compound path checking as first-match selection between
48+
alternative backend layouts.
49+
50+
#### Scenario: Earlier package layout matches before later layout
51+
52+
- **WHEN** a compound path checker contains a matching package checker before a
53+
later matching checker
54+
- **THEN** the first package checker result is used as the complete backend
55+
install source set
56+
57+
#### Scenario: First matched checker includes multiple payload folders
58+
59+
- **WHEN** the first matched checker selects multiple payload folders
60+
- **THEN** all payload folders from that matched checker are installed and later
61+
checker results are ignored
62+
63+
### Requirement: Existing single-source behavior is preserved
64+
65+
The system SHALL preserve existing `PackagePathChecker` behavior for backend
66+
layouts configured with no payload folder override or one payload folder
67+
override.
68+
69+
#### Scenario: No backend payload folder configured
70+
71+
- **WHEN** a backend layout is configured without a payload folder override and
72+
the layout root contains all expected files
73+
- **THEN** the layout root is used as the backend install source
74+
75+
#### Scenario: One package payload folder configured
76+
77+
- **WHEN** a backend package is configured with one payload folder and that
78+
folder exists
79+
- **THEN** the single folder remains the backend install source
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SPDX-FileCopyrightText: Copyright 2026, Arm Limited and/or its affiliates.
2+
SPDX-License-Identifier: Apache-2.0
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
## 1. Tests
2+
3+
- [x] 1.1 Add a failing backend installation test that installs a primary
4+
payload folder and an additional supporting payload folder from one vendored
5+
backend package and verifies both directories are present in the repository.
6+
- [x] 1.2 Add a failing backend installation test where the supporting payload
7+
folder contains a nested directory tree and verifies nested files are copied
8+
recursively.
9+
- [x] 1.3 Add focused tests for `PackagePathChecker` compatibility with no
10+
`backend_subfolder`, one string `backend_subfolder`, and multiple configured
11+
payload folders.
12+
- [x] 1.5 Add a failing test for rejection when one configured backend payload
13+
folder is missing or is not a directory.
14+
- [x] 1.6 Add a `CompoundPathChecker` regression test showing first-match
15+
behavior is preserved and the first matched checker can still return multiple
16+
payload folders.
17+
18+
## 2. Core Implementation
19+
20+
- [x] 2.1 Extend backend path resolution metadata so one matched checker can
21+
describe multiple selected payload folders without breaking existing
22+
`BackendInfo.backend_path` callers.
23+
- [x] 2.2 Extend `PackagePathChecker` to accept and normalize multiple backend
24+
payload folders while preserving string `backend_subfolder` behavior.
25+
- [x] 2.4 Update `BackendInstallation._install_from()` and repository copy logic
26+
to copy multiple selected payload folders into the installed backend directory
27+
while preserving their relative names and nested contents.
28+
- [x] 2.5 Ensure missing configured payload folders cause path checking to fail
29+
before installation.
30+
- [x] 2.6 Leave downstream backend plugin configuration to the owning package;
31+
this core change only exposes the supporting payload folder API.
32+
33+
## 3. Validation
34+
35+
- [x] 3.1 Run the focused MLIA backend installation tests.
36+
- [x] 3.2 Skip backend plugin installation tests because downstream plugin
37+
changes are outside this package.
38+
- [x] 3.3 Run lint/type checks required for the touched files.
39+
- [x] 3.4 Run the quick non-slow pytest suite if the focused checks pass.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SPDX-FileCopyrightText: Copyright 2026, Arm Limited and/or its affiliates.
2+
SPDX-License-Identifier: Apache-2.0

0 commit comments

Comments
 (0)