Skip to content

M6-S2 — The package contract: format, schemas and the dependency graph

Section titled “M6-S2 — The package contract: format, schemas and the dependency graph”
ModuleM6 — Extension design
After this session you canRead a package as the platform writes it, predict what its dependency graph pulls in, and choose how to produce a package for a need.
Time56 min with a facilitator · about 56 min on your own
Before you startM2-S3 (definitions as a wire contract) and M6-S1. Larkspur Lab, Rami Aziz signed in; a terminal with unzip and jq. The chain you built on Work Orders in M4-S2 is still there. Keep the package contract card open.
Go deeperThe package format · The dependency graph · Generating a package · Package resource schemas

◆ Orientation (1 min) — The file that carries a design

Section titled “◆ Orientation (1 min) — The file that carries a design”

In ACE M8-S1 you packaged and promoted a suite through the wizard, and learned what travels and what does not. A master needs more: Larkspur will promote packages between environments for years, through scripts as well as screens, and every failed promotion is diagnosed from the file. In this session you open a real export of Asset Maintenance, read it file by file, and learn to predict from its dependency edges what the import will do. M6-S3 then drives the import itself, and M7-S4 ships your own capability this way.

▤ Concept (8 min) — Files, edges, paths

Section titled “▤ Concept (8 min) — Files, edges, paths”

A package is a ZIP with a fixed top level. Anything else at the top level fails the import at once.

EntryRequiredWhat it holds
manifest.jsonyesThe format’s schemaVersion, when and where it was exported, how many resources of which types
index.jsonyesEvery resource in dependency order, and the name map from each resource id to its file name
dependencies.jsonyes, in practiceThe dependency edges: what each resource points at, and where in its JSON
resources/<Type>/<name>.jsonthe payloadOne snapshot per resource, grouped by type
entry-references.jsonoptionalRecords the design points at (a step’s owner group, a user), with enough data to create them in the target
store-references.json, file-references.json, files/optionalShared stores the entities use; files such as templates, and their bytes
config.jsonwritten by every exportAn echo of the export request; the importer ignores it
field-mapping-hints.json, hashes.json, package-references.json, README.mdsince 1.10, optionalMapped-field hints; and, for a published package version, its hashes, cross-package references and readme

The manifest’s schemaVersion is a compatibility gate. The exporter writes the lowest version that describes the file: 1.1 for a plain export, 1.2 once it carries mapped-field hints, 1.3 and 1.4 for published versions. A 1.10 importer accepts 1.0 to 1.4; an importer older than 1.10 accepts only 1.0 and 1.1. So a module with mapped fields exported from a 1.10 environment cannot be imported into an older one: it is refused as an incompatible schema before anything is read. That is a fact for your promotion plan whenever environments are upgraded at different times.

The snapshot files are the stored definitions you met in M2-S3, minus what belongs to the source environment: database ids and audit stamps are removed, view execution plans are dropped and rebuilt in the target, and the items of a list backed by an entity are emptied, because records do not travel. Each resource keeps its own source id, which the importer uses as the key of its remapping table.

What is never a resource. Seventeen types can be exported: modules, entities, views, queries, relations, lists, reactions, pages, buttons, statistic queries, reports, Functions, counters, announcements, aggregates, and since 1.10 quick-filter groups and tag groups. Dashboards are records of a system entity, not resources. Users, groups, organization units and working hours exist in every environment, so they travel only as references to be matched or created in the target.

The dependency service keeps a live graph of every resource and what it points at. At export time, the exporter walks that graph from what you selected and writes the edges it walked into dependencies.json. An edge looks like this:

{ "from": { "type": "DataView", "id": "5f0c…", "normalizedName": "open_work_orders" },
"to": { "type": "DataEntity", "id": "a91d…", "normalizedName": "work_orders" },
"kind": "MEMBERSHIP", "hard": true, "path": "dataEntity", "resolvedVia": "DIRECT_ID" }
  • kind is MEMBERSHIP (the view belongs to the entity; this is what “with children” follows) or REFERENCE (a cross-reference to an independent resource).
  • hard says whether the source can function without the target. Only hard edges extend the export: a soft edge is recorded, but what it points at is not pulled in.
  • path is where, inside the source’s JSON, the target’s id sits, such as dataEntity or columns[0].entityId. It is what lets the importer rewrite ids precisely.
flowchart LR
  E["Edges in dependencies.json"] --> O["Order: sort with all edges;<br/>if a cycle, drop soft edges;<br/>a hard cycle is ordered as one block"]
  E --> R["Remap: at each edge's path, replace<br/>the source id with the target id"]
  E --> S["Skip: a skipped or failed resource<br/>skips every hard dependent"]
  R --> N["A soft edge whose target is missing:<br/>the value at its path becomes null"]

What to notice: the same edges decide three things. A wrong edge does not fail loudly; it orders, rewrites or skips wrongly.

At import, the edges drive three things. The order: the importer ignores the index’s order and sorts again from the edges, so a resource is written after what it needs; a soft cycle is broken by dropping soft edges, a hard cycle is ordered as one block and broken at write time by creating one member as a stub. The remapping: every id is rewritten at its edge’s path, but only if the value there is exactly the source id; anything else is left alone. And the skips: when a resource is skipped or fails, every resource that depends on it through a hard edge is marked cascade skipped. A soft edge whose target exists in neither the package nor the target is set to null.

PathWhenWhat it costs
Export, transform, re-importYou want a variant of something an environment already hasEvery change you make to a payload must keep the edges true: change an id without its edge and it is never rewritten
Overrides on an import sessionThe same package, different values per environment (an address, a threshold)Only content, never structure: the fields that say where a resource lives cannot be overridden (M6-S3)
Hand-authoringResources no environment ever containedUnsupported: you reimplement the exporter, and the importer’s only safety net checks the container, not the consistency

The rule that follows: start from an artifact the platform built, and parameterise it through the API built for that. M6-S3 shows the override API; the package contract card keeps the rules on one page.

▶ Guided demo (10 min) — An export, started and fetched

Section titled “▶ Guided demo (10 min) — An export, started and fetched”

Starting state. Larkspur Lab as seeded, plus your M4-S2 chain on Work Orders.

  1. Open Packages › Build › Exports and start a new export. The Export resources page opens with the space’s resources on the left.
  2. Select the module Asset Maintenance with its children. The right panel lists the selection and External dependencies: resources outside the module that it needs, such as the entity Suppliers, which Spare Parts references.
  3. Do not add the dependencies. Select Export All. The status moves through Preparing… and Exporting… to Export ready.
  4. Select Download file and save it as asset-maintenance.zip.
  5. List it: unzip -l asset-maintenance.zip | head -30. The top level holds manifest.json, index.json, dependencies.json, config.json and resources/.
  6. Read the manifest: unzip -p asset-maintenance.zip manifest.json | jq '{schemaVersion, resourceCount, resourceTypes, sourceSpaceId}'.

Screenshot pending The Export resources page with Asset Maintenance selected and the External dependencies panel listing Suppliers What to notice: the external dependencies are the soft and hard edges that leave your selection; what you do not add, the target must already have.

⛏ Lab (30 min) — Read Asset Maintenance as the importer will

Section titled “⛏ Lab (30 min) — Read Asset Maintenance as the importer will”

Goal. From the export alone, answer six questions the importer will answer, and write down each prediction before you check it.

Before you start. asset-maintenance.zip from the demo, unzipped into a folder am/ (unzip -q asset-maintenance.zip -d am).

  1. Count the resources by type: jq '.orderedResources | group_by(.type) | map({type: .[0].type, n: length})' am/index.json.

  2. Compare with resourceCount in the manifest. They are equal.

  3. Find the file of the entity Work Orders through the name map: jq -r '.nameMap | to_entries[] | select(.value | test("work_orders"))' am/index.json, then open am/resources/DataEntity/<that name>.json and confirm it has an id but no audit stamps.

  4. Count the edges, and how many are hard: jq 'length, (map(select(.hard)) | length)' am/dependencies.json.

  5. List the edges that leave the package (their target is not in the index):

    Terminal window
    jq --slurpfile idx am/index.json '
    ($idx[0].orderedResources | map(.id)) as $ids
    | map(select((.to.id as $t | $ids | index($t)) | not))
    | map({from: .from.normalizedName, to: .to.normalizedName, type: .to.type, hard, path})' am/dependencies.json

Screenshot pending The jq output listing the edges that leave the Asset Maintenance package, with their target type, hardness and path What to notice: each line is a promise the target must keep; a hard one blocks the import until it is mapped.

  1. Predict: you import this file into a space that has no Suppliers entity, and you map nothing. What happens to Spare Parts and to everything that depends on it? Write it down.
  2. Check your prediction against the edge from Spare Parts to Suppliers in step 5: if it is hard, the import will refuse to run until you map it; if you chose to skip Spare Parts, its hard dependents would be cascade skipped.
  3. Find the reactions of your M4-S2 chain: ls am/resources/DataReaction/. Open Tell the CMMS.
  4. Find the edge whose from is Tell the CMMS and whose to is Mark asset under maintenance. Read its path: that is where the watched reaction’s id sits, and what the importer will rewrite.
  5. Read Tell the CMMS’s Call API options in its file. Note whether the X-Api-Key value travels in the package.
  6. Read the reaction CMMS call failed. Predict: if you exported only Tell the CMMS without it, which edges would point outside, and which way?
  7. Open am/resources/DataView/ and pick a view. Confirm it has no executionPlan.
  8. If am/field-mapping-hints.json exists, check that schemaVersion is 1.2; otherwise 1.1.
  9. Decide the production path for three needs, with a reason each: (a) Larkspur Lab must point Tell the CMMS at the lab stub, production at the real CMMS; (b) a second plant wants Asset Maintenance with every name prefixed North; (c) a partner wants to generate five entities from their own catalogue that no environment has.
  10. Delete am/ when you finish, if step 10 found a key in it.
  11. Fill in your notes table: question, prediction, evidence.

Check.

  • The type counts match the manifest’s resourceCount.
  • You found the Work Orders file through the name map, not by guessing its name.
  • You listed the edges that leave the package, with their hardness.
  • Your prediction for a missing Suppliers names the refusal for a hard unmapped dependency and the cascade skip.
  • You recorded whether the API key travels.
  • Each of the three needs has a production path and a reason.

Pass condition. Your notes give, for each of steps 6, 7, 9, 10, 11 and 14, a prediction or decision and the line of the package that settles it.

If something goes wrong

What you seeWhat to do
Export failedOpen Show details; a resource installed from another package cannot be exported as a copy. Leave it out.
Step 5 lists nothingYou added the external dependencies in the demo; repeat the export without them.
No DataReaction folderYour chain was built in another space or deleted; export the module that holds Work Orders.
jq complains about --slurpfileUse jq 1.6 or later.
Model answer

Steps 1 to 5. The index lists every resource once, so its counts match the manifest. The name map is the only reliable way to a file, because two resources with the same slug get suffixed names. The edges leaving the package include Spare Parts → Suppliers (a reference field, hard) and any page or widget that points outside.

Steps 6 and 7. A hard dependency that is in neither the package nor the target must be mapped before the import will run. If instead you skip Spare Parts, everything that depends on it through a hard edge is cascade skipped. A soft edge to a missing target would have been set to null instead.

Steps 8 to 11. The chained reaction points at the watched reaction by id, through an edge whose path is in its event settings, so the importer rewrites it to the new id. The key travels (Redact in history keeps it out of run history only), so the package carries a secret: you treat the file as sensitive and set the value per environment with an override in M6-S3. Exported alone, Tell the CMMS would have an outgoing hard edge to the reaction it watches; CMMS call failed would not be in the package at all, because nothing it watches points to it.

Step 14. (a) Overrides: one package, one value per environment. (b) Export, transform, re-import: renaming is a content change of an existing design, and names are not ids, so no edge is affected. (c) Hand-authoring, unsupported: better to build one specimen in an environment, export it and generate from that.

✓ Practice (6 min) — Check your understanding

Section titled “✓ Practice (6 min) — Check your understanding”
PracticeChoose one answer.

A script transforms an exported package: it replaces a view’s source query id with the id of another query in the same package, but leaves dependencies.json unchanged. What happens at import?

  1. Explanation for A

    ✗ Incorrect

    Not this one: rewriting happens only at an edge’s path, and only when the value there equals the edge’s source id. See the edges.

  2. Explanation for B

    ✓ Correct

    Correct: the value at the edge’s path no longer matches the edge, so the exact-match guard skips it silently. See the edges.

  3. Explanation for C

    ✗ Incorrect

    Not this one: the validator checks the container, not whether edges and payloads agree. See three ways to produce a package.

Check your answer

The correct answer is B. Open the explanation under each option to see why.

PracticeChoose one answer.

Larkspur’s production runs a release older than 1.10; Larkspur Lab runs 1.10. An export of Quality and Compliance from the lab carries field-mapping-hints.json. What happens when you import it into production?

  1. Explanation for A

    ✗ Incorrect

    Not this one: the hints raise the schema version to one the older importer does not accept. See the archive.

  2. Explanation for B

    ✓ Correct

    Correct: the file declares 1.2, and an importer older than 1.10 accepts only 1.0 and 1.1. See the archive.

  3. Explanation for C

    ✗ Incorrect

    Not this one: an older importer would treat an unknown file as a format error; the version gate stops it first. See the archive.

Check your answer

The correct answer is B. Open the explanation under each option to see why.

PracticeChoose one answer.

You export Procurement with its children. Its Purchase Orders view points softly at a list in Supplier Management. Is that list in the package?

  1. Explanation for A

    ✗ Incorrect

    Not this one: only hard edges extend the export; soft ones are recorded but not followed. See the edges.

  2. Explanation for B

    ✓ Correct

    Correct: the export walks hard edges only, and an unresolved soft reference is set to null at its path. See the edges.

  3. Explanation for C

    ✗ Incorrect

    Not this one: failing is what a hard edge would cause; a soft one is nulled instead. See the edges.

Check your answer

The correct answer is B. Open the explanation under each option to see why.

PracticeChoose one answer.

A generator names a resource file resources/DataEntity/Work Orders.json, with a space. What happens?

  1. Explanation for A

    ✗ Incorrect

    Not this one: unsafe names under resources/ are skipped silently, not refused. See the package format.

  2. Explanation for B

    ✗ Incorrect

    Not this one: nothing is renamed; the importer resolves files through the name map. See the archive.

  3. Explanation for C

    ✓ Correct

    Correct: unsafe paths are ignored during extraction, so the failure surfaces later as a missing resource and a cascade. See the edges.

Check your answer

The correct answer is C. Open the explanation under each option to see why.

PracticeChoose one answer.

Why does the importer sort the resources itself instead of using the order in index.json?

  1. Explanation for A

    ✓ Correct

    Correct: the importer re-derives the order from the edges on every run, so a consistent edge set matters more than the written order. See the edges.

  2. Explanation for B

    ✗ Incorrect

    Not this one: the exporter writes the index in dependency order; the importer just does not trust it. See the edges.

  3. Explanation for C

    ✗ Incorrect

    Not this one: every resource type is ordered by its edges. See the edges.

Check your answer

The correct answer is A. Open the explanation under each option to see why.

↺ Recap (1 min) — Read before you ship

Section titled “↺ Recap (1 min) — Read before you ship”

You can now open a package and read it as the importer will: the manifest’s version gate, the name map, the edges that decide order, rewriting and skips, and what never travels. You can choose a production path and name its cost. Next, M6-S3: drive the import yourself, from a script, through its session states, with an override and the typed failures.