Skip to content

Implement install command with committed lockfile materialization and narrow gitignore migration - #21

Merged
adelrodriguez merged 1 commit into
mainfrom
08-05-implement_install_command_with_committed_lockfile_materialization_and_gitignore_migration
Aug 6, 2026
Merged

Implement install command with committed lockfile materialization and narrow gitignore migration#21
adelrodriguez merged 1 commit into
mainfrom
08-05-implement_install_command_with_committed_lockfile_materialization_and_gitignore_migration

Conversation

@adelrodriguez

Copy link
Copy Markdown
Collaborator

Adds a packref install command that materializes all source references recorded in the committed lockfile without modifying it.

Lockfile commit model

.packref/packref-lock.json is now intended to be committed. The .gitignore rules are updated accordingly: init now writes (and migrates legacy .packref / .packref/ entries to) the narrower .packref/packages/ and .packref/.packref-lock-*.tmp patterns, preserving line endings, comments, trailing whitespace, and CRLF files. A committed lockfile (packref-lock.json) is included in the repository.

packref install behavior

  1. Requires an initialized project with a valid lockfile.
  2. Registers the canonical project path globally.
  3. Processes entries in deterministic order, skipping any reference already present on disk.
  4. Reuses a global store entry when its recorded source matches the lockfile; rejects mismatches with a new StoreSourceMismatchError.
  5. Fetches missing repository or tarball sources directly from the locked metadata.
  6. Never rewrites the lockfile.

Supporting changes

  • readStoreEntry is extracted from materializeStoreEntry so install can read stored metadata without re-materializing.
  • packageSourceEquivalence is derived from the existing schema for source comparison.
  • hasProjectReference and getProjectReferencePath are added to the project workspace layer.
  • Repository and normalize source objects omit the directory key when undefined, fixing equivalence checks against lockfile entries that lack it.
  • init logs a hint to run packref install when it finds an existing lockfile with entries.
  • The install subcommand is wired into the root CLI command.

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 69da968725

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +75 to +78
const newline = content.includes("\r\n") ? "\r\n" : "\n"
const hasFinalNewline = content.endsWith(newline)
const body = hasFinalNewline ? content.slice(0, -newline.length) : content
const lines = body.length === 0 ? [] : body.split(newline)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle mixed line endings when migrating ignore rules

When an existing .gitignore mixes CRLF and LF delimiters, selecting CRLF because it occurs anywhere and then splitting only on that delimiter leaves LF-delimited records joined together. An exact legacy .packref on an LF-only segment is therefore not recognized and remains alongside the appended narrow rules, so Git continues ignoring .packref/packref-lock.json; parse either delimiter while retaining the original delimiters for rewriting.

AGENTS.md reference: AGENTS.md:L38-L40

Useful? React with 👍 / 👎.

Comment on lines +52 to +54
const resolvedRepository = yield* resolveRepositoryRef(entry, entry.source)
const materialized = yield* fetchRepositorySnapshot(entry, resolvedRepository)
return yield* ensureMatchingSource(entry, materialized)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Validate repository metadata before populating the store

When a schema-valid committed repository entry has a noncanonical URL (such as a .git suffix) or a host inconsistent with its URL and the identity is not cached, this fetch persists the normalized source before ensureMatchingSource rejects it. The failed install thus leaves a mismatched global entry behind, every retry fails against that cached entry, and the advertised recovery wipes the entire global store; compare the normalized source with the lock metadata before fetching, or remove the newly created entry on mismatch.

AGENTS.md reference: AGENTS.md:L7-L8

Useful? React with 👍 / 👎.

@adelrodriguez
adelrodriguez force-pushed the 08-05-implement_install_command_with_committed_lockfile_materialization_and_gitignore_migration branch from 69da968 to 2392326 Compare August 6, 2026 02:33
@adelrodriguez
adelrodriguez force-pushed the 08-05-refactor_withspinner_to_accept_a_callback_and_rename_spinner_message_options branch from 26a9462 to aa66d42 Compare August 6, 2026 02:33
@adelrodriguez
adelrodriguez changed the base branch from 08-05-refactor_withspinner_to_accept_a_callback_and_rename_spinner_message_options to graphite-base/21 August 6, 2026 02:39
@adelrodriguez
adelrodriguez force-pushed the 08-05-implement_install_command_with_committed_lockfile_materialization_and_gitignore_migration branch from 2392326 to ce7b7c9 Compare August 6, 2026 02:41
@adelrodriguez
adelrodriguez changed the base branch from graphite-base/21 to main August 6, 2026 02:41
@adelrodriguez

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ce7b7c9fa4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

yield* registerProject(projectPath)

for (const entry of entries) {
if (yield* hasProjectReference(projectPath, entry)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject conflicting duplicate lockfile identities

When a schema-valid committed lockfile contains two entries with the same registry, name, and version but different source metadata, the first entry creates the shared project path and this check classifies the second as already installed without comparing its source. Installation therefore succeeds while silently ignoring one locked source, with the materialized result depending on duplicate ordering; reject duplicate identities, or at least conflicting duplicates, before processing entries.

AGENTS.md reference: AGENTS.md:L7-L9

Useful? React with 👍 / 👎.

@adelrodriguez
adelrodriguez force-pushed the 08-05-implement_install_command_with_committed_lockfile_materialization_and_gitignore_migration branch from ce7b7c9 to 17e725c Compare August 6, 2026 02:55
@adelrodriguez

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 17e725c027

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


const checkIsPackrefEntry = (entry: string) =>
entry === PACKREF_IGNORE_ENTRY || entry === `${PACKREF_IGNORE_ENTRY}/`
const checkIsPackrefEntry = (entry: string) => LEGACY_PACKREF_IGNORE_ENTRIES.has(entry.trim())

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 Badge Preserve leading whitespace in ignore patterns

When .gitignore contains a rule such as .packref/, Git treats the leading space as part of the filename pattern, but trim() classifies it as the legacy Packref rule and replaces it with the generated rules. Running packref init therefore silently removes an unrelated valid ignore rule; recognize trailing whitespace if desired, but do not strip leading whitespace during legacy migration.

AGENTS.md reference: AGENTS.md:L7-L9

Useful? React with 👍 / 👎.

@adelrodriguez
adelrodriguez merged commit 6fb49de into main Aug 6, 2026
6 checks passed
@adelrodriguez
adelrodriguez deleted the 08-05-implement_install_command_with_committed_lockfile_materialization_and_gitignore_migration branch August 6, 2026 03:05
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