Skip to content

fix(flow): never reuse the active 00000 source version - #240

Merged
ThePlenkov merged 1 commit into
mainfrom
fix/flow-mutable-active-head
Oct 23, 2026
Merged

ThePlenkov merged 1 commit into
mainfrom
fix/flow-mutable-active-head

Conversation

@ThePlenkov

@ThePlenkov ThePlenkov commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

User description

Problem

An unreleased transport exposes only the pseudo-version 00000 in the ADT versions feed. Its URI is stable, but its content is the mutable active source and keeps changing while developers work on the object under the parent request.

adt-flow treated a 00000 selection like an immutable version:

  • the exact-head fast path skipped all SAP calls when the indexed head matched the requested descriptors;
  • the indexed-components path reused the indexed source when the descriptor selection matched.

So a later checkout of the same transport (for example, after another task was released) returned the stale source captured at the first checkout. Downstream consumers then saw an empty diff even though the active code had changed.

Fix

  • isMutableVersion() marks 00000 as the active, mutable version.
  • descriptorSelectionMatches() never matches a mutable selection, so indexed reuse is skipped and the source plus metadata are re-read.
  • exactHeadFastPath() gives up when any object selection carries 00000.
  • The re-read content still goes through the normal content-hash comparison, so an unchanged active source yields no changed paths.

Tests

  • re-reads an indexed active 00000 head instead of reusing it
  • does not repeat an active 00000 head through the exact-head fast path

Both failed before the fix (indexed-components / exact-head). packages/adt-flow tests pass after it: 52/52. Prettier is clean.

Note: tsc on packages/adt-flow shows pre-existing @abapify/adk type mismatches (inventory, repositoryObject) from a stale local build. These are unrelated to this change.

🤖 Generated with Claude Code

Summary by Sourcery

Ensure active 00000 source versions are always refreshed instead of being treated as immutable indexed versions.

Bug Fixes:

  • Prevent reuse of the mutable active 00000 source version so subsequent checkouts observe current source changes.

Tests:

  • Add coverage for re-reading active 00000 sources through indexed and exact-head checkout paths.

Summary by cubic

Fixes stale checkouts of unreleased transports by never reusing the active 00000 source version. Previously, adt-flow treated 00000 as an immutable version, so the indexed-components and exact-head fast paths served the source captured at the first checkout, producing empty diffs when the active code had changed. Now 00000 selections skip indexed reuse and re-read source and metadata from SAP; the re-read still goes through the normal content-hash comparison, so unchanged sources yield no changed paths.

Written for commit 05114f4. Summary will update on new commits.

View guided diff Turn on auto-fix


CodeAnt-AI Description

Refresh active source versions on every checkout

What Changed

  • Checkouts of active 00000 versions now fetch the latest source and metadata instead of reusing an earlier snapshot.
  • Changed source files are updated, while unchanged source produces no reported changes.

Impact

✅ Current active source on every checkout
✅ Changes between tasks appear in checkout
✅ No false empty diffs for updated source

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

SAP exposes the active, still-changing source of an object in an unreleased
transport as the pseudo-version 00000 with a stable URI. Matching that
locator against an indexed descriptor made checkout reuse stale source and
metadata through the indexed-components and exact-head fast paths, so a
later task of the same parent request produced an empty delta.

Selections with versionId 00000 no longer match indexed descriptors, and
the exact-head fast path is skipped for objects that carry one, so source
and metadata are re-read from SAP and only content-hash changes are written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sourcery-ai

sourcery-ai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

The PR treats the 00000 ADT version as mutable rather than immutable, forcing manifest, metadata, and source re-reads instead of indexed or exact-head reuse while retaining content-hash filtering for unchanged content. Targeted tests cover both stale-source paths and confirm changed active content is checked out correctly.

Flow diagram for mutable 00000 source version handling

flowchart TD
    A[Checkout requested for object] --> B{Selection version is 00000?}
    B -->|Yes| C[Skip indexed reuse]
    B -->|No| D{Descriptor selection matches?}
    D -->|Yes| E[Reuse indexed source]
    D -->|No| C
    C --> F[Re-read source and metadata]
    F --> G[Compare content hash]
    G --> H[Return changed paths only]
    A --> I{Exact-head fast path eligible?}
    I -->|00000 present| F
    I -->|No mutable selection| J[Use exact-head result]
Loading

File-Level Changes

Change Details Files
Prevent reuse of mutable active source versions identified by 00000.
  • Introduced a shared mutable-version predicate for the active pseudo-version.
  • Disabled descriptor/indexed-source matching whenever the requested version is mutable.
  • Invalidated the exact-head fast path when any selected object uses 00000.
  • Preserved normal content-hash comparison after re-reading, so unchanged active content produces no changes.
packages/adt-flow/src/service.ts
Added regression coverage for both checkout reuse paths involving active 00000 sources.
  • Verified indexed active content is re-read after the source changes and metadata is refreshed.
  • Verified repeated exact-head checkouts do not use the fast path, remain unchanged when content is stable, and detect later source changes.
packages/adt-flow/tests/service.test.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@codeant-ai

codeant-ai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

🤖 CodeAnt AI — Review Status

Status Commit Started (UTC) Finished (UTC)
✅ Reviewed your PR 05114f4 Oct 22, 2026 · 18:23 18:26

@codeant-ai

codeant-ai Bot commented Oct 22, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@netlify

netlify Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for adt-cli canceled.

Name Link
🔨 Latest commit 05114f4
🔍 Latest deploy log https://app.netlify.com/projects/adt-cli/deploys/6ada548891d4ec9f2e487158

@coderabbitai

coderabbitai Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 52 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a01b394c-abec-45c0-bafe-001efffe2471
📥 Commits

Reviewing files that changed from the base of the PR and between d69005e and 05114f4.

📒 Files selected for processing: 2
  • packages/adt-flow/src/service.ts
  • packages/adt-flow/tests/service.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T18:25:33.657229Z 05114f4 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@baz-reviewer

baz-reviewer Bot commented Oct 22, 2026

Copy link
Copy Markdown

Review this PR on Baz

Merger

Waiting for CI and review to complete.


@deepsource-io

deepsource-io Bot commented Oct 22, 2026

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in d69005e...05114f4 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
Secrets Oct 22, 2026 6:23p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

@codeant-ai codeant-ai Bot added the size:M This PR changes 30-99 lines, ignoring generated files label Oct 22, 2026

@amazon-q-developer amazon-q-developer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The fix is correct and well-targeted. The three-part guard (isMutableVersion helper, early-return in descriptorSelectionMatches, and the exactHeadFastPath selection check) consistently prevents stale 00000 active-source reuse across all code paths. The two new integration tests cover both previously broken paths (indexed-components and exact-head), and the rest of the suite (52 tests) continues to pass.

No blocking defects identified. The change is safe to merge.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

@nx-cloud

nx-cloud Bot commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 05114f4

Command Status Duration Result
nx affected -t lint test build e2e-ci --verbose... ✅ Succeeded 15s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-10-22 18:24:00 UTC

@sonarqubecloud

Copy link
Copy Markdown

@gitar-bot

gitar-bot Bot commented Oct 22, 2026

Copy link
Copy Markdown

Important

You are using the Gitar free plan. Upgrade to unlock code review, CI analysis, auto-apply, custom automations, and more.

Gitar

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 5 complexity · 4 duplication

Metric Results
Complexity 5
Duplication 4

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@sourcery-ai sourcery-ai 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.

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="packages/adt-flow/src/service.ts" line_range="247-249" />
<code_context>

+const ACTIVE_VERSION_ID = '00000';
+
+function isMutableVersion(versionId: string): boolean {
+  return versionId === ACTIVE_VERSION_ID;
+}
+
 function descriptorSelectionMatches(
</code_context>
<issue_to_address>
**Older refresh overwrites newer source**

When two checkouts of the same workspace overlap, and the checkout that read the older active source applies last, concurrent checkouts of the same workspace can read different contents from the mutable `00000` source; the older checkout can reach `applyRepositoryPlan` after the newer one and overwrite its source and descriptor, leaving the workspace stale until another checkout.

Serialize checkout/index operations per workspace, or validate the active-source snapshot before applying a plan.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 1 finding to address first, and if 00000 is not actually mutable, bypassing the cached descriptor can make checkout write an unintended SAP source version into local files. Those file changes survive a code revert, but are bounded and can be restored or corrected with another checkout.

Blocking findings: packages/adt-flow/src/service.ts:249


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread packages/adt-flow/src/service.ts
@codeant-ai

codeant-ai Bot commented Oct 22, 2026

Copy link
Copy Markdown

CodeAnt Nitpicks

1 code suggestion

1. For objects with multiple source components, this forces independent reads of mutable URIs; an edit between reads can produce a checkout combining different source revisions.

Race condition · packages/adt-flow/src/service.ts:256

@codeant-ai

codeant-ai Bot commented Oct 22, 2026

Copy link
Copy Markdown

CodeAnt PR Risk: Low Risk

  • The PR appears safe to merge; no actionable issues were identified in the review.

Assessed commit: 05114f45aff8

@cubic-dev-ai cubic-dev-ai 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.

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread packages/adt-flow/src/service.ts
Comment thread packages/adt-flow/src/service.ts
@greptile-apps

greptile-apps Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Prevents checkout from treating active version 00000 as saved, unchanging source.

  • Checkout reads active 00000 source again each time.

Reviews (1) · Last reviewed commit: "fix(flow): never reuse the active 00000 ..." · Reviewed by Greptile

@ThePlenkov
ThePlenkov merged commit c06e9b8 into main Oct 23, 2026
26 checks passed
@ThePlenkov
ThePlenkov deleted the fix/flow-mutable-active-head branch October 23, 2026 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant