Skip to content

CLI: chtypes prune removes superseded builds of a line from a cache #494

Description

@EricAndrechek

Ask (from a downstream consumer).

  • The command: chtypes prune [--line <line>] [--keep N] [--dry-run] in every binding's CLI. It removes builds of a line that a newer verified build of the same line supersedes, keeping the newest N (default 1).
  • What it removes: the unpacked entry, its record, its blobs, and its index.json entry, consistently.
  • Why: a long-lived mounted cache grows by one build per library release per line. Today a consumer prunes with hand edits to the OCI layout (jq on index.json plus rm), which is exactly the kind of out-of-SDK layout knowledge that drifts.
  • Constraints:

🤖 Generated with Claude Code

Activity

  1. EricAndrechek commented on Oct 9, 2026

    @EricAndrechek
    MemberAuthor

    Planned after 2.0.0, as a 2.1.0 candidate. This is additive: binding-level API or CLI, no ABI change. The v2 lock freezes the ABI fingerprint, not the binding surface, so additions like this ship as 2.x minor releases, as 1.1.0 did for 1.x. It stays off the 2.0.0 critical path.

  2. added
    v2-pre-lockMust land before the v2 ABI lock (it may reveal an ABI need)
    and removed on Oct 9, 2026
  3. EricAndrechek commented on Oct 9, 2026

    @EricAndrechek
    MemberAuthor

    Correction: this moves BEFORE the v2 lock. It is no longer a 2.1.0 candidate. The rule now: every applicable item lands before the ABI locks, even one that looks ABI-neutral, because doing it can reveal an ABI need (a fetch-only call may want a C-ABI entry or argument). It is scheduled after the registry-lock fix (#491) and the production fetch channel, which touch the same code.

  4. EricAndrechek commented on Oct 10, 2026

    @EricAndrechek
    MemberAuthor

    Done in #609 (merged into v2 at 98f0ba4). Every CLI now has chtypes prune [--line L] [--keep N] [--dry-run] [--cache] [--strict]. For each line, it removes the builds that newer verified builds of that line supersede and keeps the newest N (default 1). It removes each build's unpacked entry, its record, its blobs and its index.json entry together.

    • stdout: pruned <version> <platform> <dir> per build. A dry run prints would-prune …; a build something holds prints in-use … and is kept.
    • stderr: the summary, chtypes: pruned|would prune <n> build(s) under <root>.
    • In-use safety: the cache had no in-use signal, so v2: a fetch-only registry call (#492), chtypes resolve (#493) and chtypes prune (#494), in all four bindings #609 adds one, the same in all four bindings (fetch guide §1, "In use"). A registry takes flock(LOCK_SH) on an entry's verified.json for every build it opens or fetches, and keeps it until the process exits. Prune takes flock(LOCK_EX|LOCK_NB) and keeps any build it can't lock. Builds fetched with chtypes fetch alone are not held.
    • It never touches another fingerprint's or another channel's records.

    The shared cases prune-{keep-newest, keep-two, line, dry-run, in-use, system-dirs-never, foreign-fingerprint-untouched, v1-channel-sees-all} are in both corpora and pass in all four bindings. Go also has a cross-process test. Follow-up: #610, one retry bound for the index.json rewrite. It ships in the next 2.0.0-dev release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestv2-pre-lockMust land before the v2 ABI lock (it may reveal an ABI need)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions