fix(build): rewrite app_pack references to materialised paths#104
Open
BimaPangestu28 wants to merge 1 commit into
Open
fix(build): rewrite app_pack references to materialised paths#104BimaPangestu28 wants to merge 1 commit into
BimaPangestu28 wants to merge 1 commit into
Conversation
`gtc setup doctor`'s `setup.bundle_manifest.reference_exists` check
on a freshly-built `.gtbundle` failed with:
```
[ERROR] reference_exists: file:///<bundle_root>/file://./testing.gtpack
expected: referenced .gtpack exists
actual: file://./testing.gtpack
```
even though the file IS in the squashfs at `packs/testing.gtpack`.
Two layered bugs:
1. The bundle.yaml that ships *inside* the squashfs carried the
user-source-relative reference (`file://./testing.gtpack`) while
`app_pack_copy_targets` had moved the file into `packs/<id>.gtpack`
(or `tenants/.../packs/...` for scoped mappings). The doctor's
resolver concatenated bundle root with the verbatim reference and
the resulting path didn't exist.
2. The doctor's resolver doesn't strip the `file://` scheme — it
treats the whole string as a relative path component. Even after
rewriting to `file://./packs/testing.gtpack` the doctor still
tried to open `<bundle_root>/file://./packs/testing.gtpack`. The
shape it actually understands is a bare relative path:
`packs/testing.gtpack`.
## Changes
- `src/project/mod.rs`:
- `MaterializedCopyTarget` + `app_pack_copy_targets` exposed as
`pub(crate)` so the build layer can reuse the same destination
rules without duplicating slug logic.
- In `build_manifest` (the resolved-YAML producer), each
`ResolvedReferencePolicy.reference` gets rewritten to its
materialised destination (bare relative path, no scheme). This
is the YAML the doctor reads when validating.
- `src/build/plan.rs`:
- `build_state` parses the manifest fields from the user-authored
YAML *before* any rewrite — `bundle-manifest.json`'s `app_packs`
keeps the canonical references the workspace declared, since
downstream tooling (catalog hooks, lock-file generators) expects
those.
- The bundle.yaml that ships inside the squashfs is rewritten via
a new `rewrite_app_pack_references_in_yaml` helper that operates
on the raw YAML text — comments, quoting, section ordering all
survive (re-emitting via serde would lose all of that).
- 4 unit tests cover the rewrite helper (replace, no-op, leave
unrelated refs alone, empty list).
The user's source bundle.yaml on disk is left untouched. The
canonical references are still recorded in `bundle.lock.json`.
Only the YAMLs that ship inside the squashfs are rewritten so the
runtime + doctor can resolve them against the squashfs root.
## Test plan
- `cargo fmt --all -- --check` clean
- `cargo clippy --all-targets --all-features -- -D warnings` clean
- `cargo test --workspace` — 170+/170+ pass (one existing wizard
test updated to assert the new bare-path reference shape — its
setup involves a slugified pack id that lands at
`packs/cisco-bundle.gtpack` post-materialisation).
- End-to-end doctor smoke against a real designer-built bundle
(28-node `support-ticket-router` canvas via the research
designer's `/api/wizard/build`): `reference_exists` ERROR is now
GONE. Remaining errors are the expected develop-mode limitations
(`answers.present` — webchat setup wizard hasn't run; cosmetic
`:latest`-tag warnings; lock + static-routes skipped in develop
mode).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
`gtc setup doctor` on a freshly-built `.gtbundle` failed with `setup.bundle_manifest.reference_exists` because bundle.yaml shipped the user-source-relative `file://./.gtpack` reference while the materialiser had moved the file to `packs/.gtpack`. Doctor's resolver tried `bundle_root.join(reference)` and the file didn't exist there.
Layered bugs
Fix
Verification
End-to-end smoke against a real 28-node `support-ticket-router` canvas via the research designer's `/api/wizard/build`:
Remaining `answers.present` ERROR + 4 warnings are expected develop-mode limitations (webchat setup wizard hasn't run; cosmetic `:latest`-tag warnings; lock + static-routes skipped in develop mode), not path/build bugs.
Branching
Targets `research` per the cross-repo research-branch convention. Once stable, promote to develop alongside the other ongoing research-tier work.