Expand description
Armory Bundle Format (ABF) importer — Phase 2 of
docs/specs/SPEC_ABF_V0_1_SINGLE_FILE_AND_IMPORTER_2026_08_01.md.
Inverse of bundle_export.rs: takes a bundle’s files (either a raw
[{path, content}] list or an unpacked .abf zip archive) and
validates + parses them into data ready for the bundle.import RPC
handler to write to the Store.
Pure functions only — no I/O, no Store access, no account resolution
(account resolution needs db_accounts, which only the RPC handler has
access to; see the spec’s §4.5). Mirrors bundle_export.rs’s shape and
quality bar deliberately: the same “warn, don’t silently drop” and
“reject the whole thing on structural failure, but never partially
import on a per-entry problem” philosophy, since the two modules are
meant to round-trip against each other.
Modules§
- parse_
steps - The steps of
parse_bundle_import_with_budget, one function each, in the order they ran: the manifest, then each component category (instructions, skills, MCP servers, account requirements, the memory note, project instructions). Moved out of it without a change in behaviour, so every warning is still pushed in the same order. A child module ofbundle_import.rs, whose private helpers and caps these use.
Structs§
- Account
Requirement - One
accounts/requirements.jsonentry — mirrors the shapebundle_export.rswrites (research report §5.3). - Bundle
Import File - One file read from an import source (zip or raw list), path relative
to the bundle root. Mirrors
bundle_export::BundleExportFile. - Imported
Context File - One
instructions/context/*file, in the[{path, content}]shapedb_bundles.context_filesstores. - Imported
Project Instruction - One
components.projectInstructionsentry, read back out of the bundle. - Parsed
Bundle Import - Parsed, validated bundle content ready for the RPC handler to resolve
accounts against and write to the Store.
mcp_serversstill contains whatever${VAR}-style placeholders the exporter’s redaction left in place — account resolution (§4.5, RPC-handler-side) substitutes real account bindings where exactly one match is found and leaves the rest untouched. - Parsed
McpServer - An MCP server parsed out of a
components.mcpServersreference — Phase 3 spec §3.0.source_pathis the stable, always-unique selection key (the manifest path reference, distinct from whatever"name"field happens to appear insideconfig’s arbitrary JSON, which has no uniqueness guarantee and isn’t even required to be present). - Parsed
Skill - A skill parsed out of a
skills/<slug>/SKILL.mdfile — the inverse ofagent_config::render_skill_md. - Warning
Budget - Bounds how many warnings a parse call accumulates, and how long each
individual warning string may be — Phase 3 spec
(
SPEC_ABF_IMPORT_UI_PHASE3_2026_08_02.md) §3.1, round 11: the cap must live at the point warnings are actually PRODUCED, not only at a later RPC-response-serialization boundary, or a hostile archive can still force the parser itself to build an unboundedVec<String>in memory before any cap ever runs.unbounded()preserves today’s existingbundle.importroute’s real, already-shipped behavior exactly — this is a capability the parser gains, not a behavior change forced onto Phase 2’s existing caller.
Enums§
- Import
Input Mode - Which of the three
bundle.import.preview/.commitinput fields produced a given payload — mixed into the content-digest hash domain itself (Phase 3 spec §3.0.5, round 7) so afile_pathpreview can never be satisfied by azip_base64commit of the identical underlying bytes (both canonicalize to the same raw zip bytes and would otherwise hash identically), closing the gap a bare byte-digest comparison left open.
Constants§
- LEGACY_
MANIFEST_ FILE - The manifest of ABF v0.1 and v0.2 archives, read forever.
- MANIFEST_
FILE - The manifest an ABF v0.3 archive carries (SPEC_AGENT_BUNDLE_FORMAT_V0_3_2026_10_05.md §2.1).
- MAX_
BUNDLE_ NAME_ CHARS - Maximum character length of a bundle’s manifest
name, enforced at parse time (Phase 3 spec §3.1, round 13) rather than at a later display boundary —nameis re-submitted verbatim asbundle_namewhen a user doesn’t edit the preview’s suggested value, so the canonical, bounded value must be what bothpreviewandcommitconverge on from the moment parsing completes. Generous for any real bundle name. - MAX_
DISPLAY_ FIELD_ CHARS - Fixed-character display cap shared by every “meant to be short” bounded
field this spec defines: skill
description/slug(rounds 10/12), requirementid/provider/env(round 11), context-filedisplay_path(round 13), and bundledescription(round 12 self-audit). - MAX_
IMPORTED_ PROJECT_ INSTRUCTIONS - Cap on how many
components.projectInstructionsentries are read back. - MAX_
IMPORTED_ SKILLS - Maximum number of skills actually imported (i.e. written to the Store)
from a single bundle.
MAX_ENTRY_COUNT/capped_component_arraybound how manycomponents.skillsentries are even LOOKED AT, but codex P1 (PR #2379 round 7) points out that’s still far too high a ceiling for the RPC handler’s write side: importing up to that many skills means up to that many separate synchronous Store transactions, each creating a permanent, globally-visible skill row — a compact malicious archive (well within the size caps) could otherwise monopolize the handler and pollute the installation’s skill catalog. A real bundle needs a handful to a few dozen skills at most. - MAX_
INSTRUCTIONS_ PREVIEW_ CHARS - Cap on
instructions_preview(Phase 3 spec §3.1, round 5) — generous for a glance-and-decide preview; bounds worst-case JSON-escaped response size to roughly 300 KB rather than the ~300 MB a maximally-adversarial, unboundedinstructionsstring could otherwise force. - MAX_
MCP_ DISPLAY_ FIELD_ CHARS - Fixed-character display cap for an MCP server’s projected
name/command(Phase 3 spec §3.1, round 7) — smaller thanMAX_DISPLAY_FIELD_CHARSsince these are meant to be short identifiers/executable names, not free-form text. - MEMORY_
COMPONENT_ IGNORED_ WARNING - SCHEMA_
V0_ 3 - The
$schemaan ABF v0.3 manifest names.
Functions§
- abf_
format_ version - The ABF format version a manifest declares through its
$schema, orNonewhen it names none this importer knows. Theversionfield is the bundle’s own content version, not this. - bound_
bundle_ name - Bounds a bundle name to
MAX_BUNDLE_NAME_CHARSvia plain truncation (no ellipsis, unliketruncate_display) — this IS the canonical value, not a display abbreviation of a longer “real” one. Shared byparse_bundle_import’s own manifest-namebounding and the Phase 3bundle.import.commitRPC’sbundle_nameoverride (round 3), so a client-supplied override can’t bypass the same boundparsed.nameis already held to. - bounded_
instructions_ preview - Bounds
instructions_previewfor the RPC response — returns(preview, truncated, total_chars). The full, untruncatedinstructionsvalue is unaffected; this only bounds what’s echoed back for display (Phase 3 spec §3.1, rounds 5 and 8). - classify_
skill_ collision "none"/"name_conflict"/"duplicate_in_bundle"— Phase 3 spec §3.1’s two-pass skill collision classification.global_slugsis whatever the caller already fetched fromskill.catalog.list’s underlyingskill_list_global()(Store access lives in the RPC handler, not here — this stays a pure function so it’s testable with a seeded fake global-skill list, per the spec’s own §6 testing notes). Pass 1 (global catalog) takes priority over pass 2 (intra-bundle duplicate) when both apply, matching §3.1’s stated precedence.- content_
digest_ files - SHA-256 content digest for
files-mode input (§3.0.5, round 6) — hashesparse_bundle_import’s own effective, order-resolved representation ([dedup_files_by_path]’s normalize-then-first-wins reduction, sorted by normalized key), not the raw input array. This makes the digest order-independent for genuinely equivalent inputs while remaining sensitive to any reordering that would actually change which entry the parser’s first-wins rule keeps. - content_
digest_ raw_ bytes - SHA-256 content digest for
file_path/zip_base64input — both canonicalize to the same thing (raw zip bytes), differentiated only by the mode tag mixed into the hash domain (§3.0.5, round 7). - duplicate_
in_ bundle_ slugs - Every parsed skill slug that appears more than once across the WHOLE
bundle — the
"duplicate_in_bundle"collision pass (Phase 3 spec §3.1, codex P1 round 2), computed independently of any external global-catalog state so it’s pure and directly testable. - enforce_
raw_ files_ caps - Applies [
check_entry_size]’s caps (plus [MAX_ENTRY_COUNT]) to the rawfilesRPC intake path — the pathunzip_bundle_importnever covers (reagent P1, PR #2379 round 5). Unlike zip entries, a raw file’scontentis already fully materialized (no separate declared-vs-actual distinction, no incremental decompression to bound), so this only needs the shared per-entry/aggregate check, no backstop-read machinery. - enforce_
raw_ files_ caps_ with_ budget - Same as
enforce_raw_files_caps, but with an explicitWarningBudget(Phase 3 spec §3.1, round 11). - manifest_
file_ name - Which manifest file a set of archive paths carries:
bundle.json, else the legacyarmory.json. - mcp_
server_ display - Bounded
{name, command}projection of an MCP server’s fullconfig(Phase 3 spec §3.1, round 7) — the fullconfigis never returned in preview/commit responses, only this small, defensively-extracted projection. Falls back tonullfor either field when absent or not a string, since MCP JSON has no required shape (§3.0). - newer_
abf_ refusal - The plain refusal for a manifest whose
$schemanames an ABF format newer than this build reads, orNone(a format this build reads, or a$schemathat names no ABF format: those keep the warning inwarn_on_schema). It names the format and, when the bundle says which AgentMux made it (metadata.agentmuxVersion), that version. Such a bundle is refused whole: a newer format can change what a component means, and importing what this build can make sense of would be a half import. - parse_
bundle_ import - Parse and validate a bundle’s files into
ParsedBundleImport. Structural failures (no manifest,bundle.jsonorarmory.json, or a malformed one) reject the whole import —Err— since there is nothing safe to partially write. Per-entry problems (a missing referenced file, an unsafe path, a malformed SKILL.md) degrade to a warning and that entry is skipped — matchesbundle_export.rs’s own philosophy, and lets a lossy import still produce a usable bundle rather than an all-or-nothing failure on e.g. one corrupt skill among five good ones. - parse_
bundle_ import_ with_ budget - Same as
parse_bundle_import, but with an explicitWarningBudgetenforced at every warning-push site inside this function (Phase 3 spec §3.1, round 11) — the newbundle.import.preview/.commitRPC handlers call this directly with a tight budget;parse_bundle_importpassesWarningBudget::unbounded, preserving today’s existingbundle.importroute’s behavior exactly. - truncate_
display - Fixed-character truncation shared by every bounded-display projection
this module (and its RPC callers, Phase 3 spec §3.1/§3.2) define —
stated once so
previewandcommitalways apply IDENTICAL bounds to the equivalent field, rather than independent per-endpoint copies drifting apart (the exact class of gap codex found and re-found across rounds 9 and 12). - unzip_
bundle_ import - Unpack a
.abfzip archive into a flat file list, applying the same path-safety check as everywhere else in this module to every entry name before it’s trusted (§4.3.4) — a zip’s own internal paths are exactly as untrusted as any other part of the archive’s content. Directory entries are skipped; anything that fails the safety check is dropped with a warning rather than surfaced as a file. - unzip_
bundle_ import_ with_ budget - Same as
unzip_bundle_import, but with an explicitWarningBudget(Phase 3 spec §3.1, round 11).