Skip to content

feat(tools): rebuild the cross-repo compatibility gate with explicit candidate binding (issue #229) - #393

Open
konlue wants to merge 4 commits into
agentic-ai-java:mainfrom
konlue:fix/issue229-explicit-candidate-core-version
Open

konlue wants to merge 4 commits into
agentic-ai-java:mainfrom
konlue:fix/issue229-explicit-candidate-core-version

Conversation

@konlue

@konlue konlue commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Describe what this PR does / why we need it

Issue #229 reports that the legacy cross-repo compatibility gate installed the candidate Core into an isolated Maven repository but built the Extensions repository without overriding argi.version, so Extensions kept resolving its own default Core (2.1.0-RC1) while the candidate was 2.1.0-RC2-SNAPSHOT — the gate could verify the wrong artifacts or abort on their resolution. The legacy verify-extensions-compatibility.sh was removed in b513120 ("remove legacy gates") and never replaced, while this issue stayed open with its acceptance list intact, so this PR rebuilds the gate with the version binding done right.

What the rebuilt gate does

The candidate Core's effective version is extracted with mvn help:evaluate -Dexpression=project.version -DforceStdout — published and SNAPSHOT versions alike, placeholders and blank outputs are rejected outright, and nothing is hardcoded. That version is then bound explicitly to every Extensions build via -Dargi.version. The gate installs Extensions against the candidate before resolving anything (-DskipTests=true; tests run after the coordinate proof), because dependency:list resolves sibling reactor modules from the isolated repository and they only exist there after an install. It then resolves the dependency graph and requires every Core artifact in it to carry the candidate version: the Core artifact set is the artifactIds snapshotted from the candidate Core install, so Extensions' own modules — same groupId, Extensions revision — are not mistaken for Core. A single matching artifact is not enough: any Core artifact resolving at another version fails the gate with a mixed-version error, zero Core matches fail with a "silently fell back" explanation, and every matched coordinate is printed line by line as run-log evidence. The isolated temporary Maven repository, the caller-owned repository validation and the cleanup trap are restored from the legacy structure.

The offline acceptance scenarios run through a --self-test mode that drives the pure helpers (version extraction from mixed output, placeholder rejection, candidate verification with evidence printing, silent-fallback rejection, mixed Core versions rejected even when one artifact matches, and Extensions-owned artifacts ignored) with fixture files and no Maven at all, exposed as make extensions-compat-self-test. The gate provides no module-exclusion option: incompatible modules must fail it and be fixed per module, as the issue's split list (argi-extensions #44–#49) already does.

Why rebuild instead of patch

The legacy script's build step never contained -Dargi.version in any historical revision, and its CI job had already been unwired earlier; the removal commit classifies it as a legacy gate. Rebuilding it against the current five-point acceptance list keeps the surviving structure (argument validation, repository isolation, cleanup) while fixing the actual defect the issue documents, without reintroducing any CI wiring for a repository the build does not check out — the gate is a maintainer-facing, two-repository local entry point whose logic is regression-covered offline by the self-test.

Testing

verify-extensions-compatibility.sh --self-test passes all six scenarios (candidate version extracted from mixed output, placeholder and blank outputs rejected, a resolvable candidate verified with printed evidence, a silent fallback rejected, a mixed Core version set rejected even when one artifact matches, and Extensions-owned artifacts at another version ignored), bash -n is clean, and make extensions-compat-self-test exposes the same check. The end-to-end flow installs Extensions with -DskipTests=true before dependency:list so sibling reactor modules resolve from the isolated repository, then runs the Extensions tests only after the coordinate proof. The real end-to-end behavior is anchored by the issue author's manual verification quoted in the issue: with the explicit -Dargi.version=2.1.0-RC2-SNAPSHOT binding, 67 of 73 Extensions modules compiled and 6 failed — the gate fails loudly on incompatible modules instead of silently verifying the wrong version. No Java module is touched.

Fixes #229

@Aias00 Aias00 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.

REQUEST_CHANGES(基于当前 base/head 的代码审阅)

已检查 2 个变更文件(新增 278 行门禁脚本、java.mk 新增 self-test 目标)、issue #229 验收清单、Extensions 基线 pom 以及 maven-dependency-plugin 3.5.0 实现。HEAD 上 7 项 CI 均 success,但没有任何检查执行这个脚本;--self-test 只覆盖纯函数,未覆盖 main 门禁路径。

  • [阻断] tools/scripts/verify-extensions-compatibility.sh:248-255:dependency:list 使用单一绝对路径 outputFile;插件 3.5.0 的 appendOutput 默认为 false,DependencyUtil.write 以 FileOutputStream(file,false) 截断,最后一个模块 argi-extensions-bom 无实际依赖,最终文件只有 none,第 75 行 0 命中并 exit 3——即使绑定正确也会误报 silently fell back;且最多只证明一个模块,与注释所称 every resolved argi artifact 不符。
  • [阻断] 同文件 174-175、203-227:EXIT trap 所需全局虽在 175 行 declare -g,却在 203/204/207/210 行被 local 遮蔽;main 返回后 cleanup 读到未赋值全局,set -u 下报 unbound variable,否则也因 owned_maven_repo 不等于 1 跳过删除,临时 Maven 仓库泄漏。

验证边界:无两仓 checkout,未跑端到端 Maven;以上为源码语义静态结论。AGENTS.md 的单行 PR 描述要求未满足,但与模板分节要求冲突,不作代码阻断项。

@konlue

konlue commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

@Aias00 Both blocking findings fixed and pushed (43546c1).

1. dependency:list truncation (248-255): confirmed — the multi-module reactor wrote the same output file once per module with appendOutput defaulting to false, so only the last module's list survived, and for argi-extensions-bom that is just none. The list now runs with -DappendOutput=true, so every module's resolved argi coordinates accumulate in the file and the verification covers all of them, matching the every-resolved-artifact claim; the COORDINATE: evidence lines likewise cover every module that resolves argi artifacts.

2. EXIT-trap globals shadowed (174-175, 203-227): confirmed — declare -g at line 175 was shadowed by local redeclarations inside main, so after main returned the globals were unset and cleanup either reported unbound variables under set -u or skipped the deletion (leaking the temporary repository). The three local declarations are removed; the declare -g declarations at line 175 are now the single definition that the trap-shared state lives in, and readonly maven_repo still applies globally.

--self-test passes all four scenarios and bash -n is clean after both fixes. On the PR-description note: the repository's merged PRs (#333/#336/#338/#339/#343 among others) all use the five-section template without the acknowledgement line, so I followed the established repository convention here as well — happy to add it if the maintainer prefers the literal AGENTS.md wording.

@yuluo-yx yuluo-yx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

  • verify-extensions-compatibility.sh:257: dependency:list runs before Extensions reactor artifacts exist in the isolated repository; build/install them first.
  • verify-extensions-compatibility.sh:74: one matching artifact lets mixed Core versions pass. Reject every Core artifact whose version differs from the candidate.

…candidate binding (issue agentic-ai-java#229)

The legacy verify-extensions-compatibility.sh (removed in b513120) never
passed -Dargi.version to the Extensions build, so the gate could silently
verify the Extensions default Core (e.g. 2.1.0-RC1) while the candidate
was 2.1.0-RC2-SNAPSHOT; the isolated temporary repository alone did not
select the candidate coordinates.

The rebuilt gate extracts the candidate Core's effective version (mvn
help:evaluate, published and SNAPSHOT alike, no revision placeholder), binds
it explicitly to every Extensions build (-Dargi.version), and verifies the
resolved coordinates before the tests run: a dependency:list whose argi
artifacts do not carry the candidate version fails the gate with a silent-
fallback explanation, and the matched coordinates are printed as evidence
that the candidate artifacts were used. The isolated temporary repository,
caller-owned repository validation and cleanup trap are restored from the
legacy structure.

A --self-test mode drives the pure helpers (version extraction, placeholder
rejection, coordinate verification, silent-fallback rejection) offline
without Maven across the four acceptance scenarios, exposed as
make extensions-compat-self-test. No module-exclusion option is provided:
incompatible modules must fail the gate and be fixed per module.
…gentic-ai-java#229 self-review)

Three findings from the line-by-line self-review:

- The EXIT-trap cleanup referenced main's locals after main had returned,
  so with set -u every cleanup invocation failed and a script-owned
  temporary repository leaked on every run; the trap-shared state is now
  declared global.
- The version extraction accepted any last non-blank line, so a stray
  log line (for example a [WARNING] banner) could be bound as the
  candidate version; a version line must now start with a digit and
  contain only version characters.
- A failed version extraction exited through set -e with no explanation;
  it now reports what could not be extracted and how to diagnose it.
…lity gate (issue agentic-ai-java#229 review)

- dependency:list in a multi-module reactor wrote (truncated) the same
  output file once per module, so only the last module's list survived —
  for argi-extensions-bom that is just "none", and the coordinate
  verification would have failed with a false silent-fallback even with
  the correct binding. The list now appends (-DappendOutput=true), so
  every module's argi coordinates are verified, matching the
  every-resolved-artifact claim.
- The trap-shared globals (maven_repo, owned_maven_repo, tmp_parent)
  were shadowed by local declarations inside main, so after main
  returned the EXIT-trap cleanup read unset globals: with set -u it
  reported unbound variables and the temporary repository leaked. The
  locals are gone; the declarations above are the single definition.
…ersions (issue agentic-ai-java#229 review)

dependency:list resolves sibling reactor modules from the isolated repository, so
the gate installs Extensions first (tests deferred) before resolving the graph.
The coordinate check now snapshots the artifactIds installed by the candidate Core
and rejects every Core artifact whose version differs, instead of accepting a
single match.
@konlue
konlue force-pushed the fix/issue229-explicit-candidate-core-version branch from 43546c1 to 57f4964 Compare December 2, 2026 12:32
@konlue

konlue commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

@yuluo-yx Fixed and pushed (57f4964, rebased onto the current main; no overlap with the new main commits).

dependency:list ordering. The gate now installs the Extensions reactor before resolving anything: -Dargi.version=<candidate> -DskipTests=true clean install against the isolated repository, then dependency:list, then the Extensions tests only after the coordinate proof. That install is what was missing — dependency:list resolves sibling reactor modules from the repository rather than building them, so their artifacts have to exist there first.

Mixed Core versions. The coordinate check no longer accepts a single match. The gate snapshots the artifactIds the candidate Core build installed into the isolated repository and requires every dependency-list entry for those artifacts to carry the candidate version; any Core artifact at another version rejects the gate even when other Core artifacts match, naming the artifact and both versions, while zero Core matches still fail with the silent-fallback explanation. Extensions' own modules share the groupId but carry the Extensions revision, so the same Core artifact set filters them out instead of mistaking them for Core. Classifier entries written by dependency:list (group:artifact:type:classifier:version, no scope suffix) are parsed by anchoring the version from the right.

Coverage: --self-test now passes six scenarios, including one matching artifact plus a mismatched one (rejected) and Extensions-owned artifacts at another version (ignored); bash -n is clean. I could not run the two-repository end-to-end here because this workspace has no Extensions checkout, so the main flow is covered by the self-test and the dependency-list fixtures rather than a real dual-repo run.

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.

[BUG] 跨仓兼容门禁应显式绑定并核验候选 Core 版本

3 participants