Skip to main content

Module import

Module import 

Source
Expand description

bundle.import, bundle.import.preview, bundle.import.commit: the ABF file/bytes intake path, its size and warning budgets, and the two-phase preview/commit flow.

Structsยง

BundleImportReq ๐Ÿ”’
BundleImportResponse ๐Ÿ”’
Response for bundle.import.
ResolvedImportInput ๐Ÿ”’
The outcome of resolving one of file_path/zip_base64/files into intake-ready files plus the Phase 3 content digest (ยง3.0.5) โ€” shared by bundle.import.preview and .commit so both compute the digest identically. The mode tag baked into content_digest (round 7) means a plain digest-equality check at commit is sufficient to enforce โ€œsame input mode as previewโ€ (round 6) โ€” no separate mode field is needed.

Constantsยง

MAX_ABF_FILE_SIZE_BYTES ๐Ÿ”’
On-disk size ceiling for file_path input (Phase 3 spec ยง3.0.5, rounds 4/5) โ€” generous headroom above MAX_TOTAL_UNCOMPRESSED_BYTESโ€™s 50 MiB for compression/container overhead and imperfectly-compressed content.
MAX_PROJECT_INSTRUCTION_PREVIEW_CHARS ๐Ÿ”’
Final combined-list bound applied to a preview/commit responseโ€™s warnings (Phase 3 spec ยง3.1 round 8 / round 9โ€™s commit-response generalization) โ€” cheap defense-in-depth over an already per-source-bounded list (each of resolve_import_inputโ€™s intake warnings and parse_bundle_import_with_budgetโ€™s own warnings is already individually bounded; concatenating two independently-bounded lists can still exceed either bound alone, so one more pass caps the combined total before itโ€™s ever serialized). Per-entry content cap for project_instructions in an import preview.

Functionsยง

bound_warnings_for_response ๐Ÿ”’
bundle_import ๐Ÿ”’
bundle.import โ€” ABF importer, Phase 2 of docs/specs/SPEC_ABF_V0_1_SINGLE_FILE_AND_IMPORTER_2026_08_01.md. Window- scoped like bundle.export (bundles arenโ€™t agent-specific). Accepts EITHER zip_base64 (a .abf archive, mirroring bundle.exportโ€™s own zip_base64 response field) OR files (a raw [{path, content}] list) โ€” exactly one must be present. Hands the bytes to the pure bundle_import module for parsing/validation, then owns every Store side-effect: creates the bundle row, creates one global Skill row per parsed skill, and performs READ-ONLY account-requirement lookups (never creates an account, never writes a secret anywhere โ€” see the specโ€™s ยง4.5 correction for why this stopped short of โ€œresolvingโ€ placeholders in place).
bundle_import_commit_impl ๐Ÿ”’
bundle.import.commit โ€” Phase 3 ยง3.2. Re-resolves and re-parses the same input fresh (never trusts client-supplied preview data for anything written), rejects on a content-digest mismatch, then writes only the selected items. Shares bundle.importโ€™s existing skill-write/ rollback logic; the differences are selection filtering, the bundle_name/import_as overrides, and the digest gate. Extracted from the RPC closure into a directly-callable, directly-testable function (the closure itself only deserializes the request and forwards).
bundle_import_intake ๐Ÿ”’
Parses the two intake shapes of bundle.import โ€“ zip_base64 or a raw files list, exactly one โ€“ into the file list plus the intake warnings.
bundle_import_preview_impl ๐Ÿ”’
bundle.import.preview โ€” Phase 3 of docs/specs/SPEC_ABF_IMPORT_UI_PHASE3_2026_08_02.md ยง3.1. Pure parse plus read-only collision/name-collision lookups โ€” zero Store writes. Window- scoped like the rest of bundle.*. Extracted from the RPC closure into a directly-callable, directly-testable function (the closure itself only deserializes the request and forwards).
commit_bundle_row ๐Ÿ”’
The bundle row a commit writes: the parsed bundle with only the selected components.
context_file_previews ๐Ÿ”’
create_global_skills ๐Ÿ”’
Skills โ€” global, not bound to any agent (mirrors skill.catalog.upsertโ€™s own is_global: true convention for a shared-resource creation path). A genuine name conflict (the ONLY intentional business error skill_upsert_unique_global returns โ€” StoreError::Other containing โ€œalready existsโ€) is a per-skill warning, not an aborted import. Codex P2, PR #2379: any OTHER error (locked/corrupt store, I/O failure) previously hit this same arm and was silently treated as a skip too โ€” turning an infrastructure failure into an apparently-successful lossy import. Only the confirmed-conflict shape is swallowed; anything else aborts the whole RPC.
dedupe_skill_selections ๐Ÿ”’
The selections to import: the client-supplied include_skills has no length cap and no dedup by source_dir, so an unbounded or repeated array could otherwise drive an unbounded number of skill_upsert_unique_global writes regardless of how many skills the archive itself parsed to (parsed.skills is already bounded by MAX_IMPORTED_SKILLS). First occurrence wins per source_dir, then the list is capped at the same MAX_IMPORTED_SKILLS the parser enforces.
import_selected_skills ๐Ÿ”’
Write the selected skills as global skills and return the ids created. A skill whose slug collides and has no non-empty rename is skipped; a name conflict at write time is a warning and a skip; any other write error rolls back the skills already created and fails the commit.
imported_bundle_row ๐Ÿ”’
The bundle row a parsed import becomes.
install_bundle_widgets ๐Ÿ”’
After a commit: copy in the chosen widgets and ask the user to approve each, the way an agentโ€™s WidgetInstall does. The archive is read again and held to the digest the user previewed, so what installs is what they saw (SPEC_WIDGET_SHARING_2026_10_10.md ยง3.3). A bundle never approves a widget.
mcp_server_previews ๐Ÿ”’
preview_commit_warning_budget ๐Ÿ”’
Bounded warning budget shared by bundle.import.preview/.commit (Phase 3 spec ยง3.1, round 11) โ€” unlike the existing bundle.import routeโ€™s effectively-unbounded budget, preserved unchanged above.
preview_widgets ๐Ÿ”’
The import previewโ€™s line for each widget the bundle carries.
project_instruction_previews ๐Ÿ”’
Phase 3, Codex P1 on PR #3163. Read-only: this is what the SOURCE agent was reading, and bundle.import.commit has no counterpart field โ€” the entries exist to be looked at, never to be written into the importing repository (spec ยง5.2). Each content is bounded the same way instructions_preview is, since a snapshot can be an arbitrarily large repository file and the response carries up to MAX_IMPORTED_PROJECT_INSTRUCTIONS of them.
read_abf_file_path ๐Ÿ”’
Reads a file_path input server-side (Phase 3 spec ยง3.0.5). Opens the path with a no-follow mechanism so a symlink fails to open at all rather than being silently resolved to its target (round 6) โ€” one handle, one continuous read, no second path resolution for anything to race against (round 5โ€™s TOCTOU fix): metadata comes from that SAME open handle and is checked against MAX_ABF_FILE_SIZE_BYTES BEFORE any read (round 4); the actual read is still hard-bounded via .take(...) regardless of what the metadata claimed.
register_bundle_import ๐Ÿ”’
register_bundle_import_commit ๐Ÿ”’
register_bundle_import_preview ๐Ÿ”’
requirement_previews ๐Ÿ”’
resolve_import_input ๐Ÿ”’
rollback_skill_rows ๐Ÿ”’
Delete the skill rows a failed commit already created; returns one message per row that would not delete.
rollback_skills ๐Ÿ”’
codex P2, PR #2379 round 4: rollback previously discarded every skill_delete error via let _ = ..., so if the SAME failing store also rejects the cleanup deletes, previously- inserted global skills could silently survive an RPC that reports failure. No transaction primitive exists on Store today, so full atomicity is out of scope here; surfacing the rollback failure instead of swallowing it is the fix that fits โ€” the caller at least learns cleanup itself may not have fully succeeded.
skill_previews ๐Ÿ”’
Skill collision detection (ยง3.1, two-pass): against the skills already installed, and among the bundleโ€™s own.
split_requirements ๐Ÿ”’
The commit responseโ€™s requirement lists, using the same bounded-display projection as preview.
split_widgets ๐Ÿ”’
Takes a zipโ€™s widget entries out of the text files and their warnings, and reads them as bytes instead.