Skip to content

fix(memory): make make dist produce a buildable source tarball again - #3231

Merged
kongche-jbw merged 1 commit into
mainfrom
fix/memory-dist-source-tarball
Sep 12, 2026
Merged

kongche-jbw merged 1 commit into
mainfrom
fix/memory-dist-source-tarball

Conversation

@Forrest-ly

Copy link
Copy Markdown
Collaborator

What is broken

make -C src/agent-memory dist — the target the Makefile documents as "Create source + vendor tarballs for RPM build", and the prerequisite of make rpm / make srpm — fails on main:

$ make dist                      # 8ba7a0f0
cp: cannot stat 'docs': No such file or directory
make: *** [Makefile:274: dist] Error 1

a46aea8d (docs(docs): move user manuals to docs/user-guide) moved src/agent-memory/docs/{en,zh}/…user_manual.md into the repository-level docs/user-guide tree, which left src/agent-memory/docs/ empty and therefore gone. The cp -R list in dist still names docs, so the target aborts before writing either tarball. It has been broken since 2026‑07‑21.

Fixing only that exposes a second, older omission: the copy list never included examples/, while Cargo.toml declares an explicit target path —

[[example]]
name = "mcp-harness"
path = "examples/mcp_harness.rs"

Cargo refuses to resolve a declared target whose file is missing, so an archive built from a merely de-docs'd copy list still fails any invocation that selects examples:

$ cargo build --offline --examples      # unpacked archive without examples/
error: can't find example `mcp-harness` at path `/…/agent-memory-0.2.7/examples/mcp_harness.rs`
error: could not compile due to 1 previous target resolution error

%build runs a plain cargo build --release --locked --offline, which does not select examples, so rpmbuild could never report this. cargo test does build them, and the archive ships tests/ plus a Makefile whose test target runs cargo test --locked — i.e. it is meant to be test-capable.

Blast radius: the two CI release paths are unaffected (.github/actions/package-source copies the whole component tree; scripts/rpm-build.sh tars it minus build artefacts). This is the contributor/local release path.

What changed

src/agent-memory/Makefile (dist only) and one stale comment in src/agent-memory/Cargo.toml:

  • Drop the removed docs/ from the copy list. The spec packages CHANGELOG.md only (%doc %{_docdir}/%{name}/CHANGELOG.md), and the manuals now live in docs/user-guide.
  • Add examples/ so every target Cargo.toml declares is present in the archive.
  • Guard the staged tree before tarring: assert each path agent-memory.spec.in's %build/%install reads (src/main.rs, src/lib.rs, examples/mcp_harness.rs, both configs, the two systemd units, adapters/agent-memory/manifest.json, the four openclaw bundle files, .anolisa/component.toml, CHANGELOG.md, LICENSE) and fail naming the missing one. Tradeoff: the list duplicates what the spec reads and can itself go stale — but it fails loudly at make dist instead of silently inside rpmbuild, which is exactly the failure mode that rotted this target.
  • Cargo.toml's "Linux only" note pointed at docs/design.md, which has never existed in this component (git log --all --diff-filter=A -- 'src/agent-memory/docs/*' shows only the two user manuals). It now points at docs/BUILDING.md and the remote-build / remote-test targets, which is where the Linux-host workflow is actually documented.

No workflow files are touched.

Verification

Local, with only the crate-download step stubbed (cargo vendor writes a placeholder tree; every other line is the real recipe — this machine's registry fetch was ~1 crate/20 s):

Check Result
make dist before this change exit 2 — cp: cannot stat 'docs': No such file or directory
make dist after exit 0 — dist/agent-memory-0.2.7.tar.gz (367 KiB) + dist/agent-memory-0.2.7-vendor.tar.gz
Unpacked archive contents top level agent-memory-0.2.7/ (matches %setup -n); all 17 spec-required paths present incl. examples/mcp_harness.rs and .cargo/config.toml; no docs/
New guard, negative case (examples/mcp_harness.rs removed) exit 2 — ERROR: examples/mcp_harness.rs is missing from dist/agent-memory-0.2.7 but agent-memory.spec.in or Cargo.toml requires it, no tarball written
cargo build --offline --examples on a staged tree without examples/ error: can't find example 'mcp-harness' (reproduces the second defect)
make -n dist expands cleanly (recipe syntax)
make help renders, dist description unchanged
make test-openclaw-install 11/11 PASS
python3 scripts/check-component-versions.py "Component version metadata is synchronized."
git status after the runs only the two intended files modified (artefacts are gitignored)

Not run: a full rpmbuild (needs mock + systemd-devel), and a real cargo vendor (registry throughput here). Neither is touched by this change — the vendor tarball recipe and the %setup/%build inputs are unchanged apart from the added examples/.

`make dist` has failed outright since a46aea8 moved the component
manuals into the repository-level docs/user-guide tree: the copy list
still named `src/agent-memory/docs`, which no longer exists, so `cp -R`
exited non-zero and the target aborted before writing either tarball.

    $ make dist                      # at 8ba7a0f, before this change
    cp: cannot stat 'docs': No such file or directory
    make: *** [Makefile:274: dist] Error 1

That failure hid a second omission: the copy list never included
`examples/`, although Cargo.toml declares `[[example]] mcp-harness` with
an explicit path. Cargo refuses to resolve a declared target whose file
is missing, so an archive built from a merely de-docced copy list still
fails every invocation that selects examples:

    $ cargo build --offline --examples    # unpacked archive, no examples/
    error: can't find example `mcp-harness` at path `.../examples/mcp_harness.rs`

`%build` runs a plain `cargo build --release`, which does not select
examples, so rpmbuild could not report it. `cargo test` does build them,
and the archive ships `tests/` plus a Makefile whose `test` target runs
`cargo test --locked`, so it is meant to be test-capable.

Neither release path in CI was affected — `.github/actions/package-source`
copies the whole component tree and `scripts/rpm-build.sh` tars it minus
build artefacts. `make dist` is the contributor-facing path (`make rpm`
and `make srpm` depend on it) and is what the Makefile documents as
"Create source + vendor tarballs for RPM build".

- Drop the removed `docs/` from the copy list; the spec packages
  CHANGELOG.md only and the manuals now live in docs/user-guide.
- Add `examples/` so every target Cargo.toml declares is present.
- Guard the staged tree before tarring and name the missing path, rather
  than letting rpmbuild or a contributor find out later. The list is
  exactly what agent-memory.spec.in's %build/%install reads plus the
  declared cargo target paths; a copy list that rots silently is what
  broke this target in the first place.
- Cargo.toml's "Linux only" note pointed at `docs/design.md`, which never
  existed in this component; point at the repo-level docs/BUILDING.md and
  the remote-* targets instead.

Verified locally (crate downloads stubbed, the rest is the real recipe):
before → exit 2 with `cp: cannot stat 'docs'`; after → exit 0 producing
dist/agent-memory-0.2.7.tar.gz (367 KiB) + the vendor tarball, and the
unpacked archive carries every spec-required path including
examples/mcp_harness.rs. With that file removed the new guard fails the
target: `ERROR: examples/mcp_harness.rs is missing from
dist/agent-memory-0.2.7 ...`. `make -n dist` expands cleanly, `make help`
renders, `make test-openclaw-install` passes, and
scripts/check-component-versions.py reports the metadata synchronized.

Co-authored-by: multica-agent <github@multica.ai>
@github-actions github-actions Bot added the component:memory src/memory label Sep 11, 2026

@ikunkun-sys ikunkun-sys left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 AI review by codex-runner · Agent: Reviewer · 判定:APPROVE

审查提交:bd3ec576。未发现阻塞合并的问题。

  1. 变更概述:修复 agent-memory 本地 make dist:移除已不存在的 docs/,补入 examples/,新增归档前的文件完整性检查,并修正构建说明引用。

  2. 正确性:复制清单覆盖 Cargo 显式目标;新增 17 项检查与源码及前置生成步骤一致,缺失文件时会在归档前退出。未发现新增逻辑缺陷。

  3. 风格与一致性:沿用现有 Makefile 写法。注释略长且包含历史提交信息,可精简;不影响合并。

  4. 风险:检查清单需随 spec、Cargo 目标同步维护。本地已通过 make -n dist、展开配方的 shell 语法检查、路径核对及 git diff --check。CI 的 agent-memory 测试成功,但本轮未实际执行打包、真实 vendoring 或 RPM 构建,不能据此确认完整打包链通过。工作树保持干净。

结论:APPROVE

建议合并,无必须修改项。本次仅提供审查意见,未提交 GitHub review。

@ikunkun-sys ikunkun-sys left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

🤖 AI review by codex-runner · Agent: Reviewer · 判定:APPROVE

审查提交:bd3ec576。未发现阻塞合并的问题。

  1. 变更概述:修复 agent-memory 本地 make dist:移除已不存在的 docs/,补入 examples/,新增归档前的文件完整性检查,并修正构建说明引用。

  2. 正确性:复制清单覆盖 Cargo 显式目标;新增 17 项检查与源码及前置生成步骤一致,缺失文件时会在归档前退出。未发现新增逻辑缺陷。

  3. 风格与一致性:沿用现有 Makefile 写法。注释略长且包含历史提交信息,可精简;不影响合并。

  4. 风险:检查清单需随 spec、Cargo 目标同步维护。本地已通过 make -n dist、展开配方的 shell 语法检查、路径核对及 git diff --check。CI 的 agent-memory 测试成功,但本轮未实际执行打包、真实 vendoring 或 RPM 构建,不能据此确认完整打包链通过。工作树保持干净。

结论:APPROVE

建议合并,无必须修改项。本次仅提供审查意见,未提交 GitHub review。

@kongche-jbw
kongche-jbw merged commit 6120268 into main Sep 12, 2026
25 checks passed
@kongche-jbw
kongche-jbw deleted the fix/memory-dist-source-tarball branch September 19, 2026 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants