Skip to content

Installed-file record, bounded YAML for inert documents, and upgrading independent packages (#857) - #901

Merged
jimhoyd merged 3 commits into
mainfrom
claude/package-trust-and-upgrade
Sep 29, 2026
Merged

jimhoyd merged 3 commits into
mainfrom
claude/package-trust-and-upgrade

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Implements #857 items 2, 4 and 6 as the owner decided them.

Item 2: installed-file record

  • addon-files.lock.json: a new file at the site root, next to package-lock.json, meant to be committed and reviewed with it. It records each add-on's sha256 per file, plus its spec, version, integrity and resolved URL. Linked directories are recorded as linked. It sits outside app/, so projectSha256 is unchanged.
  • Written by: add, remove and urlcode upgrade, and included in every rollback.
  • Checked offline by: list --strict, artifacts inspect (refused when modified), MCP artifact descriptions, and the new extensions|artifacts verify [name]. Statuses: match, modified (bounded lists of paths), stale, unrecorded, linked, missing.
  • verify --online: explicit and labelled as a network operation. It downloads the lock's resolved tarball with bounded size and time, checks the lock sha512, then compares installed files and the record against it using core's own tar reader.
  • Limits: a package installed by plain npm shows as unrecorded until it is added again. The record catches edits made after install, not a package that was malicious when installed.

Item 4: bounded YAML for third-party inert documents

  • New module: inert-yaml.ts, used by install-time inertness checks and by inspection. Project YAML still refuses anchors.
  • Allowed: anchors, aliases and << merge keys.
  • Refused: tags and directives, more than 1024 aliases, recursive aliases, duplicate keys and __proto__.
  • Expansion limit: the expanded size is measured before anything is built, and refused past min(10× input, 16 MiB) or 256 levels. Errors never echo document content.

Item 6: upgrading independent packages

  • Upgrade by re-adding: running extensions add <spec> / artifacts add <spec> again upgrades an installed independent package in place, with every gate: descriptor, integrity, ignored scripts, inertness, and the extra-lock-entry check.
    • The name can't change.
    • An extension's new descriptor must still accept the project's declaration and route policies.
    • Any refusal rolls back fully: package.json, both locks and node_modules.
    • Re-adding the same version is a no-op.
  • outdated: a new extensions|artifacts outdated is informational. It runs npm view on the recorded spec and says so when offline.
  • urlcode upgrade still never moves independent packages.

Evidence (macOS, Node 26): full npm run verify after merging main

  • It includes test:addons, test:proof, test:proof:authjs and test:ecosystem. npm run test:package also passes.
  • New test/addon-files.test.ts (7 tests):
    • a hand edit, added file and removed file caught offline;
    • --online against a local http server: match, drift, a tampered tarball, and the server down;
    • upgrades with rollback on refusal;
    • outdated.
  • New test/inert-yaml.test.ts: a real-world OpenAPI document with anchors is accepted; billion-laughs, tags, recursive aliases, the alias cap and nesting after expansion are refused.
  • Core budget raised to 927/3664 KiB (measured 945,207 packed and 3,747,895 unpacked after merging main).

Limits: verify --online doesn't support private registries that need credentials.

🤖 Generated with Claude Code

jimhoyd and others added 3 commits September 29, 2026 03:41
…ackage upgrades (#857)

Item 2: extensions add / artifacts add write addon-files.lock.json at the
site root (beside package-lock.json, committed with it, outside node_modules
and app/): per package its add-on name, kind, recorded spec, lock version,
integrity and resolved URL, and the sha256 of every installed file (linked
directories recorded as linked). list --strict, artifacts inspect, MCP
artifact tools and the new `extensions|artifacts verify [name]` compare the
installed files offline (bounded added/removed/changed lists; stale and
unrecorded entries are problems). `verify --online` is an explicit network
operation: it downloads the lock's resolved tarball, checks the sha512 and
compares file by file. remove, upgrade and every rollback keep the record.

Item 4: artifact YAML parses under a separate inert-document profile, used by
install-time inertness and inspection alike: anchors, aliases and merge keys
allowed; tags and directives refused; at most 1024 aliases; recursive aliases
refused; expanded size (<= 10x input, <= 16 MiB) and nesting (256) measured
before expansion in one linear pass. Project YAML still refuses anchors.

Item 6: re-running add <spec> for an installed independent package upgrades
it in place through the same gates with full rollback (an extension keeps its
declaration, which the new descriptor must still accept). New
`extensions|artifacts outdated` reports the newest registry version matching
each recorded spec via npm view. `urlcode upgrade` never moves independent
packages.

Package budget raised with measured numbers in scripts/package-audit.ts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jimhoyd
jimhoyd enabled auto-merge (squash) September 29, 2026 08:49
@jimhoyd
jimhoyd merged commit 4a09546 into main Sep 29, 2026
24 checks passed
@jimhoyd
jimhoyd deleted the claude/package-trust-and-upgrade branch September 29, 2026 08:55
jimhoyd added a commit that referenced this pull request Sep 29, 2026
…together (#903)

Main's CI failed the package audit (954811 packed > 949248) because #900 and #901
each measured the core budget on their own branch.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant