Skip to content

fix(antigravity): trim all native metadata tables on fork and rollback - #943

Closed
BytePioneer-AI wants to merge 1 commit into
mainfrom
fix/agy-fork-trim
Closed

BytePioneer-AI wants to merge 1 commit into
mainfrom
fix/agy-fork-trim

Conversation

@BytePioneer-AI

Copy link
Copy Markdown
Owner

Purpose

cloneNativeConversationDb deleted rows from gen_metadata, executor_metadata, parent_references and battle_mode_infos with idx >= <step cutoff>, but those tables use their own ordinals, so a clone kept metadata referencing dropped Turns (integrity_check still passed). Found while checking whether Antigravity can fork during a running Turn. This change does not relax the active-source rejection.

Changes

  • Trim each table by the step indices inside its protobuf (field numbers taken from the installed agy's descriptors), renumbering the remaining rows.
  • Derived summary now computes step count and last-user-input from the retained prefix.
  • Applies to fork and rollback (shared clone). CAPABILITIES.md note added.

Validation (run by the delegated implementer, not re-run by me)

  • 5 regression tests failed before the fix (fork 2, rollback 2, summary 1) and pass after; lock-conflict cleanup case passes.
  • npx tsc -b packages/adapters/antigravity, git diff --check.

Not verified

  • No end-to-end run on a real session. On this machine parent_references and battle_mode_infos had no non-empty rows, so their field numbers rest on the agy protobuf descriptors and branch implementation, not on observed data.
  • The brain directory copy is unchanged and can still copy half-written files from a running source (reproduced with a fixture only).

…fix on fork and rollback

gen_metadata, executor_metadata, parent_references and battle_mode_infos are keyed by
their own ordinals, so deleting rows with idx >= the step cutoff left metadata for
dropped Turns in the clone. Trim each table by the step indices in its protobuf and
rebuild the derived summary from the retained prefix.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T12:20:08.390064Z 7a5dbd9 PR opened
🔒 Security Review ✅ Completed 2026-11-19T12:20:30.259631Z 7a5dbd9 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.

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • 功能改进
    • 派生会话和回滚操作会按保留的回合范围同步处理关联数据,并重新计算派生会话摘要;无效元数据会导致操作报错。
    • 派生摘要现在包含最后一个保留用户输入步骤的索引和时间;缺少时间时使用默认值。
  • 测试
    • 扩展了会话派生、回滚及摘要状态的验证,涵盖数据库锁定和操作失败的情况。

Fork 和回滚现在依据 protobuf 中的步骤索引裁剪辅助元数据表。派生摘要记录最后一个保留的用户输入步骤索引及其时间。测试覆盖元数据裁剪、摘要更新和数据库锁定情况。

Changes: Antigravity Fork 与回滚

Layer / File(s) Summary
辅助元数据裁剪与验证
packages/adapters/antigravity/src/fork.ts, packages/adapters/antigravity/src/native-request-timing.ts, packages/adapters/antigravity/test/fork.test.ts, packages/adapters/antigravity/test/rollback.test.ts, packages/adapters/antigravity/CAPABILITIES.md
Fork 按 protobuf 中的步骤索引裁剪辅助表,并重排保留行的 idx。测试验证 Fork 和回滚后的元数据行。能力文档补充了辅助表及派生摘要的保留规则。
派生摘要的用户输入时间
packages/adapters/antigravity/src/fork.ts, packages/adapters/antigravity/src/native-request-timing.ts, packages/adapters/antigravity/test/native-clone.test.ts
摘要注册读取最后一个用户输入步骤的索引和时间。测试验证可写数据库中的派生摘要内容,以及数据库锁定时不会留下派生文件或摘要记录。

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related PRs

  • BytePioneer-AI/codex-host#827:修改 Antigravity fork 与 rollback 原生克隆路径中的 trajectory 元数据保留;与本次辅助元数据裁剪涉及同一克隆流程。

Suggested reviewers: gy212, ump45nose

Merge Risk: Minimal · up to 7a5db

Fork and rollback now trim the auxiliary metadata tables by native step index and rebuild the derived summary from the retained prefix. Tests cover the changed behavior. One open question remains: whether parent reference step indices are in the current session's coordinates. It could not be settled from the repository and is worth confirming against the agy protobuf definitions, but it is not a demonstrated defect.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed 标题“fix(antigravity): trim all native metadata tables on fork and rollback”准确描述了主要变更:在 fork 与 rollback 时裁剪所有原生元数据表。原始摘要显示,变更涉及 gen_metadata、executor_metadata、parent_references 和 battle_mode_infos 的裁剪,并…
Description check Passed 描述说明了变更原因(clone 删除行时使用错误的序号导致元数据引用已删除的 Turn)、具体改动(按 protobuf 步骤索引裁剪并重新编号、派生摘要重算、适用于 fork 与 rollback)、验证情况以及未验证的风险。描述与变更集高度相关。
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

标题“fix(antigravity): trim all native metadata tables on fork and rollback”准确描述了主要变更:在 fork 与 rollback 时裁剪所有原生元数据表。原始摘要显示,变更涉及 gen_metadata、executor_metadata、parent_references 和 battle_mode_infos 的裁剪,并重新计算派生摘要。标题与变更集相关,且具体。

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Fix failing CI checks

  • Commit to this branch
  • Create a new PR
  • 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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 81a584a and 7a5dbd9.

Files selected for processing: 6

  • packages/adapters/antigravity/CAPABILITIES.md
  • packages/adapters/antigravity/src/fork.ts
  • packages/adapters/antigravity/src/native-request-timing.ts
  • packages/adapters/antigravity/test/fork.test.ts
  • packages/adapters/antigravity/test/native-clone.test.ts
  • packages/adapters/antigravity/test/rollback.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

Recent review details

Context from checks skipped due to timeout: 7

  • GitHub Check: Check windows-latest
  • GitHub Check: Web Host tests
  • GitHub Check: Static checks
  • GitHub Check: Check macos-26
  • GitHub Check: Check Linux ARM64
  • GitHub Check: Vitest
  • GitHub Check: Check ubuntu-22.04
Additional context used

Code guidelines: 2

AGENTS.md — auto-discovered
CLAUDE.md — auto-discovered
Path-based instructions: 2

Source excerpt: Harness-specific protocol details must remain inside the corresponding Adapter.

CodeRabbit inference engine (AGENTS.md)

Files:

  • packages/adapters/antigravity/CAPABILITIES.md
  • packages/adapters/antigravity/src/fork.ts
  • packages/adapters/antigravity/src/native-request-timing.ts
  • packages/adapters/antigravity/test/fork.test.ts
  • packages/adapters/antigravity/test/native-clone.test.ts
  • packages/adapters/antigravity/test/rollback.test.ts
Source excerpt: `codexhost` runs external Agent Harnesses as independent Threads inside Codex Desktop, preserving the official shell and native Codex path.

CodeRabbit inference engine (CLAUDE.md)

Files:

  • packages/adapters/antigravity/CAPABILITIES.md
  • packages/adapters/antigravity/src/fork.ts
  • packages/adapters/antigravity/src/native-request-timing.ts
  • packages/adapters/antigravity/test/fork.test.ts
  • packages/adapters/antigravity/test/native-clone.test.ts
  • packages/adapters/antigravity/test/rollback.test.ts
Learnings: 1

Common learnings

Learnt from: CR
Repo: BytePioneer-AI/codex-host PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-10-31T06:53:42.652Z
Learning: Source excerpt:
# Repository Guidelines

## Testing & Completion

- A change is complete only when implementation, contracts, tests, and affected documentation agree.
Learnt from: CR
Repo: BytePioneer-AI/codex-host PR: 0
File: .agents/skills/codexhost-code-review/SKILL.md:0-0
Timestamp: 2026-10-17T15:17:42.370Z
Learning: Applicability reference:
AGENTS.md: # Repository Guidelines
## Repository Skills
| Task | Skill |
| --- | --- |
| Reviewing a PR or local diff for correctness and boundaries | [codexhost-code-review](.agents/skills/codexhost-code-review/SKILL.md) |

Source excerpt:
# codexhost 代码审查

## 阻断项

4. **文档与实现一致**:改动核心逻辑或契约时,对应 `docs/` 功能文档、`docs/index.md` 链接已同步;没有把变更报告当功能文档写。
OpenGrep (1.33.1)

packages/adapters/antigravity/src/fork.ts

[ERROR] 123-123: A nonliteral argument is passed to exec/execSync. Identify the receiver: Node child_process methods execute shell commands, while regular-expression and database methods have different contracts. For shell execution, prefer execFile or spawn with an argument array.

(coderabbit.command-injection.exec-js)

Additional comments: 1

packages/adapters/antigravity/src/fork.ts: 1

113-113: Data Integrity & Integration

The comment's premise cannot be decided from this checkout. It depends on the coordinate system of CortexTrajectoryReference.step_index in the installed agy 1.5.9 protobuf or its native Branch consumer. Neither artifact is available. The repository evidence conflicts: the fork.ts comment and CAPABILITIES.md describe current-session step indices, while the fixture's ancestor- label suggests ancestor coordinates. Until the native definition is inspected, the deletion of row [2] is neither confirmed nor refuted. The required action is to inspect the agy protobuf definition for CortexTrajectoryReference.step_index and the native Branch implementation that reads parent_references.

@BytePioneer-AI

Copy link
Copy Markdown
Owner Author

Superseded by #944, which includes this metadata-trimming fix.

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