feat:将A_memorix导入修改为submodule的导入方式

This commit is contained in:
A-Dawn
2026-03-24 13:45:12 +08:00
parent df872187d8
commit 9d1977446b
14 changed files with 413 additions and 0 deletions

View File

@@ -36,6 +36,7 @@ jobs:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.base_branch }}
submodules: recursive
- name: Bootstrap committed target translations into Crowdin
uses: crowdin/github-action@v2

View File

@@ -25,6 +25,8 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Sync translations with Crowdin
uses: crowdin/github-action@v2
with:
@@ -57,6 +59,7 @@ jobs:
- uses: actions/checkout@v4
with:
ref: ${{ matrix.base_branch }}
submodules: recursive
- name: Sync scheduled translations with Crowdin
uses: crowdin/github-action@v2
with:

View File

@@ -25,6 +25,7 @@ jobs:
with:
ref: dev
fetch-depth: 0
submodules: recursive
# Clone required dependencies
# - name: Clone maim_message
@@ -33,6 +34,17 @@ jobs:
- name: Clone lpmm
run: git clone https://github.com/Mai-with-u/MaiMBot-LPMM.git MaiMBot-LPMM
- name: Verify A_Memorix submodule alignment
run: |
set -euo pipefail
git -C plugins/A_memorix fetch origin MaiBot_branch --depth=1
LOCAL_SHA=$(git -C plugins/A_memorix rev-parse HEAD)
REMOTE_SHA=$(git -C plugins/A_memorix rev-parse FETCH_HEAD)
if [ "${LOCAL_SHA}" != "${REMOTE_SHA}" ]; then
echo "plugins/A_memorix is stale: local=${LOCAL_SHA}, remote=${REMOTE_SHA}" >&2
exit 1
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
@@ -79,6 +91,7 @@ jobs:
with:
ref: dev
fetch-depth: 0
submodules: recursive
# Clone required dependencies
# - name: Clone maim_message
@@ -87,6 +100,17 @@ jobs:
- name: Clone lpmm
run: git clone https://github.com/Mai-with-u/MaiMBot-LPMM.git MaiMBot-LPMM
- name: Verify A_Memorix submodule alignment
run: |
set -euo pipefail
git -C plugins/A_memorix fetch origin MaiBot_branch --depth=1
LOCAL_SHA=$(git -C plugins/A_memorix rev-parse HEAD)
REMOTE_SHA=$(git -C plugins/A_memorix rev-parse FETCH_HEAD)
if [ "${LOCAL_SHA}" != "${REMOTE_SHA}" ]; then
echo "plugins/A_memorix is stale: local=${LOCAL_SHA}, remote=${REMOTE_SHA}" >&2
exit 1
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:

View File

@@ -29,6 +29,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
# Clone required dependencies
# - name: Clone maim_message
@@ -37,6 +38,17 @@ jobs:
- name: Clone lpmm
run: git clone https://github.com/Mai-with-u/MaiMBot-LPMM.git MaiMBot-LPMM
- name: Verify A_Memorix submodule alignment
run: |
set -euo pipefail
git -C plugins/A_memorix fetch origin MaiBot_branch --depth=1
LOCAL_SHA=$(git -C plugins/A_memorix rev-parse HEAD)
REMOTE_SHA=$(git -C plugins/A_memorix rev-parse FETCH_HEAD)
if [ "${LOCAL_SHA}" != "${REMOTE_SHA}" ]; then
echo "plugins/A_memorix is stale: local=${LOCAL_SHA}, remote=${REMOTE_SHA}" >&2
exit 1
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
@@ -82,6 +94,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
# Clone required dependencies
# - name: Clone maim_message
@@ -90,6 +103,17 @@ jobs:
- name: Clone lpmm
run: git clone https://github.com/Mai-with-u/MaiMBot-LPMM.git MaiMBot-LPMM
- name: Verify A_Memorix submodule alignment
run: |
set -euo pipefail
git -C plugins/A_memorix fetch origin MaiBot_branch --depth=1
LOCAL_SHA=$(git -C plugins/A_memorix rev-parse HEAD)
REMOTE_SHA=$(git -C plugins/A_memorix rev-parse FETCH_HEAD)
if [ "${LOCAL_SHA}" != "${REMOTE_SHA}" ]; then
echo "plugins/A_memorix is stale: local=${LOCAL_SHA}, remote=${REMOTE_SHA}" >&2
exit 1
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:

View File

@@ -31,6 +31,8 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- uses: actions/setup-python@v5
with:
python-version: "3.12"

View File

@@ -7,6 +7,63 @@ permissions:
issues: write
jobs:
submodule-alignment-check:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
submodules: recursive
- name: Validate A_Memorix submodule strict alignment
env:
SUBMODULE_PATH: plugins/A_memorix
SUBMODULE_URL: https://github.com/A-Dawn/A_memorix.git
SUBMODULE_BRANCH: MaiBot_branch
run: |
set -euo pipefail
if [ ! -f .gitmodules ]; then
echo "::error::.gitmodules is missing."
exit 1
fi
actual_path=$(git config -f .gitmodules --get submodule.plugins/A_memorix.path || true)
actual_url=$(git config -f .gitmodules --get submodule.plugins/A_memorix.url || true)
actual_branch=$(git config -f .gitmodules --get submodule.plugins/A_memorix.branch || true)
if [ "${actual_path}" != "${SUBMODULE_PATH}" ]; then
echo "::error::submodule path mismatch: expected ${SUBMODULE_PATH}, got ${actual_path:-<empty>}"
exit 1
fi
if [ "${actual_url}" != "${SUBMODULE_URL}" ]; then
echo "::error::submodule url mismatch: expected ${SUBMODULE_URL}, got ${actual_url:-<empty>}"
exit 1
fi
if [ "${actual_branch}" != "${SUBMODULE_BRANCH}" ]; then
echo "::error::submodule branch mismatch: expected ${SUBMODULE_BRANCH}, got ${actual_branch:-<empty>}"
exit 1
fi
if [ ! -f "${SUBMODULE_PATH}/_manifest.json" ]; then
echo "::error::${SUBMODULE_PATH}/_manifest.json is missing. Run: git submodule update --init --recursive"
exit 1
fi
git -C "${SUBMODULE_PATH}" remote set-url origin "${SUBMODULE_URL}"
git -C "${SUBMODULE_PATH}" fetch origin "${SUBMODULE_BRANCH}" --depth=1
local_sha=$(git -C "${SUBMODULE_PATH}" rev-parse HEAD)
remote_sha=$(git -C "${SUBMODULE_PATH}" rev-parse FETCH_HEAD)
if [ "${local_sha}" != "${remote_sha}" ]; then
echo "::error::submodule ${SUBMODULE_PATH} must match origin/${SUBMODULE_BRANCH} HEAD."
echo "local=${local_sha} remote=${remote_sha}"
echo "Please run: git submodule update --remote --recursive ${SUBMODULE_PATH} && git add ${SUBMODULE_PATH} && git commit"
exit 1
fi
conflict-check:
runs-on: ubuntu-24.04
outputs:
@@ -16,6 +73,7 @@ jobs:
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
submodules: recursive
- name: Check Conflicts
id: check-conflicts
env:

View File

@@ -19,6 +19,8 @@ jobs:
environment: webui
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Bun
uses: oven-sh/setup-bun@v2

View File

@@ -17,6 +17,7 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
- name: Install Ruff and Run Checks
uses: astral-sh/ruff-action@v3
with:

View File

@@ -23,6 +23,7 @@ jobs:
with:
fetch-depth: 0
ref: ${{ github.head_ref || github.ref_name }}
submodules: recursive
- name: Install Ruff and Run Checks
uses: astral-sh/ruff-action@v3
with:

4
.gitmodules vendored Normal file
View File

@@ -0,0 +1,4 @@
[submodule "plugins/A_memorix"]
path = plugins/A_memorix
url = https://github.com/A-Dawn/A_memorix.git
branch = MaiBot_branch

View File

@@ -0,0 +1,38 @@
# A_Memorix 子模块维护说明(维护者内部文档)
> 本文档用于维护者,不面向普通用户。
## 1. 基本约束
- 子模块路径固定:`plugins/A_memorix`
- 子模块仓库固定:`https://github.com/A-Dawn/A_memorix.git`
- 子模块分支固定:`MaiBot_branch`
- 强约束:主仓内 `plugins/A_memorix` 指针必须等于远端 `origin/MaiBot_branch` 最新 HEAD
## 2. 首次拉取/恢复子模块
```bash
git submodule update --init --recursive
```
若目录为空或缺少 `_manifest.json`,先执行上面的命令再排查其他问题。
## 3. 维护者更新流程
1. 先在外部仓 `MaiBot_branch` 完成目标功能合入。
2. 在主仓执行:
```bash
git submodule update --remote --recursive plugins/A_memorix
git add plugins/A_memorix .gitmodules
git commit -m "chore(submodule): bump A_memorix"
```
## 4. CI 严格校验说明
- PR Precheck 会校验:
- `.gitmodules` 的 path/url/branch 必须匹配固定值
- 子模块指针必须等于远端 `MaiBot_branch` 最新 HEAD
- Docker 构建工作流在构建前也会执行同样的 fail-fast 对齐检查
## 5. 回滚策略
- 回滚主仓提交会同时回滚子模块指针。
- 但若回滚后的指针不再是远端 `MaiBot_branch` 最新 HEADCI 会阻断。
- 处理方式:
- 先在外部仓移动/回滚 `MaiBot_branch` 到目标提交,再重跑;
- 或按团队流程申请一次性 CI 豁免。

2
plugins/A_memorix/.gitattributes vendored Normal file
View File

@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto

245
plugins/A_memorix/.gitignore vendored Normal file
View File

@@ -0,0 +1,245 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# UV
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
#uv.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
# Ruff stuff:
.ruff_cache/
# PyPI configuration file
.pypirc
# Cursor
# Cursor is an AI-powered code editor.`.cursorignore` specifies files/directories to
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
# refer to https://docs.cursor.com/context/ignore-files
.cursorignore
.cursorindexingignore
# Python
__pycache__/
*.pyc
*.pyo
*.pyd
*.egg-info/
# Data & Storage (Privacy & Runtime)
data/
logs/
# Deprecated / Cleanup (Avoid uploading junk)
deprecated/
# OS / System
.DS_Store
Thumbs.db
ehthumbs.db
# IDE settings
.idea/
.vscode/
# Temporary Verification Scripts
verify_*.py
config.toml
# Test Artifacts & Generated Files
MagicMock/
benchmark_output.txt
e2e_debug.log
e2e_error.log
full_diff.txt
# Large Test Data Files
机娘导论-openie.json
scripts/机娘导论-openie.json
# A_memorix recall/tuning generated artifacts
artifacts/
scripts/run_arc_light_recall_pipeline.py
# Compressed Data Archives
data.zip
scripts/full_feature_smoke_test.py
ACL2026_DEMO_EVAL.md
.probe_write
tests/
temp_verify_v5_data/metadata/metadata.db
sql2/t.db
sql2/t.db-journal
scripts/test.json
scripts/test1.json
scripts/test-sample.json
USAGE_ARCHITECTURE.md
scripts/test_conversion.py
scripts/debug_graph_vis.py
/.tmp_feature_e2e_real
/.tmp_sparse_tests
/.tmp_test_probe
/.tmp_test_sqlite
/.tmp_testdata
/scripts/tmp

View File

@@ -830,6 +830,14 @@ run_installation() {
echo -e "${RED}克隆MaiCore仓库失败${RESET}"
exit 1
}
echo -e "${GREEN}初始化MaiCore子模块...${RESET}"
# 使用与主仓一致的 GitHub 加速前缀,避免子模块直连 github.com 失败
git -C MaiBot config submodule.plugins/A_memorix.url "$GITHUB_REPO/A-Dawn/A_memorix.git"
git -C MaiBot submodule sync --recursive
git -C MaiBot submodule update --init --recursive || {
echo -e "${RED}初始化MaiCore子模块失败${RESET}"
exit 1
}
echo -e "${GREEN}克隆 maim_message 包仓库...${RESET}"
git clone $GITHUB_REPO/MaiM-with-u/maim_message.git || {