Compare commits
276 Commits
codex/dash
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
| 90336acc34 | |||
|
|
91be80191e | ||
|
|
3034a5a3cb | ||
|
|
b7f4924110 | ||
| ce0fc9d5ab | |||
| d53e0e116e | |||
|
|
f608812751 | ||
|
|
19f28e5957 | ||
|
|
dc7c4b9bee | ||
|
|
2ae60e0977 | ||
|
|
6fbd805e47 | ||
|
|
ac1eddccbd | ||
|
|
433a3b6a63 | ||
|
|
5699e7cf58 | ||
|
|
7a0201dbca | ||
|
|
88992d7e61 | ||
|
|
412a12cfe5 | ||
|
|
d0dfddaf1f | ||
|
|
9dfdea9e8c | ||
|
|
d5b8b5ed04 | ||
|
|
11cb09296b | ||
|
|
1dc9710746 | ||
|
|
484e5d591b | ||
|
|
f7e4cb287e | ||
|
|
230491b090 | ||
|
|
0a60d8031c | ||
|
|
86e9fac8c7 | ||
|
|
ffe186473c | ||
|
|
e4c4a20df5 | ||
|
|
84523190b6 | ||
|
|
f68b40e9cf | ||
|
|
7624987768 | ||
|
|
d4ecc071c8 | ||
|
|
480844cfcc | ||
|
|
b64d950f64 | ||
|
|
1082d0b527 | ||
|
|
aaa788d77d | ||
|
|
ad1d91a9fc | ||
|
|
ae9e33a3bc | ||
|
|
f73665cfa0 | ||
|
|
1a6e61909e | ||
|
|
c0512c8bf6 | ||
|
|
fc7786190f | ||
|
|
3e59fa19a9 | ||
|
|
50228cdb21 | ||
|
|
f3328f148b | ||
|
|
c83f332ba9 | ||
|
|
06aa3a8341 | ||
|
|
c20dbacab6 | ||
|
|
5e59ae50eb | ||
|
|
aee1c17b43 | ||
|
|
a32699f793 | ||
|
|
84c07b882c | ||
|
|
e297a7bc6c | ||
|
|
c8d34faa85 | ||
|
|
e13d4bd6b6 | ||
|
|
e38c3be922 | ||
|
|
fbaa8546c0 | ||
|
|
477b94ae73 | ||
|
|
5e4de79984 | ||
|
|
a58b526810 | ||
|
|
11f9b53383 | ||
|
|
2d78b809ab | ||
|
|
5c6023ecd3 | ||
|
|
f56c8faf59 | ||
|
|
84eb5d149c | ||
|
|
e226b1d155 | ||
|
|
8e225d1158 | ||
|
|
708b9bae3d | ||
|
|
8b33f38e59 | ||
|
|
352c405b11 | ||
|
|
bd15b19cf1 | ||
|
|
f8d95aaa00 | ||
|
|
1050f48286 | ||
|
|
9232bace60 | ||
|
|
a35e84163a | ||
|
|
8d4b672649 | ||
|
|
14a84d3015 | ||
|
|
a2f1bd0f0c | ||
|
|
5106abd8b3 | ||
|
|
b3322680d9 | ||
|
|
08bbd632e7 | ||
|
|
6b42476962 | ||
|
|
4810602703 | ||
|
|
748cff96d4 | ||
|
|
6bf0b7662d | ||
|
|
e99febdac1 | ||
|
|
d43f622ec8 | ||
|
|
7518319d62 | ||
|
|
d393ba0d50 | ||
|
|
a98127c42d | ||
|
|
e150a8a24c | ||
|
|
419ce900e5 | ||
|
|
c52a8ab89a | ||
|
|
574eed61fb | ||
|
|
58e620d1c8 | ||
|
|
d93c04d852 | ||
|
|
e36617c022 | ||
|
|
77ee8b0af1 | ||
|
|
dfb9d7bc65 | ||
|
|
4562296985 | ||
|
|
b2ac2cb3e4 | ||
|
|
85ce47e4d5 | ||
|
|
0040988fe9 | ||
|
|
7a1231c7c6 | ||
|
|
bfaa8d6a2f | ||
|
|
0fd7e36701 | ||
|
|
ca25f9848a | ||
|
|
88526258c9 | ||
|
|
8c2ae878a2 | ||
|
|
4170c74b35 | ||
|
|
e44cd95952 | ||
|
|
faa449327f | ||
|
|
f6c2974978 | ||
|
|
aaf1a66305 | ||
| 5375074ae0 | |||
|
|
327759afe3 | ||
|
|
1ae5d37e60 | ||
|
|
f4e147e355 | ||
|
|
6d8b011c67 | ||
|
|
c942a8ced0 | ||
|
|
adc63af81c | ||
|
|
e4969acced | ||
|
|
a341def261 | ||
|
|
867d406cec | ||
|
|
6eee426e3c | ||
|
|
d93fb5f0dd | ||
|
|
d6dac755b9 | ||
|
|
e2e35cf6a2 | ||
|
|
f50efa161d | ||
|
|
b1e8812a78 | ||
|
|
8a82ecf174 | ||
|
|
c8aa1ae714 | ||
|
|
a9f2473241 | ||
|
|
1cf1e24d5f | ||
|
|
b61d7f20c3 | ||
|
|
42ca855ac8 | ||
|
|
d7201ebf25 | ||
|
|
a2d187e564 | ||
|
|
06fc6d90a7 | ||
|
|
478e44202a | ||
|
|
3d202289d4 | ||
|
|
f5c0f31fae | ||
|
|
7b7da08a44 | ||
|
|
db4182217f | ||
|
|
dffba6ca45 | ||
|
|
64d7400cef | ||
|
|
3c30c0d175 | ||
|
|
e351ddce19 | ||
|
|
b9a4577e9a | ||
|
|
6943f97212 | ||
|
|
63714753a9 | ||
|
|
99af829a42 | ||
|
|
2ed497f50c | ||
|
|
856b06175b | ||
|
|
b45a346e02 | ||
|
|
c8f6c51e48 | ||
|
|
493b3420d9 | ||
|
|
73a7e5b661 | ||
|
|
2a92718109 | ||
|
|
2ad67164f3 | ||
|
|
5d1135a095 | ||
|
|
c9b941183d | ||
|
|
07fbbc061b | ||
|
|
147c269596 | ||
|
|
6d9e6f66e0 | ||
|
|
4bc28da493 | ||
|
|
f285dafa5b | ||
|
|
fbdc488e9a | ||
|
|
a889974064 | ||
|
|
6969411b50 | ||
|
|
bde3e8e42a | ||
|
|
b2cb3cbf3a | ||
|
|
f873188819 | ||
|
|
ed494d61fe | ||
|
|
b2324c19a6 | ||
|
|
331f72dcd5 | ||
|
|
005eb934a8 | ||
|
|
59891fb0a7 | ||
|
|
8b1f997cb9 | ||
|
|
33e56f5569 | ||
|
|
3fe37a920e | ||
|
|
ca58c2582e | ||
|
|
34905aaccf | ||
|
|
8cc5cfc0a8 | ||
|
|
2230a4d136 | ||
|
|
219bb75fc5 | ||
|
|
b1e2113f82 | ||
|
|
0a40cf32fa | ||
|
|
95aaabf14b | ||
|
|
a2eac93e2f | ||
|
|
e94a8d2c14 | ||
|
|
8cdd2d79eb | ||
|
|
a8c1f0cf24 | ||
|
|
8fed6d14a1 | ||
|
|
eb4a044b97 | ||
|
|
96f77cde70 | ||
|
|
8680a52409 | ||
|
|
80bdcee9b4 | ||
|
|
7c014ce79c | ||
|
|
dcf1c37d30 | ||
|
|
b2a4f16a1f | ||
|
|
f7a5e3272b | ||
|
|
54a960284c | ||
|
|
d0a63cc9dd | ||
| 8b96632ed1 | |||
| f7ca3d90dc | |||
| 6282fe4de9 | |||
|
|
83926e254e | ||
|
|
459bcd072b | ||
| bc17d50508 | |||
|
|
19e9680aa7 | ||
|
|
71cc91b9d7 | ||
|
|
850d4fb796 | ||
|
|
fe888b0d59 | ||
|
|
7d53c25615 | ||
|
|
2715670828 | ||
|
|
8a4660d13f | ||
|
|
896289595c | ||
|
|
2840d6692a | ||
|
|
32e74273ca | ||
|
|
d75aae2a96 | ||
|
|
3da27b5b2f | ||
|
|
d06a3f17d0 | ||
|
|
fd0a54dfd2 | ||
|
|
de96cfc2be | ||
|
|
b542d71119 | ||
|
|
c1fd33f4af | ||
|
|
946a319310 | ||
|
|
39c80575fd | ||
|
|
ca80637d74 | ||
|
|
d263f20f3e | ||
|
|
0184ac60ea | ||
|
|
569b1693a2 | ||
|
|
909c58ced3 | ||
|
|
b3fd08a5f6 | ||
|
|
13d104ced6 | ||
|
|
025896ae1b | ||
|
|
4bc9c9d2c0 | ||
|
|
9fa631ad1f | ||
|
|
521acce535 | ||
|
|
8dff351787 | ||
|
|
44e66a6800 | ||
|
|
a374d24c0d | ||
|
|
93925d424a | ||
|
|
50f92a77fe | ||
| 1aad402905 | |||
| e5387ae5dc | |||
|
|
63512da71f | ||
| 525eef6384 | |||
| 9c93878e18 | |||
|
|
69cdbb5ad7 | ||
|
|
badabafb3b | ||
|
|
a777c42c4e | ||
|
|
8f6b531fd3 | ||
|
|
3549ad6216 | ||
|
|
2149b86251 | ||
|
|
01eed76937 | ||
|
|
571fbc1c3f | ||
|
|
fe871ebd3a | ||
|
|
056874294c | ||
|
|
ebb36965d3 | ||
|
|
4211ed8f48 | ||
|
|
ff1cf0be2d | ||
|
|
3221ac65e4 | ||
|
|
2876a14d4a | ||
|
|
867ca69835 | ||
|
|
4d12d8cb02 | ||
|
|
e66c77261d | ||
|
|
fab5be57ec | ||
|
|
b8360eba13 | ||
|
|
1469e1d9e1 | ||
|
|
9546810895 | ||
|
|
bc00467d24 | ||
|
|
962ea6da3d | ||
|
|
65c19de0bf |
@ -7,7 +7,7 @@ name: web-ci
|
||||
# didn't boot the dev server.
|
||||
on:
|
||||
push:
|
||||
branches: ['**']
|
||||
branches: ["**"]
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
@ -24,6 +24,7 @@ jobs:
|
||||
node-version: 22
|
||||
cache: npm
|
||||
- run: npm ci
|
||||
- run: npm run test:verification
|
||||
- run: npm run lint
|
||||
- run: npm run format:check
|
||||
- run: npm run test:go:gate
|
||||
@ -33,6 +34,14 @@ jobs:
|
||||
if: ${{ !cancelled() }}
|
||||
- run: npm run test:browser:editing
|
||||
if: ${{ !cancelled() }}
|
||||
- run: npm run test:browser:review-permissions
|
||||
if: ${{ !cancelled() }}
|
||||
- run: npm run test:browser:dashboard
|
||||
if: ${{ !cancelled() }}
|
||||
- run: go test ./internal/api -run '^TestReviewPoolSearchBrowserReplica$' -count=1 -timeout=3m -v
|
||||
if: ${{ !cancelled() }}
|
||||
env:
|
||||
REVIEW_POOL_BROWSER_TEST: "1"
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: always()
|
||||
with:
|
||||
@ -40,3 +49,81 @@ jobs:
|
||||
path: local-data/test-results/
|
||||
if-no-files-found: warn
|
||||
retention-days: 14
|
||||
|
||||
pool-search-mongo:
|
||||
runs-on: ubuntu-22.04
|
||||
services:
|
||||
mongo:
|
||||
image: mongo:8
|
||||
ports:
|
||||
- 27018:27017
|
||||
options: >-
|
||||
--health-cmd "mongosh --quiet --eval 'db.adminCommand({ping:1})'"
|
||||
--health-interval 5s --health-timeout 5s --health-retries 12
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
cache: true
|
||||
- run: go test ./internal/store -run '^TestHumanPoolSearchMongo' -count=1 -timeout=3m -v
|
||||
env:
|
||||
POOL_LOCAL_MONGO_URI: mongodb://127.0.0.1:27018
|
||||
|
||||
work-availability:
|
||||
# Current source/media paths require FFmpeg >=5.1 (-fps_mode). Keep the
|
||||
# existing Ubuntu 22 checks intact and run this mandatory matrix on 24.04.
|
||||
runs-on: ubuntu-24.04
|
||||
needs: pool-search-mongo
|
||||
if: ${{ !cancelled() }}
|
||||
services:
|
||||
mongo:
|
||||
image: mongo:8
|
||||
ports:
|
||||
- 27018:27017
|
||||
options: >-
|
||||
--health-cmd "mongosh --quiet --eval 'db.adminCommand({ping:1})'"
|
||||
--health-interval 5s --health-timeout 5s --health-retries 12
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
cache: true
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: npm
|
||||
- run: npm ci
|
||||
- run: sudo apt-get update && sudo apt-get install -y ffmpeg
|
||||
- run: npx playwright install --with-deps chromium
|
||||
- run: npm run test:work-availability
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: always()
|
||||
with:
|
||||
name: work-availability-logs
|
||||
path: local-data/
|
||||
if-no-files-found: error
|
||||
retention-days: 14
|
||||
|
||||
query-serving:
|
||||
runs-on: ubuntu-24.04
|
||||
needs: pool-search-mongo
|
||||
if: ${{ !cancelled() }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
cache: true
|
||||
- run: docker compose version
|
||||
- run: python3 scripts/test_query_serving.py --start --race
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: always()
|
||||
with:
|
||||
name: query-serving-logs
|
||||
path: local-data/query-serving-local/logs/
|
||||
if-no-files-found: error
|
||||
retention-days: 14
|
||||
- run: python3 scripts/test_query_serving.py --down
|
||||
if: always()
|
||||
|
||||
37
.scratch/acceptance-action-navigation/work.md
Normal file
37
.scratch/acceptance-action-navigation/work.md
Normal file
@ -0,0 +1,37 @@
|
||||
# #18 验收动作时长与导航
|
||||
|
||||
基线:86e9fac8;授权:本地实现、回归、提交,不推送、不部署。
|
||||
|
||||
范围:FinalAcceptanceWorkspace、acceptance-workspace helper、review-workspace CSS;复用既有审查键位,不修改标注编辑、审核决定、权限或保存协议。截图确认缺口为当前切片内动作列表,非新增切片列表。小于 3 秒的非无效区间标记“短区间”,待标注仍保留其身份,不判作有效或错误。保护共享树内所有其他任务改动。
|
||||
|
||||
完成条件:左右列表/轨道/键盘定位一致,短区间不因比例压缩不可见;输入/弹层、只读、首尾、切片切换及窄屏回归。状态:本地实现与回归完成,待推送/部署授权。
|
||||
|
||||
|
||||
## 交付与验证
|
||||
|
||||
- #580/583 两张截图已下载到主仓 `local-data/diagnostics/issue18-{quality,acceptance}.png`;确认需求指切片内动作区间,不是新增切片轨道。
|
||||
- 验收普通/专注布局增加左侧动作列表,复用质检列表样式与既有 `seekAction` 控制器,逐条显示原状态、起止、三位小数秒数及原描述。小于 3 秒的非无效区间独立行显示并标记“短区间”,待标注仍为待标注。选中项自动滚动到可见位置;加载与失败不冒充零动作。
|
||||
- 范围建议:本次实现验收列表;质检、验收共用 ↑/↓ 切动作、Ctrl/⌘+←/→ 切片;标注描述阶段已有导航,切片阶段保持边界编辑,不新增冲突键位。不改变权限、决定、草稿保存和媒体坐标协议。
|
||||
- 通过:`npm run lint:web`(类型与架构检查)、62 项有关前端回归、Prettier、diff check、hooks 状态、Go 格式(提交钩子等价检查)。
|
||||
- 通过:真实 FinalAcceptanceWorkspace/CaptureAnnotationWorkbench 浏览器流程(native / movi / movi-fractional),每模式 15 次切片变化、倍速保留、0.5 秒有效动作夹在无效动作中、点击/上下键/首尾停止、帮助弹层/文字输入保护、只读导航、批注保存和刷新;无 pageerror。普通/专注、深色窄屏及加载/空/错误/舍弃状态有截图证据。
|
||||
- 通过:`node tests/browser/review-caption-recovery.mjs` 的加载、解码失败、恢复及卸载重挂。
|
||||
- 首次浏览器尝试有定位器名称错误(已改为现有 aria-label);扩展状态覆盖后 BrowserServer 收尾超时,已改用 Playwright 直接启动/关闭独占浏览器,最终完整运行 exit 0。历史失败日志保留,不当作通过。
|
||||
- 本任务验证使用 `scripts/verify-change.py` 既有 `plan_checks` 对本任务文件生成范围(`local-data/test-results/issue18/plan.json`),逐项执行并复用未变证据;不运行共享树其他任务的 Go/集群测试。未执行生产构建/发布门禁、真实客户数据写入或线上验收。
|
||||
- 日志:`local-data/test-results/issue18/`;浏览器最终日志:`local-data/test-results/acceptance-playback-rate/issue18-direct-browser-run.log`,结果 `report.json`;代表图 `native-short-action-list.png`、`normal-action-list.png`、`dark-narrow-action-list.png` 及 `{loading,empty,error}-action-list.png`。
|
||||
- 共享树已有其他任务改动;为避免 lint-staged 默认临时 stash 这些工作,显式运行 `npx lint-staged --no-stash`、lint:web、lint:go 等价检查,随后仅本次提交使用 HUSKY=0,不修改 hooks 配置。
|
||||
|
||||
|
||||
## #584–585 追加:动作时间轴滚动与鼠标平移
|
||||
|
||||
追加基线:0a60d803;与该提交同批本地验收,不单独上线。两段录屏已下载至主仓 `local-data/diagnostics/issue18-timeline-{1,2}.mp4`,分别约 20.8 / 6.63 秒;抽帧确认横向内容溢出,鼠标无法平移,靠页面缩放看到全量时文字过小。
|
||||
|
||||
实现范围:AcceptanceActionTimeline、review-workspace CSS、现有浏览器夹具/回归、专项 timeline-pan 回归及验证范围映射。时间比例、12px 动作字号、坐标、权限、备注/审核协议不变。动作多时显示独立“横向滚动”控件(不依赖 OS 自动隐藏的原生滚动条),鼠标左键拖动作条平移;5px 阈值区分点击/拖动,捕获指针并抑制拖动后的误点击。播放定位滑杆保持独立。触控板/横向滚轮保留;滚动控件键盘事件不穿透审查快捷键。选中动作自动滚入视口。
|
||||
|
||||
专注布局撤去裁切滚动条的 106px 上限;左栏/视频网格使用受约束的行高。完整页面密集场景夹具补齐线上固定高度容器,断言左栏内部滚动、横向控件和决定按钮都在视口内。左栏已承接短动作完整文字/时长,不增加额外缩放档位、不要求用户缩小页面。
|
||||
|
||||
专项命令 `node tests/browser/acceptance-timeline-pan.mjs` 在修改前稳定失败(mouse drag must pan overflowing actions),修改后普通/专注/只读三场景通过:30 动作、鼠标拖动不定位、单击仍定位、末条自动可见、横向滚轮和独立滚动控件不改变播放时间。原生滚动条在本机系统设置下即使设置样式仍不保留高度,故改为独立可见控件;红/绿日志保留在 `local-data/test-results/issue18/timeline-*.log`。
|
||||
|
||||
追加验证:类型/架构通过;42 项映射前端回归与 22 项 tooling 回归通过;格式/diff 检查通过。整页 native / movi / movi-fractional 三模式最终 exit 0(`append-workspace-final-verified.log`),各 15 次切片变化;密集 24 动作、滚动键不穿透、固定高度、批注/刷新、只读/失败流程通过。测试输出均在忽略目录,未访问客户写接口、未推送、未部署。
|
||||
|
||||
|
||||
追加最终证据:`local-data/test-results/issue18/append-pan-delivery.log`(30 动作、三布局/权限情形)、`append-workspace-final-verified.log`(完整三播放器)、`append-caption-delivery.log`(字幕恢复)。整页完整验证使用本机已有 Chromium 156(`chromium-1248`);本机旧 1217 安装缺失 Framework 无法启动,Edge 曾在业务断言后退出超时,未计作通过。最终截图:`local-data/test-results/acceptance-playback-rate/dense-focused-scrollbar.png`;专项截图:`local-data/test-results/acceptance-timeline-pan/`。新回归已映射到 acceptance-playback-and-feedback,后续 verify:task 可选择它。后续需用户授权后将两个本地提交同批推送并按正式发布流程准备,未执行任何上线操作。
|
||||
8
.scratch/acceptance-capacity-120/work.md
Normal file
8
.scratch/acceptance-capacity-120/work.md
Normal file
@ -0,0 +1,8 @@
|
||||
# Acceptance repairs and 120-worker stability
|
||||
|
||||
Goal: Implement the approved acceptance fixes, bounded reads and static delivery, then verify 90 annotators, 18 quality reviewers, 12 acceptance reviewers and one administrator.
|
||||
Agent: Codex, current implementation chat
|
||||
Base: origin/dev @ 6d9e6f66, integrating codex/production-quality-dashboard @ a8899740 to preserve the user's existing dashboard and responsiveness work.
|
||||
Scope: acceptance UI/media lifecycle, review opinion provenance and forwarding, static build/delivery, bounded diagnostics, isolated capacity/recovery verification and corresponding contracts.
|
||||
Out of scope: production writes, resource changes, public bandwidth expansion, object storage uploads, push, PR and deployment without separate authorization.
|
||||
Risk: cross-stage opinion compatibility and coordinate mapping; cached media must retain frozen source identity and authorization; infrastructure and full capacity remain unaccepted until evidenced.
|
||||
40
.scratch/acceptance-playback-rate/verification.md
Normal file
40
.scratch/acceptance-playback-rate/verification.md
Normal file
@ -0,0 +1,40 @@
|
||||
# Acceptance playback-rate verification
|
||||
|
||||
Base: `867d406c`. Synthetic local data only; no production writes.
|
||||
|
||||
## Reproduction and fix
|
||||
|
||||
The new browser regression failed against the unchanged base: after selecting 2x and advancing to slice two, the speed selector returned `1` instead of `2`. Physical acceptance slices intentionally change the media key and remount CaptureAnnotationWorkbench, whose rate was component-local state.
|
||||
|
||||
FinalAcceptanceWorkspace now owns the rate and passes it to its media and pose workbenches. Callers that do not supply a rate retain the existing local-state behavior. No persistence across reloads is introduced.
|
||||
|
||||
## Evidence
|
||||
|
||||
- `npm run verify:task -- --base 867d406c --budget-seconds 600` ran type/architecture checks, changed-component formatting, verification tooling tests, affected frontend tests, the new browser regression, rework-boundary browser, review-draft browser and review-decision browser checks successfully. Its final permissions command could not launch because the default Playwright Chromium was absent. Original report: `local-data/test-results/verify-1793876380248594000/report.json` (retains that failure; not relabeled).
|
||||
- Reran the permissions command with `BROWSER_EXECUTABLE=/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge`; passed with no errors, failures or unexpected requests.
|
||||
- Strengthened and reran `tests/browser/acceptance-playback-rate.mjs`: physical clips must mount VIDEO and source-index clips must mount MOVI-PLAYER. Both paths passed three forward/backward transitions retaining 2x/1.5x, actual left/right element rates and play/pause. Report/screenshots: `local-data/test-results/acceptance-playback-rate/`.
|
||||
- The source components did not change during these follow-ups. Unchanged editing, draft, decision and permission evidence is reused; only the strengthened synthetic fixture/browser test was rerun.
|
||||
- Visually checked the acceptance page, both cameras, current-slice caption and retained 1.5x control. No customer-facing copy or layout changed.
|
||||
|
||||
## Running the dedicated browser regression
|
||||
|
||||
Requires ffmpeg, installed browser and local Vite on 127.0.0.1:5197 (`npm run dev -- --host 127.0.0.1 --port 5197 --strictPort`). The browser test intercepts only /api requests, permits GET/HEAD only, and supplies synthetic metadata and MP4s. It never claims, saves or submits a task.
|
||||
|
||||
Run `BROWSER_PATH='/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge' node tests/browser/acceptance-playback-rate.mjs`.
|
||||
|
||||
## Limits
|
||||
|
||||
No production verification or deployment. No promise of retaining speed across page reloads. Broad release/capacity checks are not claimed by this local UI fix. The original task-gate report remains failed for its environment issue; the targeted follow-up above supplies the successful missing check.
|
||||
|
||||
## Follow-up: shortcut navigation playback (base a341def2)
|
||||
|
||||
- Built a real-browser keyboard loop (Ctrl+Arrow then immediate Space) using synthetic source-index media. Reproduced repeated failures with all bytes buffered: UI either remained in positioning or reverted to paused. Temporary probes and event traces are under `local-data/test-results/acceptance-shortcut-playback/`.
|
||||
- Compared the pinned vendor implementation and native video properties: Movi derives seeking/readiness from its asynchronous state machine and paused from play intent. These diverge from the underlying media during rapid navigation; stale pause notifications could cancel a new play. The adapter now uses the current native engine's real paused/seeking/readyState; the software path retains vendor getters. No change to logical annotation times or seek accuracy.
|
||||
- Extended the permanent browser regression to native clips, source-index clips with integer offsets, and source-index clips with fractional offsets. Each performs 15 transitions, checks both real media clocks advance after immediate keyboard play, and retains the playback rate. Passed twice with the fix (45 transitions per run). Screenshots/report: `local-data/test-results/shortcut-playback-fixed/`; task-run copy: `local-data/test-results/acceptance-playback-rate/`.
|
||||
- Ran that same strengthened regression against the pre-fix MoviVideo from a341def2: failed waiting for playback after the shortcut (`local-data/test-results/shortcut-playback-baseline/browser-red.log`). Restored the fix automatically afterward.
|
||||
- Task verification `verify-1793893323697578000/report.json`: type/architecture, format, and browser checks passed. Full frontend gate failed with one additional-to-known-baseline ID: `fanyu-comment-followup.test.mjs :: dashboard routes all workforce roles to the clean production quality panel`. Running the required gate with the pre-fix MoviVideo produces the same failure (`shortcut-playback-baseline/frontend-gate.log`); the tested dashboard sources are unchanged by this task. Known-failures was not expanded and the failed report remains failed.
|
||||
- Actual acceptance screenshot checked with both cameras and 1.5x rate; no copy/layout changes. Production/client-specific verification remains pending; this is a local reproduction of the reported symptom, not proof of every customer's failure condition.
|
||||
|
||||
- Media recovery across annotation, quality review and acceptance passed with forced software-engine reload, simulated failed loading, bounded retry, retained position, and annotation draft preservation: `REWORK_BOUNDARY_BROWSER_TEST=1 ANNOTATION_FEEDBACK_BROWSER_SCRIPT=local-data/test-results/acceptance-shortcut-playback/media-recovery.mjs go test -count=1 ./internal/api -run '^TestReworkBoundaryBrowserReplica$' -v` (35.16s). The original script failed before mounting due to a hardcoded missing `.vite/deps/react-dom_client.js`; the task-local copy changes only its Vite cache directory and React module import through a Vite-transformed module. No product/fixture assertions were removed. The original harness failure remains recorded, and no shared node_modules cache was repaired or overwritten.
|
||||
|
||||
Local only. No push, PR, deployment, production data change or source-media change. Remaining release limitation: the pre-existing dashboard frontend assertion is still outside the known-failure baseline and blocks claiming the full task gate green.
|
||||
16
.scratch/acceptance-playback-rate/work.md
Normal file
16
.scratch/acceptance-playback-rate/work.md
Normal file
@ -0,0 +1,16 @@
|
||||
# Preserve acceptance playback speed across slice changes
|
||||
|
||||
Goal: Retain the selected playback rate when acceptance switches slices or media views, including both cameras.
|
||||
Agent: Codex
|
||||
Base: origin/dev @ 867d406c (contains live 6eee426e)
|
||||
Scope: FinalAcceptanceWorkspace playback state, optional workbench rate ownership, isolated browser regression.
|
||||
Out of scope: Persistence across browser reloads, global player defaults, task/permission changes, V4 migration, production writes or deployment.
|
||||
Risk: Shared workbench must preserve its existing uncontrolled behavior for annotation and quality review; remounted acceptance media must receive the retained rate before playback.
|
||||
|
||||
## Follow-up: intermittent shortcut navigation playback
|
||||
|
||||
Follow-up base: `a341def2`. The user reports occasional inability to play after keyboard slice navigation. Reproduced locally with synthetic full-source clips and Ctrl+Arrow navigation followed immediately by Space; no production mutation.
|
||||
|
||||
Scope: normalize Movi's HTMLMediaElement-shaped paused/seeking/readyState properties from its current native engine when present; preserve the existing software-engine getters, source/seek coordinates, media bytes, annotations and permissions. Restore original property descriptors on cleanup. Extend the browser regression to repeated keyboard navigation with integer and fractional source offsets.
|
||||
|
||||
Compatibility: pinned vendored Movi 0.4.1 exposes the active native video via getHLSVideoElement(), including its direct native wrapper; the software engine returns null. Re-check that seam if the vendor is upgraded. No vendor bundle or network settings changed.
|
||||
60
.scratch/acceptance-pool-count-status/work.md
Normal file
60
.scratch/acceptance-pool-count-status/work.md
Normal file
@ -0,0 +1,60 @@
|
||||
# #20 验收任务池数量和错误提示(position 593)
|
||||
|
||||
Status: resolved
|
||||
Tracking: merged into #10 weekly search optimization; #20 is no longer tracked independently.
|
||||
|
||||
## 优先级调整(position 594,2026-11-15)
|
||||
|
||||
章鸿铭已向客户回复「先不用管这个,这周会优化」,程晓明认可。本项归入本周 #10 检索优化,停止作为独立 bug 推进,不继续单独扩大排查、优化或安排发布。
|
||||
|
||||
已有结论留档:截图两框为任务池数量未知和计数失败提示;真实接口返回 Mongo 聚合超时,属于线上已有查询链路问题,与未部署的 592 动作左栏移植无关。已有修复 d5b8b5ed 保持本地未推送,后续由 #10 统一评估其查询限界及恢复入口,不因本次调整重写或撤销提交。
|
||||
|
||||
#18/#19/592 已有改动和验证保持;其待发布安排不因 #20 升降优先级而改动,继续等待章鸿铭明确授权。此条只调整跟踪归属,不授权推送、部署或客户数据操作。
|
||||
|
||||
|
||||
授权:本地截图读取、诊断、实现、验证和提交;不推送、不部署。基线 dev / 11cb0929,统一 recent-integration;新鲜度确认包含 origin/dev 和线上版本。共享树原有 AGENTS/docs/管理员池测试及其他任务提交保留。
|
||||
|
||||
## 截图和实际问题
|
||||
|
||||
已通过 lark-im 的现有读取权限定位平台调优群 position 593,消息 om_x100b609ee360a8a4c33efa82e7ce19e。截图保存到忽略目录 local-data/diagnostics/issue20/customer-status.png;仅保留该目标消息的上下文。
|
||||
|
||||
| 红框 | 真实位置和来源 | 判定 |
|
||||
| --- | --- | --- |
|
||||
| 上框 | AnnotationOperations 的任务池页签:可领取、我的任务、我已验收;数据来自 GET /api/human-item-counts | 当前筛选 scope 没有成功取得 reviewPoolTotals 时渲染“—”;不是动作判断状态 |
|
||||
| 下框 | 同一侧栏的 reviewPoolCountError,位于逐段任务列表上方 | 计数请求失败后,经通用错误文案显示“系统暂时无法完成操作”;不是验收决定错误 |
|
||||
|
||||
箭头指向的“全部状态”是已有筛选控件,本截图没有展开菜单,不推断其选项本身有错。截图中的任务卡和验收播放器仍正常,是因为任务列表、详情、决定和计数是独立请求。
|
||||
|
||||
## 因果证据与历史
|
||||
|
||||
1. 线上只读核验 ready 的 buildCommit 为 1a6e61909efd2e7d4afcf5d42d2653d7eef28c47。使用既有验收测试账号读取与页面一致的全项目/acceptance+prepackage_acceptance/category=all 计数路由,HTTP 500,响应明确为 `(MaxTimeMSExpired) PlanExecutor error during aggregation :: caused by :: operation exceeded time limit`。证据 live-read.json。API 日志也存在重复计数 500;日志为范围采样,不能把各用户/各路由的采样比例当总体故障率。
|
||||
2. human_pool_count_scan.go 在该线上版本与任务基线的 SHA-256 完全相同(afbe3660a4bae652c434b79098d0b0e35cc070637d92a1fdb3c77e8ce237539c)。1dc97107 没有改 AnnotationOperations 或该后端文件,且从未推送/部署;其共用动作左栏在工作台内部,本截图红框位于外层任务池,数据源不同。因此本次客户问题是已有计数超时,不是 592 移植引入。
|
||||
3. 原 covered count 把 limit 放在 facet 的匹配分支内,facet 仍要消费剩余组织候选。匹配结果超过一页时,每页都重扫剩余候选,放大聚合工作量。前端失败后不产生有效数量,错误没有局部恢复入口;它会保留至另一次相关加载,不是把质检状态读进验收缓存。
|
||||
4. 先建立红反馈:2017 候选原实现扫描 3051 个索引键,超线性预算;缺少局部重试的真实页面用例也变红。后续用 Go overlay 将最终回归直接跑在任务基线后端,12017 候选原实现扫描 78221 个键而失败;当前实现同样候选扫描 12017 个键而通过。overlay 不改 checkout,不创建分支,不改写历史。日志 count-red.log / count-baseline-12k-red.log / mongo-final.log。
|
||||
|
||||
## 修复与兼容范围
|
||||
|
||||
- 后端:先限制每个已排序的索引候选页为 1000 条,再进入保留 null/缺失语义的投影/facet。facet 同时返回匹配行和本页最后已扫描 ID/扫描数;按扫描页推进,不能按匹配页推进或因某页无匹配提前结束。继续执行原 API 权限过滤、失败整条请求不返回部分总数、取消和已有最大时限;不增加超时,不增加生产索引或迁移。
|
||||
- 前端:数量加载、失败和真实零明确区分;失败显示“任务数量暂时无法读取”及局部“重试”,仍保留未知“—”,不拿当前分页行数补总数。重试只重读数量,不切换任务池、任务或编辑状态,不改审核决定权限。成功清除旧错误;离开计数工作台清除其错误/加载状态;旧筛选响应继续受 AbortController 保护。
|
||||
- 返回值完整性按本角色实际页签校验:验收/质检只有 available/mine/reviewed,管理员才要求 all。初版新增校验错误地将 all 视为所有角色必填,被真实 API 浏览器回归抓到;已修正且将新夹具改为真实三字段响应,未提交/上线该中间版本。
|
||||
- API、Mongo 记录、切片、动作/意见、验收冻结证据、最终验收供应商匿名及正式决定/记录契约不变;无客户业务数据/配置/索引写入。回退不需要数据迁移,回到旧版会失去本次查询限界和数量恢复体验。
|
||||
|
||||
## 验证和限制
|
||||
|
||||
执行 verify:plan;使用既有 scripts/verify-change.py 的 quick/task 执行器,对本任务文件选择任务池计数和审查决定范围,排除他人管理员池测试及未改变的标注准入/编辑流程。每份复用证据记录相关源文件、测试和依赖 SHA-256;未变后端/隔离 Mongo/三播放器证据在本任务内复用,前端角色校验修正后重新执行数量恢复、真实搜索、草稿、决定、权限和构建。最终任务报告 selected-checks-passed,inputsChangedDuringRun=false:
|
||||
|
||||
- local-data/test-results/verify-1794814631078534000/report.json;主日志 local-data/test-results/issue20/task-verified.log。
|
||||
- 类型/架构检查、141 项定向前端测试、22 项验证工具测试、Go 格式和 diff 检查通过;最终前端构建通过(既有 chunk 大小提示保留)。
|
||||
- 实际页面、本地纯合成 API:验收和质检计数超时、继续处理已有验收任务不受阻、真实三字段计数恢复、清除错误、筛选慢响应/快响应不串用、不完整响应保持未知;无业务写请求,pageErrors 为空。日志 ui-green.log,截图 browser/{acceptance,quality}-count-{failed,recovered}.png,人工查看验收两种状态。
|
||||
- 隔离本地 Mongo:12017 候选、末页仅3个匹配、前面整页无匹配,计数正确并保持线性扫描;2108 条含 null/缺失/继承返工等旧形状的等价回归通过,documents fetched=0。日志 mongo-final.log。数据库名称为本次唯一合成库,测试后清理,不碰共享快照中的任务认领状态。
|
||||
- 实际 API + 隔离 Mongo:管理员和验收角色各 12000 条计数与分页基线一致,包含正常/搜索/无匹配;取消、失败无部分总数、并发身份隔离、供应商授权撤销、QC项目范围和分页/搜索等价通过。相关日志在任务报告及 verify-1794814291784921000/09.log;并发身份隔离额外定向证据为 count-concurrent.log。
|
||||
- 真实任务池搜索/翻页/历史回查/过时响应保护通过(search-browser-final.log);草稿持久化、决定失败恢复及只读/权限保护通过。
|
||||
- native / movi / movi-fractional 实际验收整页各15次切片变化、只读/决定禁用、批注保存、刷新/恢复、短动作和双时间等通过。证据 players/report.json,执行日志在 verify-1794814291784921000/16.log。播放器实现本次未改。
|
||||
|
||||
完整 Go 门禁不能宣称通过:扩大检查触及的 TestPoolPerformanceMongoBacklog 调用另一条标注随机领取计数,返回0而预期12000;使用 npm run test:go:gate 对任务基线 overlay 和当前实现分别运行,均报同一确切用例失败。两次门禁还报告已有 local-data/statistics-baseline.go 等遗留脚本编译错误。没有改 known-failures.json、没有删除/重置他人文件,没有把这些失败算进成功;门禁日志 backlog-baseline.log / backlog-current.log 及同名日志目录。最初任务级报告 verify-1794814291784921000 因角色四字段校验失败也保留,最终修正后通过,不覆盖为成功。
|
||||
|
||||
扫描量、耗时和响应字节仅为本地合成规模证据,不证明生产并发或当前线上超时已消失。本次故障探测时线上为 1a6e6190;本任务未部署,不能据本地通过宣称客户故障已经恢复。需另行完成授权发布及业务验收。
|
||||
|
||||
本地提交仅包含本任务六个文件;使用 lint-staged --no-stash 和等价检查避免临时 stash 共享工作。提交后 agent_status --no-fetch 汇报分支状态。#18/#19/592 的既有提交及其他任务提交均保留,本修复追加到待推送 dev 批次。
|
||||
|
||||
收尾状态核对:git ls-remote 读取 origin/dev 为 11cb09296b398770a630c45448dfd9bf667cc0b7,已包含此前 #18/#19/592 和其他任务提交;本任务没有执行 push/fetch 改写远端操作。#20 作为单独新增本地提交保留,未推送;不把此前提交仍称为全部未推送。
|
||||
58
.scratch/acceptance-quality-alignment/work.md
Normal file
58
.scratch/acceptance-quality-alignment/work.md
Normal file
@ -0,0 +1,58 @@
|
||||
# 验收对齐质检交互(position 592)
|
||||
|
||||
Status: resolved
|
||||
|
||||
授权:2026-11-15 章鸿铭群内方向、程晓明认可;本地分析、实现、验证和提交,不推送、不部署。
|
||||
基线:484e5d59 / unified dev recent-integration;新鲜度检查确认包含远端及线上版本。三个 UI 提交 0a60d803、230491b0、f7e4cb28 均保留;484e5d59 属于其他任务,不改动、不归入本需求成果。共享树其他 AGENTS/docs/领取池 Go 改动保持原样。
|
||||
|
||||
## 只读差距清单(实现前核对)
|
||||
|
||||
| 项目 | 质检 | 验收 | 本次处理 |
|
||||
| --- | --- | --- | --- |
|
||||
| 面板结构 | CaptureAnnotationWorkbench,左动作栏、中视频/轨道、右详情/意见;专注左 150、右 310 | FinalAcceptanceWorkspace 内再次嵌套左栏+mediaOnly 播放器,普通左160/右280、专注左150/右310 | 共用动作栏、统一尺寸和区域分配;验收右栏保留自己的传入内容 |
|
||||
| 左栏内容 | actionJudgment 状态、描述、双时间,另有返工变更/意见徽标;无独立时长行 | acceptanceActionStatus 状态、描述、双时间、三位小数秒数与短区间,加载/失败/空/舍弃独立处理 | 共用同一只读动作列表;加入共同的时长/短区间,质检返工徽标不丢失,不改标注可编辑列表 |
|
||||
| 切片选择 | 视频上方 capture-slice-navigator 下拉,配合下方切片轨道 | 下方切片块为主,视频上方无切片下拉 | 共用切片下拉形态,验收继续由 chooseSlice 提交已验证元数据后切换 |
|
||||
| 双时间 | Capture 时钟减片头得到片内,原视频沿用 Capture;#19 已补列表/详情 | 播放器片内时钟 + 当前来源冻结片头,进度条是跨来源拼接时间 | 保留 #19 原视频映射,不把拼接进度当原视频;统一标签与精度 |
|
||||
| 动作轨道 | 共用标注组件中的只读轨道,无标注编辑 | 独立 AcceptanceActionTimeline,可平移、滚动、定位;#18 已解决比例过窄 | 保留 #18 原语,验收轨道/切片概览位于视频下方;不把标注编辑带入验收 |
|
||||
| 快捷键 | reviewShortcut + ReviewViewingController;复审特有 J/K、1/2 条件启用 | 同一 reviewShortcut + 映射控制器及外层事件分发 | 保留既有键表和输入/弹层/只读保护;不复制第二份键表,不带入质检复审判定 |
|
||||
| 定位与选择 | selectReviewAction/seekSlice/seekTime,Capture 坐标 | chooseSlice 异步加载、slice-seconds 审查身份,经 finalController 映射 | 只替换视觉入口,点击/下拉/键盘都继续使用各自已验证控制器;保留切换失败原状态 |
|
||||
| 状态标识 | 原标注状态 + 返工问题数、改动,当前画面原文 | 原状态 + 短区间、舍弃、只读、文件/映射就绪、导航失败 | 共同列表显示原状态;阶段专属提示保留在既有区域,不伪造“已检查”状态 |
|
||||
| 决定与记录 | 质检通过/退回标注,复审返工判定 | 验收通过/打回质检、只读、旧版确认/评分/姿态、验收记录 | 全部保留,API、保存协议、权限、误报/退回效果均不变 |
|
||||
| 匿名 | 质检按授权可见生产归属 | 最终验收依赖现有匿名追溯/内容投影 | 不将质检任务身份/供应商/人员数据接入验收,共用组件只收动作和切片显示信息 |
|
||||
|
||||
证据入口:CaptureAnnotationWorkbench 的 actionListForRender、reviewControllerCurrent、capture-camera-selection、review-qa-side-panel;FinalAcceptanceWorkspace 的 mapReviewPosition、chooseSlice、finalController、acceptance-player-with-actions、footer;src/lib/review-shortcuts.js;src/styles/review-workspace.css;ADR 0013。
|
||||
|
||||
## 布局与实施顺序
|
||||
|
||||
1. 共用 ReviewActionList:动作状态、描述、双时间、时长/短区间、加载/空/失败/舍弃及选中自动滚动。只用于质检与验收;标注编写流程保留。
|
||||
2. 共用 ReviewSliceNavigator:质检现有视频顶部下拉作为模板,验收使用同入口;验收保留跨来源/异步切换控制器和只读切片概览。
|
||||
3. 对齐左/右栏尺寸、列表密度、当前详情与意见布局;保留验收文件/姿态/记录和固定决定栏。#18 滚动与 #19 时间显示纳入新布局,不改写旧提交。
|
||||
4. 三播放器完整验收浏览器、质检/标注回归、密集动作/普通/专注/窄屏/只读/加载/失败及切换保护;定向类型、架构、前端与工具验证;本地提交。
|
||||
|
||||
保护范围:不修改后台、Mongo、生产数据、任务领取、供应商匿名/记录投影、正式决定处理和会话写锁。正式发布和客户验收另行授权。
|
||||
|
||||
|
||||
## 实现与保留差异
|
||||
|
||||
已实现:ReviewActionList 同时承接质检和验收的左栏,沿用质检已有 actionJudgment,不改写冻结动作;三种状态、描述、双时间、秒数与短区间、选中自动滚动共用实现,质检返工意见数/本轮改动和 data-rework 标记继续保留。ReviewSliceNavigator 将质检视频顶部的切片下拉形态用于两端;验收选择继续委托 chooseSlice,并保留异步加载、失败保留、快速切换和未保存批注保护。验收普通左栏对齐 170px、右栏对齐 310px,专注维持两端既有左150px/右310px;顶部工具栏允许换行,避免窄屏被切片选择挤出。左栏行高与双时间排版、深色选中态共用。
|
||||
|
||||
保留差异具有业务原因:验收仍有跨来源拼接进度和独立文件/姿态核验、验收记录、固定验收通过/打回质检按钮;质检仍有返工基线与复审判定。验收继续用可横向平移/滚动的只读动作时间轴;未把标注可编辑轨道或质检返工判定带入验收,也没有将两端媒体/坐标协议强行合并。验收供应商匿名和正式记录效果沿用现有 API/投影,未新增身份字段的展示或请求。
|
||||
|
||||
三个待推送提交均保留:0a60d803 的时长/短区间移入共用左栏,并给质检同等信息;230491b0 的鼠标平移、可见横向滚动控件和选中自动可见继续保留;f7e4cb28 的原视频时间映射与播放/列表/详情双时间保持。没有重写历史提交。
|
||||
|
||||
## 最终验证
|
||||
|
||||
基线仍为 484e5d59。新鲜度已确认包含 origin/dev 与线上版本;执行 verify:plan,quick 和 task 使用原 scripts/verify-change.py 执行器,仅筛选本需求负责文件,排除共享树他人的文档及领取池 Go 测试。三播放器最终源码上的最新成功证据在 task 中以源码/测试 SHA-256 身份复用;其他任务级项目串行实际执行,无跳过。报告 inputsChangedDuringRun=false。
|
||||
|
||||
- 最终任务报告:local-data/test-results/verify-1794811935943889000/report.json,selected-checks-passed;主日志 local-data/test-results/acceptance-alignment/task-final.log。
|
||||
- 类型/架构检查、180 项定向 Node 前端/工具测试、22 项 Python 验证工具测试、改动格式及 diff 检查通过。
|
||||
- 原生、Movi、Movi 分数偏移三播放器,实际验收整页各 15 次切片变化通过:新切片下拉、点击/键盘、短动作和双时间、倍速保留、舍弃、意见编辑/保存/刷新、只读导航、决定按钮禁用、普通/专注/深色窄屏、24 动作滚动及加载/空/失败。原供应商/标注人员哨兵字段未在验收正文或新导航中出现。证据 acceptance/report.json、acceptance.log 及 screenshots(位于 acceptance/)。
|
||||
- 真实标注/质检共享工作台原视频稳定定位、列表/详情、新共用质检左栏时长和状态及顶部切片选择通过:任务报告 06.log;截图 local-data/test-results/issue19/workbenches/{annotation,quality}.png。
|
||||
- #18 鼠标拖动不误定位、横向滚轮/滚动控件和末条自动可见:normal/focused/focused&readonly 通过。
|
||||
- 字幕加载、解码错误隐藏、恢复、卸载/重挂通过。首次任务级运行在夹具 page.goto 的 load 等待超时,未进入业务断言;将本地浏览器设为无代理并在 DOMContentLoaded 后继续使用原有字幕就绪断言,单独和最终任务级重跑通过。保留失败报告 verify-1794811536011877000,不将它冒充通过。
|
||||
- 隔离内存 HTTP 服务与真实浏览器:标注边界/舍弃/撤销重做/失败与丢响应恢复,意见草稿持久化,正式决定失败/重复提交/确认恢复,以及审查只读/输入保护全部通过,见任务报告 09–12.log。未连接客户 Mongo/公司集群/BOS。
|
||||
- 最终前端构建通过(acceptance-alignment/build.log,既有 chunk 大小提示仍在)。人工查看了质检、验收普通/专注与深色窄屏代表截图;当前业务资料、用户意见、异常和决定入口保留。
|
||||
|
||||
本次只修改前端展示/导航入口、相应测试和验证映射;服务端、权限/匿名投影、审核保存、正式验收记录、返工效果未改。未执行生产容量或生产业务验收,不代表已部署/客户已使用。
|
||||
|
||||
本地提交前使用 lint-staged --no-stash 和等价 lint 检查,避免默认钩子临时 stash 共享树他人工作。提交后运行 agent_status --no-fetch。后续必须由章鸿铭明确授权才可推送;部署仍需另行授权及正式发布流程。
|
||||
34
.scratch/acceptance-supplier-priority/work.md
Normal file
34
.scratch/acceptance-supplier-priority/work.md
Normal file
@ -0,0 +1,34 @@
|
||||
# #21 Temporary supplier acceptance priority
|
||||
|
||||
Baseline: 5699e7cf585d4823ef8e37cd484baf655cb56f23 (dev). Decision gate 1 approved option B; local implementation/checks/commit only. No push, deployment, company-cluster/BOS/customer-data writes.
|
||||
|
||||
Goal: finish an exiting supplier's existing acceptance work for settlement; supplier and accounts remain. Admin-only per-supplier policy with project scope, expiry, cancellation and version history. Keep reviewer supplier anonymity, aggregate membership/frozen sampling, permissions, decision receipts and count totals unchanged. Owned tasks precede new admission; priority groups precede normal candidates in random and continuous admission.
|
||||
|
||||
Owned files: new acceptance_priority domain/store/API files and tests; Store interface/MemoryStore field; human loop routes/review continuation; review-claim-candidates helper/human-loop service; Users admin insertion and new SupplierAcceptancePriorityPanel. Existing AGENTS/docs/admin pool test edits are unrelated, preserved and excluded from staging/check selection.
|
||||
|
||||
Status: original implementation433a3b6a deployed in ac1eddcc after explicit decision gate2 approval; production policy remains unconfigured and admin slow-read blocks acceptance. The fix_a follow-up below is local only, awaiting its own deployment decision. Source supplier resolution is request-local through SourceBatchID and source human items/task ownership; missing/conflicting evidence stays unknown, visible only as admin “归属待核对” count. No customer record backfill. New collection acceptancePriorities is created only when an administrator first saves locally/after approved deployment. No startup migration/index build.
|
||||
|
||||
Implemented: immutable versioned per-supplier configuration in acceptancePriorities; admin-only read/write routes and supplier account-management panel; request-local batch source ownership resolution through identity-only bulk queries; priority-before-normal admission in random/continuous paths; existing own-task precedence, permission checks, final store CAS and totals preserved. Unknown/conflicting source ownership is shown only in the admin unresolved count. No startup migrations or task backfill. Candidate-only metadata read mode avoids annotation hydration and serializes an explicit anonymous whitelist. Source lookup failure does not silently fall back to ordinary admission.
|
||||
|
||||
Verification:
|
||||
- Final task report: local-data/test-results/verify-1794885636928492000/report.json, selected-checks-passed, all 14 commands passed, no unmapped checks or input changes during execution. Task baseline remains 5699e7cf. Standard verification planner/runner used with the task's declared file set and acceptance-supplier-priority scope; protected unrelated changes and their checks excluded. Reproducible local wrapper/terminal log: local-data/test-results/issue21/run-scoped-verification.py and task-final.log. npm verify:plan was inspected before editing and again after mapping.
|
||||
- TypeScript lint/typecheck, changed-file formatting, Go formatting, verification tooling tests, frontend business regressions, API and MemoryStore regressions passed. Includes priority beyond 200 newer ordinary candidates, per-project scope, unknown/conflicting historical ownership and task fallback, expired/canceled policy fallback, returned acceptance rounds, admin access/version conflicts, unchanged count totals, owned-task-first continuation, grant revocation and a single winner among eight competing claim requests from two reviewers.
|
||||
- Real localhost Mongo 27018: isolated acceptance_priority_test_* databases, configuration CAS/history, ownership resolution and new-store-instance persistence passed; temporary databases cleaned. No shared snapshot customer records changed.
|
||||
- Race detector: go test -race ./internal/api ./internal/store -run '^TestAcceptancePriorityConcurrentClaimCAS$|^TestAcceptancePriorityStoreMemory$' -count=1 -timeout=2m passed (issue21/race.log).
|
||||
- Actual Users page + isolated MemoryStore API browser: admin save/project selection/reload/cancel/load error/retry and supplier-manager exclusion passed. Desktop light/dark inspected: issue21/browser/active-light.png and active-dark.png. Loading/error and mobile screenshots retained. Existing global navigation compresses the Users page at 390px; the narrow screenshot is observation, not a mobile usability acceptance claim. No global layout changes were included.
|
||||
- #18/#19 regressions passed: original-video-time browser for annotation/QC; acceptance timeline normal/focused/read-only; acceptance-playback-rate engines native/movi/movi-fractional, 15 slice changes each, retained rates and zero page errors. Player report: local-data/test-results/acceptance-playback-rate/report.json. These fixtures are local synthetic media.
|
||||
- Earlier development failures are retained in temporary diagnostic logs; corrected MemoryStore private-field cloning and browser fixture routing/auth/reload assumptions. UI startup imports an existing synthetic legacy task once, so browser count assertions compare with the live fixture API rather than assume a fixed backlog size. The separate API before/after count equality and exact source ownership/count assertions remain in place.
|
||||
|
||||
Compatibility/activation: see docs/acceptance-supplier-priority.md. Production activation and business acceptance remain gate 2/explicit deployment authorization. Production supplier/project/expiry selection is not yet made; no production policy was created. No pushes, PRs, cluster/BOS writes, or customer-data writes. Production-size latency/capacity and full release gates have not been claimed.
|
||||
|
||||
Historical initial local handoff: implementation commit 433a3b6a. Pre-commit TypeScript/architecture/Go formatting checks passed. Existing protected user edits remain outside the task commit. Remote dev has not been changed by this task. Release preparation must first synchronize the authorized release tip and use the documented release process; deployment authorization is not inferred from decision gate 1.
|
||||
|
||||
## Configuration read unblock (fix_a)
|
||||
|
||||
Decision gate 1 approved 2026-11-16: local implementation only, no push/deploy. Base ac1eddcc. Owned files: API acceptance_priority*, routes_human_loop/golden, SupplierAcceptancePriorityPanel, browser fixture, matching verification scope/docs. Preserve unrelated dirty files. Separate metadata/save/cancel acknowledgements from optional two-second statistics; null counts on incomplete, version-fenced responses and independent browser cancellation/retry. Production policy remains unconfigured; deployed does not mean priority active.
|
||||
|
||||
fix_a verification: local-data/test-results/verify-1794893320981309000/report.json selected-checks-passed; 15 commands, no deferred/unmapped coverage and no input changes during run. Protected unrelated changes excluded using standard scoped planner/executor wrapper local-data/test-results/issue21/run-fix-a-verification.py. Type/architecture, format, tooling, API/MemoryStore, real isolated Mongo policy and configuration latency, full admin browser and #18/#19 normal/focused/read-only/native/movi/movi-fractional regressions passed. Additional race run covers save while statistics pending and competing claims.
|
||||
|
||||
Latency fixture: 5600 synthetic Mongo candidates; GET2.8ms, save26.3ms, cancel6.6ms; zero candidate/source read commands. Forced waiting statistics completes as incomplete at2s; counts null, never partial zero. Stats version fencing rejects a response after concurrent config save. Actual browser covers independent loading/timeout/error/retry, saved acknowledgement, stale version rejection, supplier-manager exclusion; normal light/dark and incomplete screenshots inspected under local-data/test-results/issue21/browser/. Initial failing pre-fix tests and one initial browser failure retained in fix-a-red.log / earlier tool output; final browser and task pass.
|
||||
|
||||
Limits: all fixtures local/synthetic. Production code/data/priority policies unchanged by fix_a, no push/deploy. Statistics retain exhaustive authoritative algorithm and may legitimately remain incomplete for organization-wide scope; this patch removes its ability to block configuration or mask committed saves. Production warm latency and full release/active-priority business acceptance remain pending gate2.
|
||||
12
.scratch/admin-pool-counts-20261021/spec.md
Normal file
12
.scratch/admin-pool-counts-20261021/spec.md
Normal file
@ -0,0 +1,12 @@
|
||||
# Correct administrative annotation pool totals and paging
|
||||
Status: resolved
|
||||
|
||||
Base: 867ca698 (contains the prior local editing repairs). Local only.
|
||||
|
||||
The annotation workspace administrator badges must count all authorized human items, independent of the current list page, text search and status category. Project/workflow/run/Capture scope still applies. Lists must page human items, then join tasks by IDs; searching must include older items beyond the former first 500. Never fetch all business payloads into the browser, change customer records, widen annotator visibility or modify claim permissions.
|
||||
|
||||
Use an admin-only read endpoint, compact server-side counts and bounded cursor pages. Keep existing non-admin/review behavior and old APIs for compatibility. Test >500 items, mixed stages, orphan/cross-org batches, permissions, claim changes, old-page search, category filtering, stale page responses and pagination with stable totals. No production deployment in this task.
|
||||
|
||||
## Answer
|
||||
|
||||
Implemented admin-only totals with a 5-second bounded actor/scope cache; list pages follow human item cursors and join only page task IDs. Server-side Capture/status search sees older items; abandoned searches are cancelled and stale responses fenced. Existing role paths and APIs remain. See docs/annotation-admin-task-pool.zh-CN.md and docs/verification/admin-pool-counts-20261021.md.
|
||||
8
.scratch/agent-branch-workflow/work.md
Normal file
8
.scratch/agent-branch-workflow/work.md
Normal file
@ -0,0 +1,8 @@
|
||||
# Branch rules and status script for parallel agents
|
||||
|
||||
Goal: stop branch sprawl: one branch per task from dev, a task card per branch, one command to see every branch's state
|
||||
Agent: Claude Code (desktop session, frontend-polish thread)
|
||||
Base: origin/dev @ 1aad4029
|
||||
Scope: AGENTS.md, docs/agents/branch-workflow.md, scripts/agent_status.py, tests/agents/
|
||||
Out of scope: moving release.py's ledger to one place; deleting remote branches or worktrees
|
||||
Risk: tooling and docs only; --prune deletes local branches already contained in origin/dev
|
||||
8
.scratch/branch-freshness-check/work.md
Normal file
8
.scratch/branch-freshness-check/work.md
Normal file
@ -0,0 +1,8 @@
|
||||
# Read-only branch freshness check at session start
|
||||
|
||||
Goal: warn before work starts when the checkout is behind origin/dev or lacks the commit a live Fanyu deployment runs
|
||||
Agent: Claude Code (desktop session, 2026-10-27)
|
||||
Base: claude/reviewer-dashboard-20261027 @ 27156708 (PR #60, the live release line; user asked to stack on it so the PR lands after #60)
|
||||
Scope: scripts/local/branch-freshness.sh, tests/release/test_branch_freshness.py, one AGENTS.md line
|
||||
Out of scope: release.py, agent_status.py, any cluster write, deleting branches
|
||||
Risk: tooling only; reads git and `kubectl get deploy` with a short timeout, never writes
|
||||
12
.scratch/cheng-feedback-20261021/spec.md
Normal file
12
.scratch/cheng-feedback-20261021/spec.md
Normal file
@ -0,0 +1,12 @@
|
||||
# Repair initial slicing and rework feedback
|
||||
Status: resolved
|
||||
|
||||
Base: local rework boundary repair 4d12d8cb, based on deployed fab5be57.
|
||||
|
||||
- Initial slice quick conflicts must be visible and confirmable/cancellable by the same keys and buttons as annotation conflicts. Preserve pending, described and invalid records; no customer migration.
|
||||
- Successful C split, drag and delete must survive save/reload and support same-session undo/redo, respecting the existing one-second acceptance window and stage boundaries.
|
||||
- Live complete editor drafts update feedback immediately, preserving classification fields. Derived slice status alone must not clear opinions.
|
||||
- Discarded slices retain evidence and a right-side opinion rail without an action editor. Explicit whole-action invalidation shows its impact.
|
||||
- Review remains read-only; E remains annotation-only. No production mutation or deployment in this task.
|
||||
|
||||
Evidence: [verification](../../docs/verification/cheng-feedback-20261021.md).
|
||||
@ -1,6 +1,6 @@
|
||||
# 客户可对账看板
|
||||
|
||||
Status: ready-for-agent
|
||||
Status: resolved
|
||||
|
||||
## 已确认
|
||||
|
||||
@ -12,10 +12,10 @@ Status: ready-for-agent
|
||||
|
||||
- 提交:首次成功送检,按该日期入账;反复保存/返工重提不重复累计。明确重跑或撤销完成证据的规则需沿用正式版本链,不按 revision 大小猜测。
|
||||
- 质检通过、验收通过:各按有效正式决定实际完成日期入账,重复决定/重试不重复;同一 part 可以在不同日期分别进入各阶段。撤销/打回后的处理保留事件历史及当前状态,明细显示证据,不能直接把当前最新状态当历史结论。
|
||||
- 返工中:当前状态快照,不是期间返工次数;范围为当前筛选归属、在查询截止时刻仍需返工的 part。日期范围不能把历史已解决返工再次算成当前返工。若要历史截止日快照,必须有可靠状态事件重放;否则仅显示当前时刻并注明。
|
||||
- 返工中:当前状态快照,不是期间返工次数;范围为当前筛选归属、在查询截止时刻仍需返工的 part。日期范围不能把历史已解决返工再次算成当前返工。若要历史截止日快照,必须有可靠状态事件重放;本版使用当前时刻快照,接口返回 asOf;不添加页面规则说明。
|
||||
- 时区:显示当前账号配置的统计时区;按本地日界转 UTC 半开区间,查询与导出一致。
|
||||
- 可结算参考:本期有效验收通过整段时长,不表示已付款或新增结算凭证;本期去重与跨期不重复结算需将来另立实际结算台账,原型不冒充结算系统。
|
||||
- 归属:使用提交/被审版本冻结的作者、供应商;不能按当前任务分配人或现任角色重写历史。缺少证据的字段显示“—”,不添加伪业务状态、黄色提示或说明段落;字段缺口保留在内部核对记录中。
|
||||
- 归属:使用提交/被审版本冻结的作者、供应商;不能按当前任务分配人或现任角色重写历史。缺少可靠证据的字段显示“—”;不在产品界面显示“待核对”、覆盖率或调试说明。
|
||||
|
||||
## 个人版式
|
||||
|
||||
@ -27,12 +27,35 @@ Status: ready-for-agent
|
||||
|
||||
## Mongo 补录边界
|
||||
|
||||
先读已有证据生成缺口清单。可恢复的字段逐项列来源与冲突,须经用户确认才补录;不能恢复的留空待核对,不为凑齐看板造记录。报表计算、可选内部统计快照与客户交付 JSON 分开。
|
||||
先读已有证据生成缺口清单。可恢复的字段逐项列来源与冲突,须经用户确认才补录;不能恢复的留空,不为凑齐看板造记录。报表计算、可选内部统计快照与客户交付 JSON 分开。
|
||||
|
||||
## 页面与分页
|
||||
|
||||
- 数量直接显示数字,不附加“个 part”。缺失值显示“—”,不添加长口径解释、黄色提醒、“待核对”或演示日期。
|
||||
- 任务、供应商、人员每日表分别分页,默认 5 条,可选 5/10/20/50;展示总条数、页码和上一页/下一页。筛选变更回到第一页,汇总始终覆盖完整筛选结果。
|
||||
- 导出完整筛选任务明细,不受当前页影响;详情弹层只读,支持关闭和 Esc,返回保留位置。
|
||||
|
||||
## 本次交付状态
|
||||
|
||||
角色筛选的 role 投影缺陷已修复并完成本地 Mongo/真实 router 回归,待合入和另行发布。本地看板原型仅供版式/交互评审,使用明确标识的合成数据。真实指标接口、完整导出和生产历史覆盖率仍待实现/核实。
|
||||
2026-10-20 已按用户批准的原型完成正式实现,保存在 `codex/customer-dashboard-20261020` 分支:
|
||||
|
||||
原型源码保存在独立 `codex/dashboard-reconciliation-prototype-20261020` 分支,不进入生产代码;入口为 tests/browser/fixtures/dashboard-reconciliation-prototype.html。
|
||||
- 新增只读 `GET /api/dashboard/annotation-output`,支持阶段归属、日期/项目/供应商/人员筛选、独立分页和完整 CSV 导出。组织管理员看组织内正式纳入的项目,供应商管理员看本供应商,标注员看本人;客户端参数不能扩大服务端权限。
|
||||
- Mongo 仅投影读取已有事实;统计源使用正式生产范围配置,不添加客户数据、不回填历史、不改变交付 JSON。时长只使用明确的整段视频源时长,不使用保留切片时长或按 15 分钟估算。
|
||||
- 个人与管理员/供应商管理员接入真实 React 页面;旧的源采集生产进度/运行概览保留在管理员折叠区;质检与验收角色原有工作看板保留。
|
||||
- 已验证:真实 router 与隔离合成 Mongo 的三角色浏览器流程;权限、返工/重试去重、跨期、冻结归属、缺失时长、207 条分页与完整导出;前端/Go 既有失败基线无新增;生产前端启动与 Go 构建通过。
|
||||
- 上述初版已按用户授权发布为 `65c19de0`,线上三角色只读读取通过;看板请求实测约 13.7–14.7 秒。生产管理员/供应商管理员专用账号验收和历史完整性覆盖仍未完成,未执行历史补录。
|
||||
- 该初版随后被同分支 `962ea6da`(共享按需快照)取代;线上当前构建为 `962ea6da`,状态仍为 `deployed_pending_acceptance`,六类业务验收证据为 `unverified`。
|
||||
|
||||
2026-10-20 UI 修订:数量卡片不显示“个 part”,视频编号列不展示统计单位术语;移除“待核对”占位文案,缺少字段显示“—”,不推定为零或补造任务状态。
|
||||
## 性能优化:共享按需快照(已发布,业务验收待补)
|
||||
|
||||
用户选择方案 2 后,改为所有 API 副本复用按组织/正式项目范围隔离的 part 统计事实,日期、人员和分页请求不再重复读取完整历史。访问触发刷新,默认间隔 120 秒;保留完整可用版本,失败退避,超过 15 分钟不再继续提供陈旧结果。卡片、明细和 CSV 固定同一快照版本,失效后整页恢复;保持确认版式。
|
||||
|
||||
每次请求仍重新校验当前身份和正式项目范围。业务记录、历史补录、交付 JSON 不变。该 GET 在缺少快照或刷新时会写入两个内部派生统计集合,不能再描述为服务端零写入;普通数据库浏览/写入入口禁止访问这些集合。原始审核事件保留在业务存储,快照不复制事件列表,报表详情提供阶段时间与归属。
|
||||
|
||||
本地验证与资源限制见 [`共享快照验证报告`](../../docs/verification/dashboard-snapshots-20261020/report.md),实现契约见 [`共享按需看板快照`](../dashboard-snapshots-20261020/spec.md)。本次优化已按用户授权于 2026-10-20 22:56 发布为 `962ea6da`;线上发布与有限验收见同一报告「线上发布状态」一节。发布记录为 Git 忽略路径 `local-data/releases/dashboard-snapshots-20261020-962ea6da/`,六类业务验收仍为 `unverified`。
|
||||
|
||||
验证记录:[`docs/verification/customer-dashboard-20261020/report.md`](../../docs/verification/customer-dashboard-20261020/report.md)。
|
||||
|
||||
## 原型历史
|
||||
|
||||
原型源码保存在独立 `codex/dashboard-reconciliation-prototype-20261020` 分支,不进入生产代码;入口为 `tests/browser/fixtures/dashboard-reconciliation-prototype.html`。用户确认版式后,正式页面重新接入真实接口,原型数据没有进入运行服务。
|
||||
|
||||
10
.scratch/dashboard-date-refresh/work.md
Normal file
10
.scratch/dashboard-date-refresh/work.md
Normal file
@ -0,0 +1,10 @@
|
||||
# Dashboard dates, freshness and production reads
|
||||
|
||||
Goal: Fix shared dashboard single-day selection, stale results and slow production reads.
|
||||
Agent: Codex
|
||||
Base: codex/release-review-source-20261103 @ d93fb5f0 (verified live baseline; contains origin/dev; follow-up to user review).
|
||||
Scope: Shared dashboard UI, production report read path and focused regression tests.
|
||||
Out of scope: Production writes, indexes, deployment and changing ADR 0012 cohort semantics.
|
||||
Risk: Preserve exclusive API bounds and existing authorization; UI uses inclusive dates. Report read optimizations require result equivalence.
|
||||
|
||||
Verification: Five-role browser flows cover inclusive dates, invalid input, recovery, snapshot refresh, CSV, daily work and legacy zero counters. Mongo synthetic evidence preserves exact report results and tenant/database isolation; cache hits avoid repeated finds. Production cold-query latency remains unverified after deployment; no new indexes or production writes are authorized or performed. Evidence is under local-data/test-results/dashboard-date-refresh-evidence/.
|
||||
28
.scratch/dashboard-snapshots-20261020/spec.md
Normal file
28
.scratch/dashboard-snapshots-20261020/spec.md
Normal file
@ -0,0 +1,28 @@
|
||||
# 共享按需看板快照
|
||||
|
||||
Status: resolved
|
||||
|
||||
2026-10-20 用户选择方案 2。线上基线三次读取为 13.7–14.7 秒,分页在读历史/重算之后执行。同日 22:56 用户另行授权镜像上传、具体部署及内部派生统计写入,候选 `962ea6da` 已发布为线上构建;6 类业务验收证据仍为 `unverified`,发布记录状态为 `deployed_pending_acceptance`,不宣称完整业务验收通过。
|
||||
|
||||
## 契约
|
||||
|
||||
- 保留 part、整段时长、正式阶段时间、冻结作者/供应商、跨期累计、返工快照、空值和服务端权限规则。
|
||||
- 共享已解释的 part 统计事实,按组织/正式项目范围/算法版本区分。所有 API 副本通过 Mongo 复用同一代快照,不按人员、日期或页码重复读历史。
|
||||
- 请求时校验当前身份与范围;首次缺快照返回构建中,后台生成。有完整快照时立即读取,过期按需触发一个后台构建;无人访问不刷新。刷新默认间隔 120 秒,失败重试退避 120 秒,15 分钟后不把陈旧结果继续当作可用结果。
|
||||
- 全局一个有效重建租约,续租与发布按 owner/epoch 条件更新。失效工作者不能覆盖新结果。崩溃/重启后可回收过期租约。快照完整生成、校验成功后才原子替换可见指针。
|
||||
- 独立内部统计集合,不写业务记录、客户描述、媒体或交付 JSON;不把原始审核历史复制到统计快照。保留原有事实读取与纯统计算法作重建来源。
|
||||
- 固定 16 个存储槽,每槽压缩载荷最多 4 MiB;总压缩载荷最多 64 MiB。每个范围保留当前和前一代,最多 8 个范围;有限复用槽位,不能无限积累历史代次。解压限制 32 MiB、重建源读取限制 64 MiB/250000 文档、同时至多两条来源查询、重建 90 秒超时。字节预算不冒充进程 RSS 硬上限。
|
||||
- 卡片/明细/导出按 snapshotId 固定同一代;过期或被回收的 token 明确返回冲突,整页切到新版本,不能混用两代或静默重算导出。
|
||||
- 页面保留确认版式,不加口径长提示;冷启动只显示正常加载状态并有界轮询,取消切换停止轮询。普通刷新不绕过全局限频。
|
||||
|
||||
## 验证
|
||||
|
||||
真实 router 多 handler/分页共用一次历史重建的回归;Memory/Mongo 两个 Adapter;跨 API 并发、过期刷新、失败保留、租约回收、失效 owner 发布拒绝、槽位/字节上限、固定版本导出、权限变更与范围变化;隔离合成 Mongo 三角色浏览器与有规模的计时/扫描次数;按既有前端/Go 基线门禁核对新增失败。
|
||||
|
||||
## 实现结果
|
||||
|
||||
已接入真实 API、Mongo/Memory Adapter 和正式看板。统计结果按版本分页、下钻及导出,旧客户端继续获得完整 200 响应;新客户端冷启动采用可取消的构建中轮询。内部集合 `annotationOutputSnapshotState`、`annotationOutputSnapshotSlots` 不通过普通数据库浏览/写入接口开放。
|
||||
|
||||
本地 5000 part、25000 条历史事件、4 个 API 实例及 32 次热请求:历史重建 1 次,首次 224 ms,热请求 P50 15 ms / P95 17 ms。该数据来自隔离合成 Mongo,不是生产性能承诺。
|
||||
|
||||
验证和兼容边界见 [`report.md`](../../docs/verification/dashboard-snapshots-20261020/report.md),线上发布与有限验收状态见该报告「线上发布状态」一节。本次已发布为 `962ea6da`;新增内部派生集合 `annotationOutputSnapshotState` / `annotationOutputSnapshotSlots` 的写入已列入发布计划并获得用户明确授权。发布记录与原始证据位于工作树内 Git 忽略的 `local-data/releases/dashboard-snapshots-20261020-962ea6da/` 和 `local-data/verification/dashboard-snapshots-release-20261020/`。
|
||||
33
.scratch/delivery-classification-20261021/spec.md
Normal file
33
.scratch/delivery-classification-20261021/spec.md
Normal file
@ -0,0 +1,33 @@
|
||||
# 最终分类交付与内部追溯分离
|
||||
|
||||
Status: done
|
||||
|
||||
2026-10-21 用户要求将两轮总 JSON 核查的问题一起本地修复,并明确选择独立 `tags` 列表、管理员维护。依据为马迪 10-09 至 10-14 的格式对话与本会话补充。原始核查证据在主仓 `local-data/diagnostics/delivery-json-audit-20261021/`。
|
||||
|
||||
## 验收条件
|
||||
|
||||
- 字典词条独立 tags,不从 category/aliases 猜补。选择字典后 ID、类型、版本、名称、编码、tags 经服务器校验并冻结,切片/动作修订、物化、审查及最终 JSON 保持一致;字典后改不改写已确认结果。
|
||||
- 未写动作描述仍保留切片基础分类和全部区间。显式无效与舍弃独立,不从空文本推断;舍弃原因是分类事实,保留。纯留空、混合、全无效及全舍弃均可表达。
|
||||
- 新分类交付使用显式 v4 协议及默认关闭的 DELIVERY_JSON_V4(要求 PART_INDEX_DELIVERY)。客户主 JSON 保持 capture/part、slices/taskSplit/segments 的约定形态,只含定位、最终分类、字典快照、边界及必要源引用;动作 contentKind 使用马迪约定的 annotated/invalid_marked/gap_placeholder。
|
||||
- v4 全舍弃 part 仍输出分类 JSON。旧目录/v1/v2/v3 的 no_deliverables 行为、历史文件和在途任务兼容保留,不静默重写旧批次。
|
||||
- 交付只取最终验收通过的固定物化修订与摘要;返工正式修正须重新通过验收。批注、人员、轮次变化不能改分类,审核者不能通过标注接口修改业务结果。
|
||||
- 全部已提交追溯留内部 JSON,按 capture/part/结果版本关联:审核人、批注、轮次、退回/复审及正式处理记录。客户主 JSON 不带审核历史、lineage、抽检过程或内部路径引用,客户下载不包含内部追溯文件。
|
||||
- 不可变批次的选择/身份/SHA/范围/条件发布/重试规则保留;版本必须显式识别,拒绝混搭和不一致证据。历史缺少字典标签不得按最新字典猜补,保留已有名称事实和未知字段边界。
|
||||
- 舍弃 reasonNote/at 与 note/discardedAt 兼容映射;原始 meta/标定路径基准显式且一致。规范、真实入口样例与校验器枚举一致。
|
||||
|
||||
## 验证
|
||||
|
||||
定向 Go/Python/前端回归,隔离本机 Mongo 与真实 router 的保存→返工→复审→验收→原生打包→批次及下载,检查最终分类/标签和完整内部追溯;覆盖失败重试、重启/旧版本读取、字典更新、未授权篡改、全舍弃、缺失历史证据。前端与 Go 全量门禁按既有基线对照;真实浏览器检查字典 tags 管理和选择,Web/Go 构建及生产包启动。
|
||||
|
||||
不上传镜像、不部署、不写公司数据、不补写历史交付、不 push/PR。本地完成后以新分支提交。
|
||||
|
||||
|
||||
## 本地完成证据(2026-10-21)
|
||||
|
||||
- 独立分支 `codex/delivery-classification-20261021`,基于 `bc00467d`。本次只做本地代码、合成数据验证及提交;未 push、提 PR、上传镜像、部署、启用工作流或改写历史交付。
|
||||
- Go 与前端全量门禁无新增失败,保留原有 70 / 13 个已知失败,基线文件未修改;类型、格式、构建、生成源码一致性及生产页面启动通过。
|
||||
- 定向 Python 37 项通过(含真实视频物化→v4 的 5 项验证);一个旧版 Go 物化 opt-in 用例未单独启用,新旧真实媒体链路已由独立用例覆盖。
|
||||
- 本机 27018 随机独立 Mongo 库的三轮退回和 API 重启、原生 v4 的正式接口批次发布/失败恢复/重试/下载、停用与移除词条后的直接及面板撤销重做、v5/v6 标签防伪造均通过。测试库执行后清理。
|
||||
- 静态复核的 Standards / Spec 两轴发现均已修正并关闭;保留无快照历史的名称事实,不以当前 tags 猜补。未确认临时名称不能绕过最终确认/提交。
|
||||
- 完整日志、分离的客户/内部样例和浏览器截图保留在本工作树 `local-data/verification/delivery-classification-20261021/`。客户样例子目录 `customer-samples/partNNNN/` 每份只含 `part.json`;`customer-samples/internal/` 不属于客户包。
|
||||
- 新协议默认关闭,线上尚未验证/启用;后续正式发布需要覆盖 API/processor、Worker、package 镜像及内部 artifact 存储,按现有发布授权流程执行。未把旧镜像 release 摘要伪装成新源码摘要。
|
||||
21
.scratch/delivery-consumer-contract-20261021/spec.md
Normal file
21
.scratch/delivery-consumer-contract-20261021/spec.md
Normal file
@ -0,0 +1,21 @@
|
||||
Implement approved local v4 contract only. Freeze source ref metadata in revision; require complete customer v4 original source fields. Derive tags from own dictionary or parent frozen dictionary without overwriting selection provenance. Explicit timestamps + local/part seconds, half-open time bases and original PTS resolution. Consumer roundtrip uses only exported JSON + synthetic original source. Legacy formats remain unchanged. Commit local only, no deploy.
|
||||
|
||||
Status: resolved
|
||||
|
||||
Acceptance:
|
||||
- Effective tags and action/slice origin are explicit; independent selections and invalid flags remain intact.
|
||||
- part → slices → segments hierarchy and discard-reason-only semantics remain intact.
|
||||
- Frozen original BOS references survive metadata-only reuse; no connection credentials or workspace paths enter customer output.
|
||||
- Action local/part times and hardware PTS boundaries are complete and continuous.
|
||||
- Missing tags, source, timestamps, source files or conflicting identities reject v4 package/batch publication.
|
||||
- Independent reader resolves every synthetic original camera frame from JSON alone in physical and source-index modes.
|
||||
- Immutable retry/recovery, separate private audit, legacy formats and local Mongo publication remain verified.
|
||||
|
||||
Compatibility: v4 default stays off; no production changes, retrospective tag guessing, old delivery replacement, downstream recutting or source writes.
|
||||
|
||||
Verification:
|
||||
- 73 relevant Python tests passed, including physical/source-index independent real-media consumption, legacy v1/v2/v3 and 60-second materialization.
|
||||
- Native Python v4 output passed Go batch/API publication, failure recovery and download tests with an isolated local Mongo 27018 database.
|
||||
- Go full baseline gate: the same 70 named known failures, no new failures and no baseline edits.
|
||||
- Operator repository generation check and git diff whitespace check passed.
|
||||
- Local evidence: `local-data/verification/delivery-consumer-20261021/`; final customer samples under `final-samples/{physical,source-index}/customer/part0001/part.json`.
|
||||
8
.scratch/image-build-stamp/work.md
Normal file
8
.scratch/image-build-stamp/work.md
Normal file
@ -0,0 +1,8 @@
|
||||
# Stamp images with their build commit and time
|
||||
|
||||
Goal: images report the commit they were built from: pass DROBOTICFLOW_BUILD_COMMIT/BUILD_TIME build-args and make that the documented release build step
|
||||
Agent: Claude Code (Opus 5.5), desktop session 2026-10-28
|
||||
Base: origin/dev @ 8b96632e
|
||||
Scope: scripts/release-build-api-image.sh, scripts/build-and-push-images.sh, docs/release/README.md, tests/release/test_release_build_api_image.py, tests/backend/build_push_images_script_test.py
|
||||
Out of scope: release.py checking the image's baked stamp; the stale DROBOTICFLOW_IMAGE env on live deployments; worker/validator images
|
||||
Risk: build tooling and docs only; existing images and deployments unchanged
|
||||
@ -1,6 +1,6 @@
|
||||
# 独立内部测试环境落地计划
|
||||
|
||||
Status: proposed
|
||||
Status: superseded — 2026-10-20 ADR-0004 修订替代了专用节点、新云盘、合成素材先行、Ingress 与 5 账号/6 样本等前提;见 [spec.md](spec.md) 当前修订
|
||||
Date: 2026-09-27
|
||||
Scope: 本轮仅制定计划,不部署、不申请付费资源、不复制客户样本、不提交 PR。
|
||||
|
||||
|
||||
@ -25,3 +25,7 @@ Blocked by: 无(触发=用户启动执行模式/部署后线上验证)
|
||||
## 验证命令
|
||||
|
||||
- 复现栈/测试通道浏览器手工证据记录到本文件 `## Comments`
|
||||
|
||||
## Comments
|
||||
|
||||
- 2026-10-20:内部测试环境修订后,第 1 项(无 movi 服务时的浏览器播放)由 [12](12-cluster-http-verifier.md) 的浏览器播放场景覆盖,结果作为 `video-playback` 测试环境部分的证据;本票其余内容不变。
|
||||
|
||||
49
.scratch/internal-test-lane/issues/06-renderer-local-node.md
Normal file
49
.scratch/internal-test-lane/issues/06-renderer-local-node.md
Normal file
@ -0,0 +1,49 @@
|
||||
# Render the environment on a pinned node with local storage and a private entry
|
||||
|
||||
Type: task
|
||||
Status: ready-for-agent
|
||||
Blocked by: none
|
||||
|
||||
Spec: Environment. Code: `scripts/internal_test_lane/environment.py`, `tests/internal_test_lane/test_environment.py`.
|
||||
|
||||
Today the renderer creates an RWX workspace PVC and an Ingress, forces the Secure cookie and does
|
||||
not pin nodes. The cluster has only `csi-bos` (no-provisioner) and no IngressClass.
|
||||
|
||||
- Replace the RWX PVC and Ingress with static local PVs for Mongo and workspace: `Retain`, RWO,
|
||||
node affinity on `kubernetes.io/hostname`, explicit claim binding, per-batch names as today.
|
||||
- Config gains `node` and `hostRoot`. Refuse an empty node, a `hostRoot` outside a dedicated
|
||||
internal-test prefix, `droboticflow-fanyu`, and any production PV/PVC name.
|
||||
- Pin API, processor, Mongo and initializer to the node.
|
||||
- Render a one-time directory-preparation pod (pattern: `k8s/qwen-node-cache.prepare-dir.template.yaml`)
|
||||
that creates only this batch's directories under `hostRoot`, owned for the Mongo user.
|
||||
- Entry mode `private-forward`: ClusterIP only, no Ingress or TLS secret, and
|
||||
`DROBOTICFLOW_SESSION_COOKIE_SECURE=false` only in this mode; other modes keep `true`.
|
||||
- Processor runs `ANNOTATION_PROCESSOR_ROLE=all`, concurrency 1.
|
||||
- Refuse any `BOS_*`, `ANNOTATION_WORKSPACE_*` or csi-bos reference.
|
||||
- `internal-test-quota` keeps its stable name and fits API, processor, Mongo, initializer and the
|
||||
preparation pod with finite limits.
|
||||
- Keep default-deny; allow only app pods → Mongo. Whether port-forward needs an extra rule under
|
||||
Cilium stays an explicit unverified item; never open namespace-external ingress to get it working.
|
||||
|
||||
Capacity (PV size and ResourceQuota do not limit what is actually written to a local disk, and
|
||||
node `.4`'s disk is shared with kubelet and images; filling it evicts pods on that node, which can
|
||||
include production operator Jobs):
|
||||
|
||||
- Config gains a capacity budget: bundle source bytes, an output factor for slice media and results
|
||||
(default 2.0 × source until a real batch measures it), Mongo, dump, and retention of 3 archived
|
||||
batches plus the current one. The renderer prints the total.
|
||||
- The directory-preparation pod reports `df` for the filesystem holding `hostRoot`. The operator
|
||||
imports that report; the tool refuses to prepare when free space minus the budget would leave less
|
||||
than 25% of the filesystem free (kubelet hard eviction defaults to 10%). The threshold can be
|
||||
raised, not set below 15%.
|
||||
- The same preflight is required before seed, baseline start, upgrade and archive. A crossed
|
||||
threshold means stop new work (operator scales API and processor to 0) and record it; nothing is
|
||||
deleted automatically.
|
||||
- Every pod gets ephemeral-storage requests and limits, so log and container-layer growth evicts the
|
||||
test pod rather than its neighbours.
|
||||
- Use a filesystem project quota on `hostRoot` when the node filesystem supports it. Otherwise the
|
||||
batch record states "disk usage not enforced by the filesystem; bounded by preflight only".
|
||||
|
||||
Done when: public-boundary tests cover the rendered shape, the budget arithmetic, the threshold
|
||||
refusal and each other refusal, existing tests are
|
||||
updated, and the deployment section of `docs/internal-test-lane.md` matches. No cluster access.
|
||||
@ -0,0 +1,24 @@
|
||||
# Derive test runtime config from a production snapshot
|
||||
|
||||
Type: task
|
||||
Status: ready-for-agent
|
||||
Blocked by: 06
|
||||
|
||||
Spec: Environment (runtime configuration).
|
||||
|
||||
- Input: a read-only snapshot of the production `droboticflow-api` and
|
||||
`droboticflow-annotation-processor` Deployments plus the ConfigMaps they reference. Secrets are
|
||||
never read; only references appear.
|
||||
- Copy non-secret env from the snapshot, then apply an explicit override allowlist:
|
||||
- isolation: namespace / `K8S_NAMESPACE`, Mongo URI and database (test Secret),
|
||||
`WORKSPACE_MOUNT_PATH`, removal of `BOS_ENDPOINT` and every `ANNOTATION_WORKSPACE_*` key,
|
||||
the private-forward cookie setting;
|
||||
- capacity: replicas, `ANNOTATION_PROCESSOR_ROLE`, concurrency keys, resources.
|
||||
- `DROBOTICFLOW_DATABASE_BOOTSTRAP` follows production (currently `verify-existing`).
|
||||
- A reference to a production Secret or ConfigMap that the test namespace lacks is refused, not dropped.
|
||||
- Emit `config-diff.json` per batch (key, class, before/after; secret refs shown as references);
|
||||
`batch.json` binds its SHA256.
|
||||
- Refuse snapshots from another namespace or with a missing Deployment.
|
||||
|
||||
Done when: tests cover the allowlist, refusal of unlisted differences and stable diff output, and
|
||||
the guide explains the diff and why other differences disqualify a batch as evidence.
|
||||
28
.scratch/internal-test-lane/issues/08-bundle-seed-v2.md
Normal file
28
.scratch/internal-test-lane/issues/08-bundle-seed-v2.md
Normal file
@ -0,0 +1,28 @@
|
||||
# Bundle and seed v2: production projects, two suppliers, five business roles
|
||||
|
||||
Type: task
|
||||
Status: ready-for-agent
|
||||
Blocked by: none
|
||||
|
||||
Spec: Data and accounts.
|
||||
|
||||
Today `scripts/internal_test_lane/lifecycle.py` (around lines 155, 201, 476) requires exactly six
|
||||
samples, three each for BLF-data and SL-data, and `internal/testlane/plan.go` (around lines
|
||||
133–302) hardcodes six samples, two dictionaries, those two projects, one supplier and the roles
|
||||
admin / supplier_manager / annotator / quality_reviewer / acceptance_reviewer.
|
||||
|
||||
- New schema `droboticflow.internal-test-seed/v2`: projects come from the bundle (name,
|
||||
workflow-definition snapshot, three dictionaries each); 1–12 samples, at most 3 per project;
|
||||
kinds `scratch`, `snapshot` at `annotation`, `snapshot` at `quality_review`.
|
||||
- Suppliers `test-a` and `test-b`, both authorized on every test project; tasks start unassigned
|
||||
in the shared project pool.
|
||||
- Accounts: annotator and quality reviewer per supplier, plus a `test-a` acceptance reviewer with
|
||||
supplier final-acceptance authorization. No platform admin, no supplier manager.
|
||||
`credentials.py` emits exactly these five.
|
||||
- The seeded database must start under the production bootstrap mode (`verify-existing`).
|
||||
- v1 bundles exist only as local synthetic fixtures: refuse v1 with a clear message. Keep every
|
||||
existing refusal (non-empty target, non-test URI, plan/manifest hash mismatch).
|
||||
- `tests/internal_test_lane/make_synthetic_bundle.py` produces v2.
|
||||
|
||||
Done when: Go and Python tests are updated, a fresh local Mongo seeds from a synthetic v2 bundle,
|
||||
and the guide documents v2.
|
||||
@ -0,0 +1,42 @@
|
||||
# Export samples from a restored backup and download their media
|
||||
|
||||
Type: task
|
||||
Status: ready-for-agent
|
||||
Blocked by: 08
|
||||
|
||||
Spec: Data and accounts, run-sequence steps 1–2.
|
||||
|
||||
Restoring the backup (today's `scripts/local/fetch-mongo-snapshot.sh` execs into a production API
|
||||
pod, stages the archive in chunks under that pod's `/tmp`, then runs `docker rm -f
|
||||
fanyu-mongo-restore`, recreates 27018 and restores with `--drop`; its default backup directory is
|
||||
the fixed `fanyu-v58-ca15d60d`):
|
||||
|
||||
- Leave that script unchanged for its existing 27018 use; add a separate restore path for the lane.
|
||||
- List backup directories under `/workspace/system/backups/` and show the chosen one's name, date
|
||||
and archive size. If the newest backup is older than the selection window, stop: taking a new
|
||||
production backup is a separate approved operation.
|
||||
- Read the archive by byte ranges straight from the mounted file, with no staging in the production
|
||||
pod. If staging cannot be avoided, check the archive size against the pod's free ephemeral space
|
||||
first and refuse above a threshold. Verify the full SHA256 locally.
|
||||
- Restore into a new container with an explicit unique name and an explicit unused loopback port.
|
||||
Refuse when the name exists or the port is in use, and refuse 27017–27020 (existing local
|
||||
stacks). Never `docker rm -f` an existing container and never `--drop` into one.
|
||||
|
||||
Exporting:
|
||||
|
||||
- Connect only to an explicit loopback Mongo URI; refuse non-loopback hosts and the existing
|
||||
local containers on 27017/27018.
|
||||
- `candidates`: per project active in the backup's recent window (default 14 days, flag), list
|
||||
tasks by stage with Capture name, part count, required media keys and sizes. No account names
|
||||
or phone numbers.
|
||||
- `export`: from chosen task IDs (at most 3 per project, 12 total) write a v2 bundle skeleton:
|
||||
project config, workflow-definition snapshot, dictionaries, slice/action content for snapshot
|
||||
kinds, and required media (both cameras, both PTS, IMU) as BOS keys.
|
||||
- Download only those keys, read-only, with credentials from the untracked local file (same
|
||||
approach as `scripts/local/download-capture.sh`); record size and SHA256 into bundle assets;
|
||||
resume safely; never write to BOS.
|
||||
- Print the total size before downloading; refuse above a cap (default 20 GiB).
|
||||
|
||||
Done when: tests use a synthetic Mongo fixture, a mocked BOS client and a mocked `kubectl`/`docker`
|
||||
boundary that prove the refusals (existing container, busy port, staging over threshold). This ticket does not touch
|
||||
a real backup or BOS.
|
||||
@ -0,0 +1,31 @@
|
||||
# release.py: selectable policy, validator coverage, worker guard
|
||||
|
||||
Type: task
|
||||
Status: ready-for-agent
|
||||
Blocked by: none
|
||||
|
||||
Spec: Promotion. Code: `scripts/release.py` (policy hardcoded at line 19), `docs/release/`.
|
||||
|
||||
- `--policy <path>`; without it, behaviour stays on `docs/release/fanyu-policy.json`, so existing
|
||||
records keep working. Historical records with another policy hash follow the existing read-only rules.
|
||||
- The Fanyu policy adds `droboticflow-annotation-validator`: same image patch, its own role env
|
||||
(`validation`) and resources preserved; the cluster check verifies each Deployment's role.
|
||||
- New `docs/release/internal-test-policy.json`: namespace `droboticflow-internal-test`, local-PV
|
||||
workspace, no bucket/BOS checks, API + processor (role `all`). Each policy refuses the other
|
||||
namespace by name and UID.
|
||||
- Split `annotation-delivery` in the Fanyu policy's `requiredEvidence` into `annotation-results`
|
||||
and `delivery-packaging`. `delivery-packaging` is satisfied by either:
|
||||
- a packaging test record from an environment that runs the worker and package operators (the
|
||||
test lane cannot produce it), or
|
||||
- an unchanged-delivery-inputs check that `release.py` computes itself: the diff between the
|
||||
production API build commit and the candidate over a policy-declared path list is empty. The path
|
||||
list (result-JSON writers, release partition, part-index delivery, package operators) is derived
|
||||
from the code and reviewed with the policy. A non-empty diff requires the packaging test record.
|
||||
Records under the old policy hash stay historical; an in-progress record must be prepared again.
|
||||
- Worker guard: read the production worker's build commit from the read-only snapshot; refuse
|
||||
the plan if `internal/worker` or `cmd/worker` differ between it and the candidate, pointing to
|
||||
separate verification.
|
||||
|
||||
Done when: `tests/release` (simulated Kubernetes) covers policy selection, three-Deployment patch
|
||||
and partial failure, the worker guard, cross-policy refusal, and both `delivery-packaging` paths
|
||||
(empty diff accepted, non-empty diff without a packaging record refused), and `docs/release/README.md` is updated.
|
||||
@ -0,0 +1,36 @@
|
||||
# Bind test-lane batch reports to release evidence
|
||||
|
||||
Type: task
|
||||
Status: ready-for-agent
|
||||
Blocked by: 10, 13
|
||||
|
||||
Spec: Promotion.
|
||||
|
||||
- `release.py evidence <id> --check <c> --test-lane-batch <batch-id>` reads the local batch
|
||||
record and requires: state `business-verified`, `candidateImage` equal to the release image
|
||||
digest, a config diff limited to allowed classes, and unchanged report hashes. It stores the
|
||||
batch ID, digests and report hash; anything else is refused. Batches in `failed` or
|
||||
`outcome-unknown` are always refused.
|
||||
- Start point: for the upgrade-rehearsal part of `change-safety`, the batch's `baselineImage` must
|
||||
equal the `before` image the release plan recorded for each Deployment it covers. Production may run
|
||||
different starting digests (today the validator runs `7699d455…` while api and processor run
|
||||
`1a1ead7a…`); a Deployment whose `before` image differs from `baselineImage` is listed as not
|
||||
covered by the rehearsal.
|
||||
- Each check needs named scenarios in the report, all `passed`. A scenario that is missing, failed or
|
||||
unverified refuses the check.
|
||||
|
||||
| Release check | Required scenarios |
|
||||
| --- | --- |
|
||||
| `role-login` | five business-role logins; role-boundary refusals (admin logins come from production smoke) |
|
||||
| `supplier-permissions` | cross-supplier claim refused; other supplier's annotation invisible |
|
||||
| `review-acceptance` | QC pass; QC return → rework resubmit; final acceptance |
|
||||
| `slice-recovery` | processor restart with work resumed; in-flight tasks resumed after upgrade |
|
||||
| `video-playback` | browser playback for both cameras: first frame, playback advancing (test-lane part) |
|
||||
| `annotation-results` | accepted results contain normal, discard, invalid and blank cases as entered |
|
||||
| `change-safety` (rehearsal part) | start-point match; in-flight state created on baseline; resumed on candidate |
|
||||
|
||||
`delivery-packaging` cannot be satisfied by a batch (see ticket 10).
|
||||
- Production-side smoke evidence (ticket 14) is still required by `verify`.
|
||||
|
||||
Done when: tests cover digest mismatch, start-point mismatch, a partially covered Deployment, a
|
||||
missing or failed scenario, an unverified or failed batch, a tampered report and a disallowed check.
|
||||
@ -0,0 +1,29 @@
|
||||
# HTTP business verifier for cluster batches
|
||||
|
||||
Type: task
|
||||
Status: ready-for-agent
|
||||
Blocked by: 08
|
||||
|
||||
Spec: Batch flow steps 2 and 4. Today `tests/internal_test_lane/verify_local.py` reads fixed
|
||||
local paths and assumes one supplier.
|
||||
|
||||
- Inputs: loopback base URL (port-forward), the private accounts file and the executed plan.
|
||||
Refuse any non-loopback host.
|
||||
- Scenarios: five logins and role-boundary refusals; `test-a` claims and `test-b` can neither
|
||||
claim nor see that annotation; slicing → normal / discard / invalid / blank → submit → QC return
|
||||
→ rework resubmit → QC pass → final acceptance; snapshot samples; frame range.
|
||||
- Browser playback with Playwright (already a dependency): for both cameras in normal and focus
|
||||
layout, the first frame renders (video ready and a non-blank sampled frame) and playback time
|
||||
advances within ±20% of wall-clock time over 5 s. Record what happens without a movi service; this
|
||||
covers item 1 of ticket 05 for the test lane. HTTP media responses alone never pass this scenario.
|
||||
- `--phase in-flight` stops after leaving claimed, slicing-pending and submission-pending tasks;
|
||||
`--phase after-upgrade` resumes exactly those tasks.
|
||||
- Processor-restart recovery: the tool prints the restart step for the operator, then waits and
|
||||
checks the work resumes; it never restarts pods itself.
|
||||
- Every scenario has a stable ID and a `passed` / `failed` / `unverified` status, matching the table
|
||||
in ticket 11.
|
||||
- One final JSON report: batch ID, observed build commit/digest (cross-checked with `batch.json`),
|
||||
sample keys, task and item IDs, per-check status. No credentials; never overwrites.
|
||||
|
||||
Done when: it runs against a fresh local stack with two suppliers, and tests cover report shape
|
||||
and refusals.
|
||||
26
.scratch/internal-test-lane/issues/13-upgrade-rehearsal.md
Normal file
26
.scratch/internal-test-lane/issues/13-upgrade-rehearsal.md
Normal file
@ -0,0 +1,26 @@
|
||||
# Batch flow: baseline-to-candidate upgrade rehearsal
|
||||
|
||||
Type: task
|
||||
Status: ready-for-agent
|
||||
Blocked by: 06, 07, 10, 12
|
||||
|
||||
Spec: Batch flow.
|
||||
|
||||
- Batch config gains pinned `baselineImage` and `candidateImage`; `batch.json` binds both.
|
||||
`baselineImage` comes from a read-only snapshot of the production Deployments taken at prepare
|
||||
time, and the snapshot's per-Deployment images are recorded for the start-point check in ticket 11.
|
||||
- States: prepared → seeded → baseline-running → in-flight-created → upgraded →
|
||||
business-verified → archived. Each transition imports operator-provided evidence as today;
|
||||
the tool never probes the cluster.
|
||||
- The upgrade runs `release.py` with the internal-test policy, the same code path as production.
|
||||
- If the candidate needs a migration that production would run as a separate reviewed step, the
|
||||
rehearsal runs that same procedure in the test namespace; otherwise its change-safety part
|
||||
cannot be recorded.
|
||||
- `status` shows which digest ran in each phase.
|
||||
- Failure path: any phase may move to `failed` or `outcome-unknown`. Either one means stop new work
|
||||
(operator scales API and processor to 0), archive with that state kept (ticket 15), and never
|
||||
promote the batch to `business-verified`. The next attempt is a new batch with new identities; a
|
||||
contaminated batch is not resumed.
|
||||
|
||||
Done when: lifecycle tests cover transitions, refusals and both failure states, a local end-to-end run uses two locally
|
||||
built binaries (production commit → dev-mainline HEAD), and the guide is updated.
|
||||
31
.scratch/internal-test-lane/issues/14-production-smoke.md
Normal file
31
.scratch/internal-test-lane/issues/14-production-smoke.md
Normal file
@ -0,0 +1,31 @@
|
||||
# Post-promotion production smoke, no customer-data writes by default
|
||||
|
||||
Type: task
|
||||
Status: ready-for-agent
|
||||
Blocked by: 12
|
||||
|
||||
Spec: Promotion (production smoke).
|
||||
|
||||
- Uses the untracked production verification accounts file. Before any write mode, confirm those
|
||||
accounts belong to the frozen internal organization.
|
||||
- An HTTP method does not decide whether a call writes. Task detail GET runs interrupted-slice
|
||||
recovery and can finalize a pending submission (`internal/api/annotation_operations.go`, around
|
||||
line 999); frame-range GET persists a timeline index on a cache miss
|
||||
(`internal/api/annotation_timeline_index.go`, around line 102). Keep an endpoint list in the tool,
|
||||
each entry classified by server-side effect: none / possible write / forbidden.
|
||||
- Default mode promises no customer-data writes, not zero writes: logins (admin roles when accounts
|
||||
are supplied), project and task lists, opening an existing internal-organization task, browser
|
||||
playback (reusing ticket 12's check), frame range. Endpoints marked "possible write" are called
|
||||
only on internal-organization objects, and the report lists every such call and the object it
|
||||
touched. Calls outside the list, and any call on a non-internal organization, are refused.
|
||||
- BOS path: the smoke asserts that frame range loads from the BOS source of an internal-organization
|
||||
task (this exercises the BOS read and HEAD). Cache invalidation after a source ETag change would
|
||||
need a production object to change, so it stays unverified.
|
||||
- Write mode needs `--write --confirm <token>` and explicit internal-organization task IDs:
|
||||
claim → slicing → submit → QC → acceptance. Refuse customer organization IDs, report how many
|
||||
internal tasks remain, never create tasks.
|
||||
- Report JSON bound to the release ID and the observed build commit.
|
||||
|
||||
Done when: tests against a mocked HTTP server cover unlisted-endpoint refusal, organization
|
||||
refusal, the side-effect report (including cold frame-range cache and an interrupted task) and the
|
||||
confirm token. This ticket does not access production.
|
||||
17
.scratch/internal-test-lane/issues/15-batch-archive.md
Normal file
17
.scratch/internal-test-lane/issues/15-batch-archive.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Archive cluster batches to local storage
|
||||
|
||||
Type: task
|
||||
Status: ready-for-agent
|
||||
Blocked by: 06
|
||||
|
||||
Spec: Batch flow step 5.
|
||||
|
||||
- Render an archive pod in the test namespace that runs `mongodump` of the batch database into
|
||||
the batch directory on the node; render the pull commands into
|
||||
`local-data/internal-test-lane/batches/<batch-id>/` with a SHA256 manifest.
|
||||
- Dumps count toward the capacity budget in ticket 06, and archiving requires a passing preflight.
|
||||
- `archive` evidence additionally requires the pulled dump, reports and config diff with hashes.
|
||||
- Retention: latest 3 archived batches plus the current one. `cleanup-plan` also lists the
|
||||
node-side directories for a separately approved cluster cleanup; the tool never deletes remotely.
|
||||
|
||||
Done when: tests cover manifest verification and retention selection.
|
||||
@ -128,3 +128,82 @@ Q1–Q3 均已采用推荐项。
|
||||
- [01 environment](issues/01-environment.md), [02 seed](issues/02-seed.md), [03 lifecycle](issues/03-lifecycle.md) implemented and locally verified.
|
||||
- [04 integration](issues/04-integration.md): core five-role scratch/snapshot workflows verified through final acceptance; standard delivery-package worker/graph remains uncovered. See [verification and two-axis review](verification.md).
|
||||
- No customer assets or production runtime changes. Company deployment, real sample copy and production publication remain separately authorized operations.
|
||||
|
||||
## 2026-10-19 修订讨论
|
||||
|
||||
背景:客户已投产,用户不能再用客户账号测试。希望基于 `codex/dev-mainline-20261019` 在线上单开测试环境,用少量真实客户样本模拟全流程;通过后用脚本把同一版本发布到生产。本节不构成部署、复制或账号创建授权。
|
||||
|
||||
### 2026-10-19 Round 1(Q1–Q10 全部采用推荐项)
|
||||
|
||||
- Q1:修订 ADR-0004 而非另起方案。三处修订:首次部署即用真实客户样本(不再先走合成素材阶段);全流程覆盖标准交付打包;测试结果作为生产发布验收证据。其余既定决策不变。
|
||||
- Q2:“推送到生产”定义为**版本晋升**:测试环境运行 dev-mainline 已提交 commit 构建的不可变镜像 digest,通过后经 `scripts/release.py` 将同一 digest 发布到生产;测试数据、账号、配置、存储卷不进生产;测试批次验收报告挂入 release 记录作为写入类证据;每次生产部署仍需当次授权。
|
||||
- Q3:测试环境运行配置从生产只读导出非机密项,仅覆盖隔离字段(namespace、数据库、存储、入口)与容量字段(并发 1、资源上限);每批记录与生产的配置差异,差异外不一致的项不能作为晋升证据。
|
||||
- Q4:纳入标准交付打包:测试 namespace 内独立工作流 worker(仅限测试 namespace 创建 Job)、算子镜像、生产打包工作流快照;不启用 `fanyu-high-capacity` 档,打包并发 1,产物只写测试存储、不进客户交付出口。
|
||||
- Q5:新建测试专用 BOS bucket,用生产只读凭证复制选中 Capture;测试环境的 csi-bos 存储卷与 AK/SK 只对测试 bucket 有权限。不只读挂载生产 bucket,不改用 local PV。
|
||||
- Q6:测试 namespace 内独立 Mongo 实例(不在生产 Mongo 上另建库);从生产只读导出选中项目配置(项目、工作流定义快照、三类字典)及样本,以新身份生成测试任务副本;不复制客户账号、会话、领取、在途处理和正式审查记录。
|
||||
- Q7:每个在产项目 3 条(待切片、保留切片/动作快照、质检阶段快照),总数 ≤ 12;精确清单与体积只读盘点后由用户确认。
|
||||
- Q8:两个测试供应商 `test-a`、`test-b`,各含供应商管理员/标注员/质检员,另加平台管理员和最终验收员,约 8 个账号(替代原 5 账号)。
|
||||
- Q9:首版仅本机 127.0.0.1 端口转发,供用户本人使用;不建公网入口、不改生产 Ingress/DNS。
|
||||
- Q10:“多个 pod”指一套测试环境内多个组件,一次一个候选版本;不并行多套环境。
|
||||
|
||||
### 集群只读盘点(2026-10-19)
|
||||
|
||||
- 三个 Ready 节点:`10.189.16.33`(56 CPU / ~220 GiB / 2 GPU,requests CPU 15%、limits 37%);`10.189.16.4`、`10.189.16.5`(各 8 CPU / ~31 GiB,后者 CPU limits 已超售至 185%)。均无污点。采样时实际 CPU 使用接近 0。
|
||||
- 存储类仅 `csi-bos`(no-provisioner,静态 PV);无 IngressClass。生产工作区 `droboticflow-workspace-pv` 200Gi 为 csi-bosplugin。
|
||||
- `droboticflow-internal-test` namespace 于 2026-09-27 已建,仅有 `internal-test-quota`(pods 3、requests 1 CPU/2Gi、limits 3 CPU/10.5Gi、存储 20Gi、PVC 8)、`internal-test-default-deny` 网络策略及 CCE 自动镜像拉取 Secret;无工作负载。配额不足以容纳 worker 与算子 Job。
|
||||
- 生产 `droboticflow-fanyu` 应用组件:api ×4 与 annotation-processor ×2(同镜像,build commit 630a95c8 = 当前 dev-mainline HEAD,processor role=revision);annotation-validator ×2(另一镜像,963b530f,role=validation,2026-10-17 建);worker ×2(worker 镜像,963b530f);drosync-coordinator ×2;GPU 服务 headpose/wilor 无就绪副本。`release.py` 策略只覆盖 api 与 processor。
|
||||
- **已有生产内测试组织**:所有生产应用组件的 `ANNOTATION_WORKSPACE_MAPPINGS` 含 `org-internal-0bd5aa2e…`,读取生产 bucket `internal-test/blf-20260927-…/assets`,写 `system/runs/run-internal-*`,交付至 `internal-test/…/deliveries/TEST-internal-BLF__…`。来源为 2026-09-27 release 记录 `test-readonly-fix-20260927`(API-only 配置变更,7 个测试账号覆盖 5 角色)。这是生产库内隔离组织方案,与 ADR-0004 的独立环境方案并存,待决定其去留。
|
||||
|
||||
### 2026-10-19 Round 2(Q11–Q15 采用推荐项;Q16 被用户否决)
|
||||
|
||||
- Q11:保留既有生产内测试组织 `org-internal-…`,冻结并收窄为**晋升后生产冒烟**:每次晋升后用 1 条样本验证生产自身配置、凭证与存储;不再新增样本或项目。
|
||||
- Q12:候选版本为一个 dev-mainline commit 构建的镜像;测试环境各组件 1 副本;drosync-coordinator 不在测试环境和候选范围内。(组件范围已被 2026-10-20 范围收窄修订,见下文。)
|
||||
- Q13:每批先以生产当前 digest 启动并导入样本、制造在途状态,再用**同一晋升脚本**指向测试环境升级到候选版本,演练迁移与在途恢复,产出 change-safety 证据。修订 ADR-0004“一批一版本”为“一批 = 生产版本 → 候选版本”。
|
||||
- Q14:测试环境固定到 `10.189.16.4`(无生产应用 Pod),不给生产节点加污点、不改生产调度;按需上调测试配额;观察到争用再申请专用节点。
|
||||
- Q15:测试 Mongo 为测试 namespace 内 Pod,主版本与生产一致(待只读核实),数据放 `.4` 本地盘专用目录的静态卷。
|
||||
- Q16(否决):用户无法也不愿创建 BOS 子用户或测试 bucket。
|
||||
|
||||
### 2026-10-20 用户范围收窄
|
||||
|
||||
- 本轮只测试**标注 → 质检 → 最终验收**;Capture 接入及算子处理不在本问题范围。
|
||||
- 不需要平台管理员的全局管理功能。
|
||||
- 用户希望直接从 BOS 读取相应文件。代码核实:该链路并非只读——标注处理器在领取后自行生成切片媒体,送检与终审发布结果文件,均写入 `WORKSPACE_MOUNT_PATH` 下;算子 Job 与 worker 确实不参与。依据 [annotation-workspace-mappings.md](../../docs/annotation-workspace-mappings.md):“只读委托仅解决素材与帧范围加载,不支持生成切片产物”。
|
||||
- 由此 Round 1 Q4(纳入标准交付打包)失效;Q5、Q8、Q12、Q15 中依赖测试 bucket、worker 或平台管理员的部分待 Round 3 重新确认。
|
||||
- 事实:本地 Capture 样例(单 part、480p)约 235 MB;12 条源素材约数 GB。生产 worker(963b530f)与 api(630a95c8)之间 5 个提交未改 worker 代码。
|
||||
|
||||
### 2026-10-20 Round 3(Q16′–Q21 全部采用推荐项)
|
||||
|
||||
- Q16′(替代 Q16、Q5):以本机已有 BOS 凭证、按 `scripts/local/download-capture.sh` 方式一次性只读下载选中 Capture,校验 SHA256 后上传到 `.4` 本地盘测试工作区。测试环境为纯本地工作区模式:不挂载 BOS、不持有任何 BOS 凭证,切片与结果写本地盘。bosfs 读取与 BOS ETag 版本检查不在测试环境覆盖范围,由 Q11 晋升后生产冒烟覆盖。不采用只读挂载生产 bucket,不写入生产 bucket 的 `internal-test/` 前缀。
|
||||
- Q17(撤回 Round 1 Q4):不含 worker、算子 Job 与标准交付打包。测试环境组件为 API ×1、标注处理器 ×1(role `all`,并发 1)、Mongo ×1。终审通过的任务停在待交付。
|
||||
- Q18(修订 Q12):晋升只更新 API 镜像的三个组件 api、annotation-processor、annotation-validator;worker 保持现版本。候选改动 `internal/worker`、`cmd/worker` 时晋升脚本拒绝并要求另行验证。需扩展 `release.py` 策略纳入 validator。
|
||||
- Q19(修订 Q8):5 个业务账号——test-a 标注员与质检员、test-b 标注员与质检员、1 名归属 test-a 且开通供应商最终验收授权的最终验收员;无平台管理员与供应商管理员。项目、供应商、成员与任务由 seed 命令建立。管理类登录由生产冒烟只读检查。
|
||||
- Q20:样本选择、项目配置与字典导出、Mongo 版本确认均基于 `scripts/local/fetch-mongo-snapshot.sh` 拉取的最新备份,在本地独立容器完成,不查询线上库。选样清单交用户确认。
|
||||
- Q21:测试批次报告记录候选镜像 digest 与配置差异摘要;`release.py evidence` 接收测试报告时校验 digest 一致且批次为 business-verified,否则拒绝。测试环境无法产出的证据(含交付打包)保持 unverified。
|
||||
|
||||
### 2026-10-20 Round 4(Q22–Q25 全部采用推荐项)
|
||||
|
||||
- Q22:逐步单独授权,前一步通过才询问下一步:① 拉取最新 Mongo 备份到新的本地容器(不动 27018)并选样;② 确认清单后从 BOS 只读下载样本;③ 从 dev-mainline 干净 worktree 构建候选 API 镜像并推送到公司镜像仓库;④ 测试 namespace 写入(配额、`.4` 专用目录、静态卷、Mongo、上传素材、seed、删除初始化 Pod),写前复核集群与 namespace UID;⑤ 以生产当前 digest 启动、制造在途状态、用晋升脚本升级到候选并跑全流程;⑥ 按 `release.py` 流程晋升生产并做生产冒烟。
|
||||
- Q23:晋升后生产冒烟默认只读(全角色登录、列表、内部组织任务、视频播放与帧范围);仅当候选改动领取、切片、送检或审查写路径时,经当次批准在内部组织剩余任务上做写入冒烟;任务耗尽时报告,不自动补充,不使用客户任务。
|
||||
- Q24:归档时 `mongodump`、结果报告与配置差异摘要写 `.4` 本地盘并拉回 `local-data/internal-test-lane/batches/<batch-id>/`;保留最近 3 批加当前批;旧批次本地产物预览后确认删除;集群侧清理另列清单与授权。
|
||||
- Q25:复现特定客户问题时可追加该 Capture 为样本,按 ①→②→④ 流程逐次批准,活动总数 ≤ 12;新身份,不回写来源任务。
|
||||
- 前沿已清空,待用户确认达成共同理解后修订 ADR-0004 与 spec 并拆分实施票。
|
||||
|
||||
### 2026-10-20 共同理解确认
|
||||
|
||||
- 用户确认四轮决定达成共同理解。已记录:[ADR-0004 2026-10-20 修订](../../docs/adr/0004-isolated-internal-test-lane.md)、[spec.md 当前修订](spec.md)、实施票 [06](issues/06-renderer-local-node.md)–[15](issues/15-batch-archive.md)(05 为主线既有 movi 冒烟票);[部署计划](deployment-plan.md) 标记为 superseded;术语“内部测试环境”“版本晋升”写入 [CONTEXT.md](../../CONTEXT.md)。
|
||||
- 依赖:06、08、10、14 无前置;07←06;09←08;12←08;15←06;13←06/07/10/12;11←10/13。既有 05(movi 直连播放冒烟,暂缓)可在本环境部署后执行。
|
||||
- 未开始实施,未提交;集群、BOS、备份拉取与生产晋升均未执行,按 spec 的 Run sequence 逐步授权。
|
||||
|
||||
### 2026-10-20 外部审阅采纳
|
||||
|
||||
用户采纳外部审阅的 7 点及补充项,第 6 点选方案 A。均已代码核实并写入票据与 spec:
|
||||
|
||||
- 备份恢复:现有 `fetch-mongo-snapshot.sh` 会在生产 API Pod 的 `/tmp` 分块暂存归档,并删除重建 27018 容器、`--drop` 恢复;默认备份目录固定为 `fanyu-v58-ca15d60d`。改为独立容器名与端口、拒绝覆盖、按字节区间直接读取不在生产 Pod 暂存、展示备份日期,过旧则停止([09](issues/09-backup-sample-export.md))。
|
||||
- 生产冒烟:任务详情 GET 会恢复中断切片并可能完成待定送检,帧范围 GET 缓存缺失时写入索引;“只允许 GET”不等于只读。改为按服务端副作用分类端点,默认承诺不写客户数据,内部组织上的副作用写入列入报告([14](issues/14-production-smoke.md),新增依赖 12)。
|
||||
- 本地盘容量:预算 + `df` 预检 + 剩余 25% 停止阈值 + 临时存储上限;文件系统配额视节点支持,否则记录为仅预检约束([06](issues/06-renderer-local-node.md)、[15](issues/15-batch-archive.md))。
|
||||
- 升级起点:`baselineImage` 须等于发布计划记录的各 Deployment 旧镜像;当前 validator(`7699d455…`)与 api/processor(`1a1ead7a…`)起点不同,不一致者列为演练未覆盖([11](issues/11-release-evidence-binding.md)、[13](issues/13-upgrade-rehearsal.md))。
|
||||
- 检查项→必需场景映射,缺项、失败、未验证一律拒绝([11](issues/11-release-evidence-binding.md)、[12](issues/12-cluster-http-verifier.md))。
|
||||
- 发布证据:`annotation-delivery` 拆为 `annotation-results` 与 `delivery-packaging`;后者由打包测试记录,或 `release.py` 自行核对策略声明的交付输入路径未改动满足([10](issues/10-release-policy-scope.md))。ADR-0004 修订已补记。
|
||||
- 播放与 ETag:浏览器(Playwright)首帧与播放推进;ETag 变化后的缓存失效保持未验证;05 号票第 1 项由 12 覆盖。
|
||||
- 失败路径:`failed` / `outcome-unknown` 停机、保留状态归档、重开新批次([13](issues/13-upgrade-rehearsal.md))。
|
||||
- 依赖更新:14←12。
|
||||
|
||||
@ -1,4 +1,166 @@
|
||||
# Internal test lane — implementation baseline
|
||||
# Internal test lane
|
||||
|
||||
Status: ready-for-agent
|
||||
Current revision: 2026-10-20
|
||||
Code baseline: `codex/dev-mainline-20261019` @ `630a95c8`
|
||||
|
||||
Decisions: [map.md](map.md) (2026-10-19/20, Rounds 1–4) and the 2026-10-20 revision of
|
||||
[ADR-0004](../../docs/adr/0004-isolated-internal-test-lane.md). This revision authorizes local
|
||||
implementation and local verification of tickets 06–15 only. Pulling a backup, downloading
|
||||
from BOS, pushing images, writing to the cluster, creating accounts there and promoting to
|
||||
production are separately approved steps (see Run sequence).
|
||||
|
||||
## User-facing outcome
|
||||
|
||||
Before promoting a dev-mainline candidate, the developer runs one batch in the isolated test
|
||||
environment. Up to 12 real customer samples, chosen from the newest production backup and
|
||||
downloaded once read-only from BOS, are claimed, sliced, annotated, submitted, reviewed and
|
||||
accepted by five test business accounts in two test suppliers. The batch first runs the
|
||||
production image, then upgrades to the candidate with the same promotion script used for
|
||||
production. A business-verified report bound to the candidate digest becomes release evidence;
|
||||
that digest is then promoted to production's API-image components and checked by a production
|
||||
smoke that is read-only by default.
|
||||
|
||||
## Scope
|
||||
|
||||
In: annotation → quality review → final acceptance, including slice generation, source-index
|
||||
validation, save, submission, rework return, processor restart recovery, supplier claim
|
||||
exclusivity and invisibility, browser video playback (first frame, playback advancing) and frame
|
||||
range from the local workspace.
|
||||
|
||||
Out, and recorded as unverified wherever release evidence asks for it: workflow worker,
|
||||
operator Jobs, standard delivery packaging, Capture ingestion, cache invalidation after a BOS
|
||||
source ETag change, load and capacity, platform-admin and supplier-admin
|
||||
management.
|
||||
|
||||
## Environment
|
||||
|
||||
- Namespace `droboticflow-internal-test` (exists; only `internal-test-quota` and
|
||||
`internal-test-default-deny` today). Every pod is pinned to node `10.189.16.4`; production
|
||||
nodes get no taints and production scheduling is unchanged.
|
||||
- Components: API ×1; annotation processor ×1 with role `all`, concurrency 1; Mongo ×1 with
|
||||
the production major version; an initializer pod during import only; a one-time
|
||||
directory-preparation pod.
|
||||
- Storage: static local PVs on a dedicated directory of node `.4` for Mongo and workspace,
|
||||
`Retain`, node affinity, RWO. No csi-bos volume, BOS endpoint, storage connection,
|
||||
workspace mapping or BOS credential exists in the namespace.
|
||||
- Entry: ClusterIP only, reached through `kubectl port-forward` bound to `127.0.0.1`. The
|
||||
session cookie may drop `Secure` only in this explicit private-forward mode.
|
||||
- Runtime configuration is derived from a read-only snapshot of the production API and
|
||||
processor Deployments. Only isolation fields (namespace, database, workspace/storage,
|
||||
entry/cookie) and capacity fields (replicas, processor role, concurrency, resources) are
|
||||
overridden; the database bootstrap mode follows production. Each batch records the diff;
|
||||
any other difference disqualifies the batch as promotion evidence.
|
||||
- Quota fits API, processor, Mongo and initializer with finite CPU, memory and storage limits.
|
||||
- Disk: PV size and quota do not bound real writes to the node's local disk, which kubelet and
|
||||
images share. A budget (samples, slice output, Mongo, dumps, 3 retained batches plus the current
|
||||
one) is checked against a `df` preflight before seed, start, upgrade and archive; below 25% free
|
||||
after the budget, work stops. Pods carry ephemeral-storage limits; a filesystem quota is used where
|
||||
the node supports it, otherwise the batch record says the limit is preflight-only.
|
||||
|
||||
## Data and accounts
|
||||
|
||||
- Selection and export read a backup restored into a new local container with its own name and
|
||||
loopback port; the restore refuses an existing container name, a busy port and 27017–27020, and
|
||||
never drops into an existing database. The archive is read by byte ranges from the backup mount,
|
||||
without staging inside the production pod. The chosen backup's name and date are shown; if the
|
||||
newest one is older than the selection window, work stops, because a new production backup is a
|
||||
separately approved operation. The live database is never queried.
|
||||
- Per in-production project, up to 3 samples: scratch (pending annotation), annotation
|
||||
snapshot (existing slices and actions), quality-review snapshot. At most 12 in total. The
|
||||
user confirms the final list (Capture, project, template kind, size) before download.
|
||||
- Media is downloaded read-only from production BOS on the developer machine, SHA256-verified
|
||||
and bundled. Project config, the workflow-definition snapshot and the three dictionaries come
|
||||
from the backup. Customer accounts, sessions, leases, in-flight work, formal review records
|
||||
and notification targets are not copied.
|
||||
- Suppliers `test-a` and `test-b`. Accounts: annotator and quality reviewer for each supplier,
|
||||
plus one final acceptance reviewer in `test-a` with supplier final-acceptance authorization.
|
||||
All work identities are new; source IDs are kept only for traceability. The seeded database
|
||||
must start under the production bootstrap mode.
|
||||
- Reproduction samples may be added later through the same export → download → import path,
|
||||
approved each time, keeping the active total at 12 or fewer.
|
||||
|
||||
## Batch flow
|
||||
|
||||
1. Prepare a batch with `baselineImage` (production's current API digest, from a read-only
|
||||
Deployment snapshot that also records each Deployment's image) and `candidateImage`.
|
||||
2. Seed, start on `baselineImage`, and create in-flight state: claimed tasks, slicing pending,
|
||||
submission pending.
|
||||
3. Upgrade to `candidateImage` with `release.py` and the internal-test policy.
|
||||
4. Run the HTTP verifier and the browser playback check on the candidate: five roles, supplier
|
||||
isolation, normal and rework paths, processor restart recovery. Record `business-verified` with the candidate digest and
|
||||
the config diff.
|
||||
5. Archive: `mongodump`, reports and config diff pulled to
|
||||
`local-data/internal-test-lane/batches/<batch-id>/`. Keep the latest 3 batches plus the
|
||||
current one; older local outputs are removed only after preview and confirmation. Cluster-side
|
||||
cleanup is a separate approved list.
|
||||
|
||||
Any phase can end in `failed` or `outcome-unknown`: stop new work, archive with that state kept,
|
||||
never mark the batch `business-verified`, and start over with a new batch.
|
||||
|
||||
## Promotion
|
||||
|
||||
- `release.py` takes an explicit policy; without one it keeps today's Fanyu behaviour.
|
||||
- The Fanyu policy covers `droboticflow-api`, `droboticflow-annotation-processor` and
|
||||
`droboticflow-annotation-validator`. The worker is not touched; promotion is refused when the
|
||||
candidate differs from the production worker's build commit under `internal/worker` or
|
||||
`cmd/worker`. Shared-package compatibility with the old worker stays a change-safety review item.
|
||||
- The Fanyu policy's `annotation-delivery` becomes `annotation-results` (satisfiable by a batch) and
|
||||
`delivery-packaging` (a packaging test record, or `release.py`'s own check that the policy-declared
|
||||
delivery-input paths are unchanged between the production API commit and the candidate).
|
||||
- A test-lane report counts as evidence only if its candidate digest equals the release image
|
||||
digest, the batch is `business-verified`, and every scenario the requested check needs is present
|
||||
and `passed` (mapping in ticket 11). For the rehearsal part of `change-safety`, `baselineImage`
|
||||
must also equal each covered Deployment's `before` image in the release plan; Deployments with a
|
||||
different starting digest are listed as not covered. Evidence the batch cannot produce stays
|
||||
unverified.
|
||||
- After promotion, the production smoke runs in the frozen internal organization and by default
|
||||
writes no customer data. Some GETs write (task detail recovery, frame-range index on a cache miss),
|
||||
so endpoints are classified by server-side effect, possible writes are confined to
|
||||
internal-organization objects and listed in the report. A write smoke runs only when the candidate changes claim, slicing, submission or
|
||||
review write paths, approved each time, on remaining internal tasks only. Customer tasks are
|
||||
never used and internal tasks are never replenished automatically.
|
||||
|
||||
## Run sequence (each step approved separately)
|
||||
|
||||
1. Pull the newest backup (name and date shown) into a new local container, select samples, user
|
||||
confirms the list.
|
||||
2. Download the confirmed samples from BOS, read-only.
|
||||
3. Build the candidate API image from a clean dev-mainline worktree and push it to the company
|
||||
registry.
|
||||
4. Test-namespace writes: quota, node directory, PVs/PVCs, Mongo, upload, seed, delete the
|
||||
initializer. Re-verify the cluster and namespace UID first.
|
||||
5. Start on the production digest, create in-flight state, upgrade, verify, record evidence.
|
||||
6. Promote with `release.py` prepare → check → plan → approval → deploy → verify, then run the
|
||||
production smoke.
|
||||
|
||||
## Verification seams
|
||||
|
||||
- Public-boundary tests for the renderer, lifecycle CLI, seed planner and `release.py`
|
||||
(simulated Kubernetes, as today).
|
||||
- Local end-to-end on a fresh Mongo port and API port (not 27017/27018/3001): a v2 bundle from
|
||||
synthetic media, two suppliers, five roles, baseline → candidate upgrade, and a verifier report
|
||||
bound to the digest.
|
||||
- Cluster behaviour (local PV binding on `.4`, port-forward under Cilium default-deny, quota)
|
||||
stays unverified until run-sequence step 4 is approved.
|
||||
|
||||
## Tickets
|
||||
|
||||
[06](issues/06-renderer-local-node.md) ·
|
||||
[07](issues/07-runtime-config-parity.md) ·
|
||||
[08](issues/08-bundle-seed-v2.md) ·
|
||||
[09](issues/09-backup-sample-export.md) ·
|
||||
[10](issues/10-release-policy-scope.md) ·
|
||||
[11](issues/11-release-evidence-binding.md) ·
|
||||
[12](issues/12-cluster-http-verifier.md) ·
|
||||
[13](issues/13-upgrade-rehearsal.md) ·
|
||||
[14](issues/14-production-smoke.md) ·
|
||||
[15](issues/15-batch-archive.md)
|
||||
|
||||
Existing [05](issues/05-movi-smoke-and-sl3-evidence.md) (movi direct-playback smoke, deferred by the user)
|
||||
fits this environment once it is deployed: it has no movi service.
|
||||
|
||||
## 2026-09-27 baseline (implemented; superseded where it conflicts)
|
||||
|
||||
Status: implemented 2026-09-27 (local synthetic verification); 2026-10-12 drift catch-up re-verified (suites + five-role HTTP flow; movi browser smoke pending), see verification.md new section and final section
|
||||
Baseline: 17e7de7e (implementation); drift-reviewed 2026-10-12 at 5a956624
|
||||
@ -9,7 +171,7 @@ The current turn authorizes local implementation and synthetic validation only:
|
||||
no customer database, BOS assets, production deployment or live credentials are accessed.
|
||||
Actual cluster provisioning and the six real sample transfers remain separately approved operations.
|
||||
|
||||
## User-facing outcome
|
||||
### User-facing outcome
|
||||
|
||||
An internal developer can prepare a small, independently runnable environment
|
||||
using the same application/business UI, five isolated role accounts and a fixed
|
||||
@ -17,7 +179,7 @@ six-source sample pack (three BLF-data, three SL-data). They can reproduce a
|
||||
known state or start from slicing, archive results and explicitly prepare the
|
||||
next batch/version without putting customer work into a test queue.
|
||||
|
||||
## Delivery components
|
||||
### Delivery components
|
||||
|
||||
1. Offline environment renderer and configuration validation. Fixed test namespace,
|
||||
distinct host, authenticated dedicated Mongo, per-batch database and PVCs,
|
||||
@ -35,7 +197,7 @@ next batch/version without putting customer work into a test queue.
|
||||
prepared, seeded and business-verified states; no claim of deployed/accepted
|
||||
solely because manifests were rendered or records inserted.
|
||||
|
||||
## Explicit behavior
|
||||
### Explicit behavior
|
||||
|
||||
- Test supplier `test`; platform admin plus supplier manager, annotator, quality
|
||||
reviewer and acceptance reviewer. Customer identities are not cloned.
|
||||
@ -66,7 +228,7 @@ next batch/version without putting customer work into a test queue.
|
||||
- Same immutable app image is used for eventual promotion, with production runtime
|
||||
settings retained. Candidate success does not authorize production release.
|
||||
|
||||
## Confirmed verification seams
|
||||
### Confirmed verification seams
|
||||
|
||||
The user explicitly accepted these on 2026-09-27:
|
||||
|
||||
@ -79,7 +241,7 @@ typecheck/build, then full relevant suites at the end. Review against baseline
|
||||
17e7de7e along standards and specification axes. Existing full-suite failures
|
||||
must be reported separately; do not claim a wholly green repository.
|
||||
|
||||
## Current-turn acceptance
|
||||
### Current-turn acceptance
|
||||
|
||||
Local commands, manifests, initialization, lifecycle and synthetic workflow evidence
|
||||
are runnable and documented. No company access is required to demonstrate refusal
|
||||
@ -87,7 +249,7 @@ checks and business behavior. Real sample inventory, exact company allocation,
|
||||
external ingress/storage prerequisites, cluster deployment and capacity validation
|
||||
remain explicitly unverified until separately authorized; do not fabricate them.
|
||||
|
||||
## 2026-10-12 漂移复核与追进度工单(用户批准落档)
|
||||
### 2026-10-12 漂移复核与追进度工单(用户批准落档)
|
||||
|
||||
9-27 实现完整存在且未被后续演进破坏:Go 包测试 2026-10-12 重跑全绿(`go test ./internal/testlane/...`),种子命令 `cmd/internal-test-seed` 与 `scripts/internal_test_lane.py` 冒烟正常,五角色账号模型与当前 `internal/api/auth.go` 服务端校验完全一致;实现后零维护提交、零破坏。但距验证基线 `17e7de7e` 约 174 个提交已进入主线,差距如下:
|
||||
|
||||
|
||||
32
.scratch/mongo-cpu/spec.md
Normal file
32
.scratch/mongo-cpu/spec.md
Normal file
@ -0,0 +1,32 @@
|
||||
# Independent query store for fixed-source Mongo CPU
|
||||
|
||||
Status: claimed
|
||||
Type: task
|
||||
Base: 8b33f38e
|
||||
Branch: codex/mongo-cpu
|
||||
|
||||
## Approved outcome
|
||||
|
||||
Existing Mongo remains authority for annotation, slicing, submission, quality review, final acceptance, permissions and version checks. An independent query Mongo owns thin query facts, projection progress, background aggregation and shared results; Valkey misses read that database. Move counts, dashboards and work records first, then task-pool lists. Production stays unchanged until separate approvals and verified evidence.
|
||||
|
||||
## Capability evidence
|
||||
|
||||
2026-11-12: bounded metadata-only probe against Fanyu's existing API Mongo configuration through an existing pod memory relay: maxWireVersion 25, sessions available, no exposed replica-set/router capability; opening the empty-filter change stream returns classified unsupported-topology (40573). No files were installed in cluster and no customer record was read or written. Sanitized report: local-data/diagnostics/mongo-cpu/cdc-capability-relay.json. Do not infer physical database topology beyond this entry point. Direct host connectivity failed separately and is not CDC evidence.
|
||||
|
||||
## Implementation contract
|
||||
|
||||
- Source adapter atomically tags query-relevant writes in the same document. Default off. Meaningless draft/log/version-only changes do not require repeated projection cycles. Existing filters, business versions and ownership checks remain intact.
|
||||
- No cross-cluster or source multi-document transaction assumption. Hard deletion uses durable per-operation intents and cancellable per-record claims; recovery must not guess from timestamps or restore deleted/old annotation snapshots.
|
||||
- Source dirty reads use small explicit indexes and bounded batches. Each projection is durable/idempotent before source marker acknowledgment; acknowledgment is conditional on the exact source revision. Restart resumes a persisted one-time bootstrap checkpoint, then polls only dirty records. No full source scan per browser query or periodic report build.
|
||||
- The read database receives allowlisted metadata/facts only, excluding annotations, descriptions, opinion text, media, passwords, tokens and signed links. Preserve legacy fact interpretation and exact statistics reducers.
|
||||
- Query read selection applies only to nominated GET paths. Authentication, current authorization, source task detail, command validation, claim CAS and workflow workers remain on authority. No stale permission grants; use authoritative page checks and pending visibility exclusions where needed.
|
||||
- Target health/coverage/version are checked before serving. Cache failure reads the query store; target failure cannot cause a full-source fallback storm. Existing tasks remain operable through authority. Old paths stay available behind an explicit rollback switch.
|
||||
- Count/list matching, pagination and server-shipped canClaim preserve existing contracts. Counts use a stated projection watermark; actual claim/decision is authoritative. Missing/incomplete data must not become zero or silently drop tasks.
|
||||
|
||||
## Validation
|
||||
|
||||
Real isolated source standalone + separate query replica set; atomic tagging, no-op suppression, deletes, delete/submit concurrency, old jobs, duplicate/out-of-order processing, restart, bootstrap races, cache/query-store loss, permission revocation and legacy data. Reuse original reducers and original read path for exhaustive result comparisons. Measure original source CPU/commands/bytes/scans including projection and acknowledgment load, plus query latency and new services' resources. Test 81 then 200/500 actors and larger history; label actual resource constraints, do not turn an uncapped native run into a 4-core capacity promise. Formal release gates follow integration to synchronized dev, never from this unmerged worktree.
|
||||
|
||||
## State
|
||||
|
||||
Local implementation complete on codex/mongo-cpu; default off. CDC verified read-only. Thin report/history/count reads, Valkey and subsequently pool candidates are connected to the independent query database. All authority mutations and permissions/CAS stay on source. New Mongo/Valkey/race/contracts pass; original work-availability and browser regressions pass. Bounded count-path comparisons show source offload, but full HTTP/mixed workload, write amplification, long steady-state and independent resource capacity remain unaccepted. Formal task check retains failures/skips/mapping gaps and a scheduler-concurrency anomaly is recorded, not silently dismissed. See verification.md. No source/cluster indexes or customer data changed; no push, PR, merge or release authorized/performed.
|
||||
79
.scratch/mongo-cpu/verification.md
Normal file
79
.scratch/mongo-cpu/verification.md
Normal file
@ -0,0 +1,79 @@
|
||||
# mongo-cpu verification — 2026-11-12
|
||||
|
||||
Status: claimed
|
||||
Type: task
|
||||
Base: 8b33f38e59d20ea13855c75b68973a78cf74de20
|
||||
Branch: codex/mongo-cpu
|
||||
Scope: isolated synthetic data only; production metadata-only CDC probe.
|
||||
Production acceptance: NOT complete. All production changes remain unauthorized/unperformed.
|
||||
|
||||
## Passed
|
||||
|
||||
- Freshness: `local-data/diagnostics/mongo-cpu/freshness-final.log`; contains origin/dev and live commit.
|
||||
- CDC: `cdc-capability-relay.json` in the same directory. Current entry returns unsupported topology40573, sessions available, no exposed set/router. No customer content copied.
|
||||
- Final dedicated module: `final-replica-gate-6.log`, raw `local-data/query-replica-local/logs/check-c139e638e31c49b2a16aa92bc039aaea.log`. Real source standalone/query RS/Valkey, race detector; no missing, skipped or changed-source cases. Includes old writer repair, revision reset, deletion/lease fences, null/mixed IDs, idempotent receipts, pending filtered/blind counts, source ACL revocation, self-review, configuration fail-closed and healthy independent fact routing.
|
||||
- Source business contracts with tracking enabled: supplier management/deletion, acceptance authorization/revocation, latest progress; production indexes retained. Adapter supplies missing synthetic source keys on fixture inserts/claims, without changing production methods or assertions.
|
||||
- Task-level original work availability core/Mongo/advisory browser/recovery: passed. Task browser searches, task transport, slicing/rework, deleted-annotator recovery, dashboard presentation/refresh/stability and original query-serving real components passed.
|
||||
- Additional exact Mongo cases: `additional-mongo-contracts.log`, all passed. Platform inventory fixture now includes42 real source tasks plus an orphan that must remain excluded; no business gate weakened. Trace, index migration, latest progress and supplier pool conversion passed.
|
||||
- Final Go baseline: `go-baseline-final-2/summary.json`:68 failures, all70-entry existing baseline, zero new. Original base exported read-only (not a Git worktree) also passed the same baseline gate: `go-base-8b33/summary.json`. Never changed known-failures.json.
|
||||
- Python compatibility: `python-compatibility-final.log`:37 passed. Four materialization cases still skipped without their Go fixture context, not counted as passed.
|
||||
|
||||
## Original failures retained
|
||||
|
||||
- `verify-task-final.log` / `local-data/test-results/verify-1794504930660420000/report.json`:47 passed,3 incomplete,3 failed, source unchanged. Missing pytest was rerun with existing root venv. Inventory fixture failure was corrected and exact cases passed. Productionstats failures are in the Go known-failure baseline. Optional external coverage/mapping gaps are not declared green.
|
||||
- `verify-quick-final.log`: sandboxed Node lifecycle check timed out; identical selected frontend command passed in the elevated task gate. No claim that the initial quick run passed.
|
||||
- Dedicated attempts3/4: older generic fixtures lacked unique source keys. Production unique indexes were retained; synthetic fixture adapter corrected identity on both insert and claim. Attempt5: best-effort shared-cache hit assertion failed once under concurrent verification; final complete run passed unchanged. Cache outage correctness passed throughout; keep transient hit failure for sustained-load follow-up.
|
||||
- `go-baseline-final/summary.json`: one additional Worker concurrent dispatch failure. `worker-concurrency-repeat.log` reproduced it with memory fixtures; base narrow20/200 runs passed, but the unchanged base under race detection reproduced the same failure (`worker-concurrency-base-race.log`). Full final gate passed. This verifies the anomaly also exists at the task baseline; no scheduler code or baseline was changed. Its root cause remains uncorrected and must be tracked before production acceptance.
|
||||
|
||||
## Bounded performance only
|
||||
|
||||
Dataset26218 synthetic tasks; same existing read indexes both sides, source pending checks and marker/ack traffic included. No customer data. Native runs had no CPU/RSS quotas. Docker has source4CPU/4GiB and query4CPU/8GiB declared limits but the entire VM has only4CPU/~6GiB, so it is not an independent8CPU/12GiB environment.
|
||||
|
||||
Fixed-resource raw artifact: `local-data/diagnostics/mongo-cpu/scale/20261112T172715.078381000Z/report.json` (`complete:false`).
|
||||
|
||||
| All-project actors | Authority p95 ms / errors | New path p95 ms / errors | Source CPU-seconds before / after |
|
||||
| ------------------ | ------------------------- | ------------------------ | --------------------------------- |
|
||||
| 81 | 6462 /45 | 259 /0 | 22.568 /0.046 |
|
||||
| 200 | 21465 /83 | 348 /0 | 74.893 /0.066 |
|
||||
| 500 | 64638 /247 | 547 /0 | 222.933 /0.197 |
|
||||
|
||||
These are storage-count visitors, not full HTTP or complete workflows. Original baseline failures make the combined comparison test FAIL; never mark it as accepted. Optimized counts match the complete fixture. Old timeout-truncated replies cannot support a strict end-to-end reduction percentage. Source CPU/bytes do decrease in this measured path; no production total CPU/EIP claim.
|
||||
|
||||
## Remaining / next gate
|
||||
|
||||
1. Resolve/reproduce the Worker concurrency anomaly and remaining external task mapping/fixture gaps; keep failed logs.
|
||||
2. Dedicated independent Linux source4CPU + separately provisioned query/worker/cache resources, exact version/fixtures/index/compression/request script. Full HTTP role/permission parity, cold and warm counts, all-project search/list, dashboards and work records.
|
||||
3.81/200/500 actors, three long steady-state rounds, writes/submission and incremental/delete/reconciliation cost included. Record source and target CPU/RSS/IO/scans/bytes, API latency/errors, lag, cache loss, backlog and restart. New500-actor count p95547ms still exceeds the proposed warm500ms goal in this constrained short test.
|
||||
3. Inventory production writers and index sizes before any source tagging/copy.47 potential new source indexes need a specific cost/rollback plan and explicit authorization. No indexes created in company Mongo.
|
||||
4. Only after result/permission correctness, source total load reduction and speed targets pass: integrate to dev, synchronize with approval, then prepare a separately authorized release through release.py. Do not release the worktree branch or treat Pod readiness as acceptance.
|
||||
|
||||
## Final query configuration/recovery follow-up
|
||||
|
||||
- Source database and QUERY_SERVING_NAMESPACE are pinned in target control metadata; a different logical source/namespace cannot reuse checkpoints or take over existing facts. This does not claim physical identity across clones that deliberately reuse both settings; topology verification and disaster-recovery planning remain required.
|
||||
- A cold, temporarily disconnected query client is retained. A cancelable single verifier retries at most once per second, so startup degradation self-recovers without replacing the API reader or scanning authority history. Initialization/readiness failure never becomes a zero report or a core-work gate.
|
||||
- Full dedicated final suite: `final-replica-complete.log`, raw `local-data/query-replica-local/logs/check-26b729daec844d87afd55c4b9ff5cfcc.log`; no missing/skipped/changed inputs, race detector enabled. Includes real gated-network failure followed by successful automatic recovery, correct environment routing and wrong-authority/namespace rejection.
|
||||
- Cross-module integration: `verify-integration-final.log`, `local-data/test-results/verify-1794506801679137000/report.json`:47 passed,2 incomplete,1 failed, inputs unchanged. All six integration checks passed (web lint, full format, frontend baseline, Go baseline, build, production artifact boot). Overall remains failed because raw productionstats tests have known failures and optional Mongo/worker cases/mapping gaps remain incomplete. Binding/cold-start additions followed this run and have separate final dedicated evidence; do not present the earlier whole-repo fingerprint as final-code release approval.
|
||||
- `isolated-capacity-plan.md` and sanitized cluster node/PV inventories are in the ignored diagnostics folder. No suitable unused database PV is established. Storage choice is pending; no company resources or production indexes/data were changed.
|
||||
|
||||
## Final metadata-stampede fix and repeated comparison
|
||||
|
||||
- Final-code attempt `scale/20261112T184107.767161000Z/report.json` exposed70 new-path one-project500 failures with generic not-ready errors. It remains retained, not replaced or accepted. The per-request200ms readiness probe was too fragile during the burst.
|
||||
- Fixed by sharing only an in-flight readiness fetch via singleflight, with a bounded independent producer and per-caller cancellation. No readiness TTL, data truncation, permission cache or source-history fallback added.100 simultaneous waiters execute exactly one real Mongo find. Full module/race/contracts passed: `final-replica-watermark.log`, raw `local-data/query-replica-local/logs/check-a5cd98306e064edfb491fbc23394459e.log`.
|
||||
- Same dataset/resources/indexes/script after fix: `scale-watermark-final.log`, immutable `scale/20261112T184936.001112000Z/report.json` and raw `local-data/query-replica-local/logs/check-da9d072b74ed4ea8aad7c1b4cb13f66c.log`. Source fingerprint unchanged during run. All six new-path phases have zero errors; fixture counts exact. Combined test still FAILS because old-path phases time out. This is not production acceptance.
|
||||
|
||||
| Scope/actors | Old p95 ms / errors | Final new p95 ms / errors | Source CPU-seconds old / new | Source reply bytes old / new |
|
||||
| ------------ | ------------------- | ------------------------- | ---------------------------- | ---------------------------- |
|
||||
| Single81 | 1294 /0 | 107 /0 | 4.8454 /0.0269 | 44185088 /37012 |
|
||||
| Single200 | 2889 /0 | 173 /0 | 10.6156 /0.0548 | 109099010 /84018 |
|
||||
| Single500 | 6644 /57 | 330 /0 | 24.3211 /0.1377 | 241654452 /202518 |
|
||||
| All81 | 7039 /39 | 203 /0 | 25.1073 /0.0288 | 554784076 /37012 |
|
||||
| All200 | 21159 /83 | 328 /0 | 74.6761 /0.0693 | 1524127176 /84018 |
|
||||
| All500 | 63608 /187 | 528 /0 | 221.024 /0.1497 | 4087040050 /202518 |
|
||||
|
||||
Single-project81 source commands243→268: small indexed checks can increase command count while dramatically reducing read volume/CPU. Do not claim every metric decreases. Go client/native host and shared4CPU/~6GiB Docker VM constraints remain; no HTTP/auth/full workflow or source total steady-state CPU claim. Final all-project500 p95528ms still exceeds warm500ms target.
|
||||
|
||||
Final Go gate after watermark coalescing: `go-watermark-final/summary.json`,68 existing failures,0 new. Changed Go files were explicitly checked with gofmt; new YAML/Markdown/JSON were checked by path (`format-delivery.log`). The frontend-only npm formatting gate passed separately (`format-staged-final.log`); it is not treated as backend-format coverage. Source freshness before delivery: `freshness-delivery.log`, includes origin/dev and live.
|
||||
|
||||
The dedicated replica Docker lab is stopped after verification with named volumes preserved; `python3 scripts/test_query_replica.py --auto` restarts it. Existing27017/27018/27019 services and protected worktrees are not cleaned/reset by this task. No push, PR, dev merge or deployment was performed.
|
||||
|
||||
Local implementation commit:708b9bae. Feature switches remain default OFF; branch has not been merged into dev or pushed. The source namespace/source writer/source index and independent SSD prerequisites remain in the documented acceptance plan, not applied changes.
|
||||
30
.scratch/mongo-cpu/work.md
Normal file
30
.scratch/mongo-cpu/work.md
Normal file
@ -0,0 +1,30 @@
|
||||
# mongo-cpu worktree
|
||||
|
||||
Status: claimed
|
||||
Type: task
|
||||
Owner: Codex
|
||||
Branch: codex/mongo-cpu
|
||||
Base: 8b33f38e59d20ea13855c75b68973a78cf74de20 (fresh dev; contains origin/dev and live)
|
||||
Worktree: local-data/worktrees/mongo-cpu
|
||||
|
||||
用户明确授权独立worktree mongo-cpu。先只读核实公司Mongo CDC;再实现独立查询Mongo、可靠增量同步,优先计数/看板/作业记录,随后任务池列表。复用既有Valkey与Typesense可选模块。源Mongo仍掌管标注、切片、送检、质检、最终验收、权限与版本;不改客户记录。
|
||||
|
||||
文件域:查询存储适配、CDC/投影后台、统计与计数/列表读路径、配置及本地隔离验证、运维文档。保护dev原有两项admin测试和旧发布笔记。
|
||||
|
||||
回归与减负验证通过后在本分支本地提交,报告证据与未验证范围;回dev集成、推送、PR、公司部署及生产数据/索引写入按后续明确授权执行。只读CDC探测不写客户数据、不开新生产服务。
|
||||
|
||||
先前原库物化版本两轮持续对照通过,第三轮因转入独立读库实施而中止,不作为完整验收。
|
||||
|
||||
## Current evidence
|
||||
|
||||
Local read-replica implementation and scoped regressions complete; capacity verification remains pending. Keep this worktree and isolated source/query lab for follow-up. Source and query feature switches stay OFF in production. Merge-back only after remaining acceptance and explicit integration request; never release this unmerged branch directly. See [verification](verification.md) for passing, failed and pending evidence.
|
||||
|
||||
## Storage selection follow-up
|
||||
|
||||
The earlier new-cloud-disk selection is paused by the latest user instruction: inspect existing node capacity/type/IO and prefer reuse, with no purchase. The disabled CDS proposal remains for comparison only. Read-only audit found 136.3/86.9/200.1Gi available on three shared root disks, low IO during a 30-second sample, and no visible root quota mount options. Underlying SSD/HDD SKU is unknown. Node .4 is the preferred candidate for a bounded 20–30Gi synthetic pilot, conditional on capacity/IO safeguards and peak observation; no database, PV, Pod, mount or production-data changes performed. See docs/operations/query-replica-node-disk-audit.md. Long-running capacity and workflow acceptance remain pending.
|
||||
|
||||
User selected node .4 and authorized a synthetic 20–30Gi pilot only after isolation is confirmed. Read-only follow-up confirms kernel 5.15/cgroup v2 and io delegation under kubepods.slice, but no configured hard capacity or validated per-pilot IO enforcement. Drafted docs/operations/query-replica-node4-isolation-plan.md with a 25Gi fixed-filesystem candidate and scoped cgroup limits, explicit loop/writeback proof and restart requirements. Local-only tests passed: 256Mi EXT4/tmpfs ENOSPC with unchanged backing-file size; 16Mi direct and buffered+fdatasync writes through loop at a configured 1MiB/s took 16.06/16.07 seconds; remount retained file size. Local kernel is 6.8, production 5.15, runtime management differs. No cluster writes or database started. Startup/recreation enforcement, IOPS/read caps, peak baseline, guarded node smoke and Mongo recovery remain pending; do not treat local proof as production isolation acceptance.
|
||||
|
||||
Subsequent user authorization explicitly covers node .4 small synthetic tests. Created only the dedicated query-lab namespace/quota/deny-all policy/ConfigMap and512Mi test filesystem. No production data/application deployment changed. The original host path match was fixed for Pod mount-namespace changes. DirectIO did not satisfy buffered write throttling; stopped and retained failures. Global PSI also included throttled test waiting; protection additionally measures existing Pod PSI and physical latency rather than treating global PSI as business impact. Dual loop+physical-disk controls also FAILED buffered write enforcement (run-6):4Mi direct4.011s, buffered+fdatasync0.008s, buffered bytes not charged to target Pod. All test Pods stopped;512Mi image/mount retained.25Gi uncreated. Mongo cross-Pod data and full-disk recovery deliberately not executed after IO failure. Existing readiness/Pod-pressure sampling showed no deterioration within this short window. See docs/operations/query-replica-node4-smoke-results.md. All source/query feature switches remain OFF; do not deploy this loop approach or describe the failed suite as capacity acceptance.
|
||||
|
||||
Latest follow-up supersedes the failed-configuration conclusion above. Synced live dev5c6023ec into this branch (merge5e4de799), preserving both verification mappings. A1Mi random-data differential proved old inode writeback escaped the new Pod, while new loop inodes and native EXT4 controls were limited. Normal unmount/rebind of only the exact-owned idle filesystem restored all four cases (~1s/Mi); no reformat/forced unmount/global cache changes. Full512Mi suite passed BPS/IOPS before/after Pod replacement, preserved journal-acknowledged data, and recovered from filesystem ENOSPC without deleting Mongo files. Then, under the user's conditional authorization, created a distinct25Gi synthetic single-member replica set on .4,1CPU/1Gi, loopback only/no Service, dual IO caps and75Gi free-space guard. A majority+journaled marker survived another Pod replacement. Running Pod node4-query25 (UID19f5f918-9bb1-4e6a-a362-bb70afacee26) has a6h deadline ending2026-11-13T09:47:06Z; file remains after stop. Production Pod identities/restarts and protected IO pressure unchanged in sampled window. Source/read feature flags still OFF; no original Mongo projection/sync or capacity acceptance claimed. Evidence: node4-smoke/attribution-\*, recovery-remount/, query25/. No purchase or customer-data writes.
|
||||
34
.scratch/original-video-time/work.md
Normal file
34
.scratch/original-video-time/work.md
Normal file
@ -0,0 +1,34 @@
|
||||
# #19 原视频时间点
|
||||
|
||||
Status: resolved
|
||||
|
||||
目标:标注、质检、最终验收同时提供片内和原视频播放时间,供边界调整后定位核对。来源:2026-11-15 程晓明转一线反馈(position 590–591);客户承诺为「让研发加一下」。授权仅本地实现、验证、提交;推送及部署仍需章鸿铭明确授权。
|
||||
|
||||
基线:统一开发目录 recent-integration,dev / 230491b0。新鲜度脚本确认包含 origin/dev 与线上版本;#18 的 0a60d803、230491b0 已在当前 dev,保留同批交付。未新建分支或 worktree。主目录没有该新鲜度脚本,实际在统一开发目录执行成功。
|
||||
|
||||
## 方案和兼容范围
|
||||
|
||||
- 标注、质检共用 CaptureAnnotationWorkbench,片内时间为动作/播放坐标减去当前切片起点,原视频时间沿用已有 Capture 播放坐标。
|
||||
- 最终验收播放器使用片内逻辑时钟,原视频时间为当前切片冻结源起点加片内时间。acceptanceFullVideoWindow 是跨来源累计的观看进度,不能作为多来源的原视频时钟。每一来源独立归零;双目解码偏移及硬件 PTS 不替代业务播放时钟。
|
||||
- 播放栏、动作列表、编辑/只读动作详情和质检/验收右侧当前画面详情同步显示,使用「片内」「原视频」及毫秒精度。验收切片列表补充原视频范围。窄时间轴不增加会被裁切的第二行,已有悬浮信息补全原视频区间。
|
||||
- 对历史缺少映射的记录显示「原视频 —」。直接读取冻结切片的原始边界,避免 null 经 Number 转换后被误显示成零;原有验收检查和时间轴逻辑不变。
|
||||
- 仅前端展示,保存/API/Mongo/切片定义、审核意见坐标、送检和审核决定契约不变。无数据迁移、无客户写操作。MaterializedSliceWorkbench 当前无实际渲染入口,不扩展废弃入口。
|
||||
|
||||
负责文件:src/components/{CaptureAnnotationWorkbench,FinalAcceptanceWorkspace,AcceptanceActionTimeline,ReviewCaptions}.tsx、src/lib/annotation-time.js、scripts/verification-scopes.json、本需求新增测试及 tests/browser/acceptance-playback-rate.mjs。原有 AGENTS/docs/领取池 Go 测试及其他 .scratch 工作保持原样。
|
||||
|
||||
## 验证范围和证据
|
||||
|
||||
入口已执行 verify:plan 和 verify:task --plan,基线均为 230491b0。共享树含他人领取池变更,因此 quick 使用同一 scripts/verify-change.py 执行器,显式限定上述负责文件;没有为本需求启动他人的 Go/数据库/生产负载检查。任务级选择显示相关浏览器专项;审核保存、权限和后端边界操作未改,不扩展到这些映射的数据库专项,不能将本报告当作整个平台或发布门禁全通过。
|
||||
|
||||
- 180 项定向前端/工具 Node 测试通过(含稳定原视频定位、跨来源时钟、空边界、#18 动作/播放和既有审核/保存逻辑);验证工具 Python 测试通过;lint:web 类型/架构检查及改动格式/diff 检查通过。quick 最终报告位置在 local-data/test-results/issue19/quick-final.log 中。
|
||||
- 标注/质检真实共享组件、本地合成视频:播放定位、动作列表、编辑/只读详情、当前画面详情;边界 5→3 后片内 1–2→3–4 秒,原视频保持 6–7 秒;无标注写入。日志 workbenches.log;截图 workbenches/{annotation,quality}.png。
|
||||
- 最终验收真实整页:native / movi / movi-fractional 三模式,每种 15 次切片变化;第二片片内 0 秒对应原视频 8 秒,列表/右侧详情与播放栏一致;倍速、短动作、舍弃切片、字幕、批注、只读、草稿失败、加载/空/错误状态、普通/深色窄屏和密集列表回归。日志 acceptance.log、acceptance/report.json 及其截图。
|
||||
- #18 时间轴鼠标拖动、普通点击、滚轮、独立滚动控件、末条自动可见,normal / focused / focused&readonly 通过;日志 timeline-pan.log。
|
||||
- 前端构建通过,保留既有 chunk 大小提示;本次早期 npm run build 全量构建也 exit 0。最终前端构建见 build-web-final.log。
|
||||
- 截图人工查看标注、质检和验收显示;夹具初次定位超时来自未实现 HTTP Range,补齐 Range 后实际定位与截图通过。没有因此修改播放器传输逻辑。
|
||||
|
||||
所有日志和截图位于忽略目录 local-data/test-results/issue19/。公司集群、BOS 及客户数据未写入。生产验证、生产业务接受、正式发布门禁和 120 人容量未执行,本需求不作这些承诺。
|
||||
|
||||
本地实现和本需求定向验证已就绪。最终 quick 报告:local-data/test-results/verify-1794808129484018000/report.json;180 项 Node 测试通过、22 项验证工具 Python 测试通过。最终浏览器三模式报告及前端构建通过,提交后运行 agent_status --no-fetch 核对分支。
|
||||
|
||||
下一步仅为授权后的交付:章鸿铭明确批准推送后将 #18 的 0a60d803、230491b0 与本需求提交同批推送;部署仍须独立明确授权及正式发布门禁。当前未推送、未部署,客户尚未使用本次显示变化。
|
||||
40
.scratch/platform-issues-20261110/validation.md
Normal file
40
.scratch/platform-issues-20261110/validation.md
Normal file
@ -0,0 +1,40 @@
|
||||
# 平台调优问题修复验证(2026-11-10)
|
||||
|
||||
Base: `0040988f`,统一 `dev` 工作区;未创建新分支。用户本轮授权本地逐项修复,未授权推送、部署或客户数据回写。
|
||||
|
||||
## 改动范围
|
||||
|
||||
| 问题 | 本地处置 | 仍需确认 |
|
||||
| --- | --- | --- |
|
||||
| 跨接口超时、送检锁竞争 | 整合 `404e40c0` 的安全锁释放和持久化有界重试,以及 `ae52e5d4` / `1ba3a0a6` 的检索、列表读取优化 | 发布后的真实请求效果;不把健康检查当成业务验收 |
|
||||
| 送检后标注疑似丢失 | 整合 `d1dc4a38`:归档失败输入、保护正式修订及返工工作区、阻断空白切片覆盖 | 历史内容未恢复;既有调查未找到完整最新快照,本轮不回写客户数据 |
|
||||
| 多人均为 12.1 小时 | 原始秒数不同,已确认是一位小数舍入;保留既有展示契约 | 不作为代码缺陷修改 |
|
||||
| 验收时间点打点缺失 | 转发来源、切片与时间基准;按当前切片映射;补全 mediaOnly 的标记层,复用聚合与跳转逻辑 | 发布后业务验收 |
|
||||
| 看板刷新跳动 | 同查询刷新沿用更新时间行显示状态,取消重复占位;失败仍清除旧值并报错 | 发布后业务验收 |
|
||||
| 跨账号汇总不同 | 选定人员/角色时统一顶部、供应商及人员归属,保留组织/供应商/本人约束 | 发布后同快照对账 |
|
||||
| 18 段约 2.35 小时 | 原附件实际显示 BLF-data、首次送检 10/10–11/09、通过 1.2 小时;此前 2.49 来自另一范围,不能混为同一差额 | 原 18 段清单缺失,已请求补充;不通过调整公式凑数 |
|
||||
|
||||
## 已有证据
|
||||
|
||||
- 跨账号回归在旧实现失败(管理员选验收员得到 0),修复后单元与 API 同快照对照通过;覆盖供应商隔离、不同角色、重复通过去重。
|
||||
- 刷新浏览器在旧实现位移 67.5px,修复后 0px;看板和卡片没有重新挂载。合成 API 与账号,未写客户数据。
|
||||
- 验收浏览器 native / movi / movi-fractional 三模式通过:保存后标记可见、点击跳转、换片不串点、刷新/重新进入后恢复、只读和加载失败禁写。
|
||||
- 界面已查看本地合成截图:验收标记、刷新中看板。正常状态无新增说明栏,错误仍可见。
|
||||
- 原始记录与命令日志位于忽略目录 `local-data/`;不在此保存凭证或客户标注正文。
|
||||
|
||||
## 最终验证
|
||||
|
||||
- 整批 `npm run verify:task -- --base 0040988f --budget-seconds 1800` 记录:`local-data/test-results/verify-1794315714569782000/report.json`。初始结果 31 passed / 3 failed / 2 incomplete,且过程中修改过统计代码;该报告本身不作为“整批全绿”证据。
|
||||
- 三项首次失败已分别补证:管理员任务池原命令复跑通过(`local-data/admin-pool-browser-recheck.log`);刷新测试断言修正后,位移为 0px、失败清空旧值及恢复通过(`local-data/dashboard-refresh-final.log`);切片夹具补齐媒体引用、真实 validator 校验和当前“恢复”文案后,6 类编辑/撤销恢复场景通过(`local-data/slice-phase-final.log`)。没有放宽产品校验。
|
||||
- 最终统计逻辑:`go test ./internal/workforcestats ./internal/api -run TestProductionQuality -count=1` 通过(`local-data/statistics-final-tests.log`)。顶部、供应商及人员使用同一累加入口,不再复制本人归因逻辑。
|
||||
- 最终统计代码另跑 `python3 scripts/test_dashboard_stability.py`:race、timing 阶段 required 全通过,skipped 为空。5000 part / 4 API handler / 121 次暖查询,p95 59ms,未触发源事实重建(`local-data/platform-fixes-final-stability.log`)。这是本地合成验证,不是生产容量承诺。
|
||||
- 最终 `npm run test:browser:dashboard`:admin / manager / u1 / qc / acceptor 五角色、空数据、筛选、失败与恢复通过,无异常写入和页面错误(`local-data/platform-fixes-final-dashboard.log`)。验收三播放器模式与重载后的标记显示/导航见 `local-data/test-results/acceptance-playback-rate/report.json`。
|
||||
- 数据库专项:任务池 Mongo 旧数据、权限、分页、覆盖投影、大载荷;送检恢复事件持久化与隐私;锁取消、未开始操作释放、已开始且结果未知保持保护、进程崩溃恢复及旧 worker fencing 均通过。见整批报告 13、16、17、25、30、31、32 日志。
|
||||
- 81 人读取混合冒烟:975 requests / 0 errors(整批 `29.log`)。检索性能的原三轮对照沿用未修改实现的 `docs/operations/acceptance-search-v2.md` 证据;本次组合后的短冒烟不冒充完整持续容量验收。
|
||||
- 按集成计划补齐格式、前端基线门禁、生产构建和启动检查;Go 门禁在最终统计重构后复跑。前端 13 个失败均在既有 14 项基线内;Go 68 个失败均在既有 70 项基线内,没有新增失败,不修改基线。日志:`local-data/platform-fixes-{format,frontend-gate,build,boot}.log`、`local-data/platform-fixes-final-go-gate.log`。
|
||||
- 验证映射 tooling 22 项通过(`local-data/platform-fixes-tooling.log`)。整批 store 默认运行中被跳过的其他 opt-in / replica-set 场景保留为未覆盖,不声称全库测试全部执行;本批相关 Mongo 路径已显式开启通过。推送、公司部署、客户数据回写、120 人长期容量及生产业务验收均未进行。
|
||||
- 最终源文件摘要、基线与补充日志索引:忽略目录 `local-data/platform-fixes-evidence.json`。应用源码修改后重跑相应统计单元/API、race、时延及五角色浏览器验证,未将旧运行自动当作最终证据。
|
||||
|
||||
## 历史内容恢复边界
|
||||
|
||||
既有调查见 `../submission-loss-guard/validation.md` 的 Affected capture recovery:故障送检后发生普通切片生成与前置修订清理,旧 BOS 修订不可读,未取得完整最新返工快照。保留下来的打回基线不等于用户后来改好的内容。本次交付未来提交/重试保护,不声称已恢复历史丢失内容,不将旧基线写回当前任务。
|
||||
170
.scratch/poll-pool-optimization/readmix.md
Normal file
170
.scratch/poll-pool-optimization/readmix.md
Normal file
@ -0,0 +1,170 @@
|
||||
# Local polling and pool read-mix verification
|
||||
|
||||
This runner is an intermediate regression/performance smoke test, not the approved capacity acceptance test. It uses real API handlers and a unique synthetic database on loopback Mongo 27018. It never reads production credentials, connects to a remote Mongo, or writes the local snapshot database. The unique database is dropped on completion. Indexes come from each tested revision's `EnsureIndexes`.
|
||||
|
||||
## Run
|
||||
|
||||
From this worktree:
|
||||
|
||||
```sh
|
||||
python3 scripts/local/poll-pool-readmix.py \
|
||||
--baseline 80bdcee9 --authorization-state legacy --warmup 5 --duration 30 --repetitions 3 \
|
||||
--output local-data/test-results/readmix-v2-three-rounds
|
||||
```
|
||||
|
||||
Use a new output directory for every invocation. Baseline source is archived into a temporary directory; the same test harness is copied into it. The current checkout supplies candidate code, so keep it unchanged during a comparison. The runner pins and records both revision IDs, alternates execution order, retains logs/results and fails on HTTP errors, stable read-mix writes or returned-task-set differences.
|
||||
|
||||
Each variant receives the same deterministic fixture: two projects, three active suppliers, 60 annotators, 12 quality reviewers, eight acceptance reviewers and one administrator. Accounts use unique synthetic phone IDs. Workflows preserve distinct annotation, semantic review and acceptance stage definitions. Nonempty administrator work records, reviewer ownership/history and two-item annotation buffers are seeded. The varying deterministic payload is synthetic, not a measured production payload distribution.
|
||||
|
||||
## Requests and measurement
|
||||
|
||||
- Annotation buffer: every three seconds; legacy mode on baseline, explicit summary mode on candidate.
|
||||
- Quality pool: available/mine/reviewed with `quality_review,semantic_review`, every 12 seconds.
|
||||
- Acceptance pool: the same three views for each of `acceptance` and `prepackage_acceptance`, every 12 seconds.
|
||||
- Review groups alternate single-project and all-project queries. The fixture has owned/history work in prepackage acceptance; legacy acceptance mine/history are intentionally empty.
|
||||
- Administrator: workforce report every 12 seconds, including nonempty synthetic work records.
|
||||
- Polls begin together; this is a synchronized burst/read mix. The revised scheduler fixes the number of rounds, rather than allowing a race at the time-window boundary. With 30 measured seconds this produces exactly 855 requests per variant.
|
||||
|
||||
Reports contain per-request handler latency, status, item count and returned task-ID hash; endpoint p95/max; raw and gzip sizes; Mongo command count, cumulative command duration, reply bytes and write-command count; Go heap snapshots and allocation totals. Gzip uses the same Go default compression for both variants, measured separately from handler latency. CPU time spent computing gzip still shares the local process resources. Mongo cumulative command time overlaps across concurrent requests and is not wall-clock latency.
|
||||
|
||||
## Interpretation limits
|
||||
|
||||
No ingress, real authentication transport, WAN shaping, browser render cost, video, continuation renewal or editing/submission writes are included. The administrator cache may remain warm throughout a short run. The fixture does not reproduce a large historical dataset, all permission-restricted project combinations or deep pagination. Task-ID equality is a visibility check, not a substitute for the state/permission regression suite. Heap endpoints do not prove memory stability or Pod sizing; CPU throttling and scan execution plans are not collected yet.
|
||||
|
||||
Do not report `p95 <= 2s` from this smoke test as production acceptance. The approved baseline/stage-one/stage-two comparison, representative historical data, 5-minute warmup + 30-minute steady phase repeated three times, resource telemetry, cold entry and recovery cases remain outstanding. Increasing this runner's duration alone does not add the missing workload coverage.
|
||||
|
||||
## Three-round smoke result (2026-10-28)
|
||||
|
||||
Compared production baseline `80bdcee9` with candidate application code `a2eac93e`. Each round used 5 seconds warmup and 30 seconds measurement; this is **not** the planned 5/30-minute soak. Each variant completed 855 requests per round, 2,565 total. Both variants had zero HTTP errors and zero measured Mongo write commands. Returned task-ID sets matched for every actor/request in all three pairs. The administrator report had nonempty records.
|
||||
|
||||
The following values are the **median of the three per-round p95 values**, not the p95 of pooled samples:
|
||||
|
||||
| Request | Baseline | Candidate | Interpretation |
|
||||
| --- | ---: | ---: | --- |
|
||||
| Annotation buffer | 444.725 ms | 463.224 ms | 4.2% higher; latency improvement not demonstrated |
|
||||
| Quality, all projects, available | 610.761 ms | 549.923 ms | 10.0% lower; below the 50% relative goal |
|
||||
| Prepackage acceptance, all projects, available | 608.618 ms | 491.782 ms | 19.2% lower; below the 50% relative goal |
|
||||
|
||||
Buffer gzip averaged 38,844.6 bytes/request on baseline versus 306.7 on candidate, a 99.2% reduction on this synthetic two-task fixture. Pool-list gzip remained essentially unchanged. Mongo commands per round decreased from 13,304 to 10,820 (18.7%); Mongo reply bytes decreased from approximately 253.17 MB to 205.63 MB (18.8%). These count/byte improvements reproduced in all three rounds. They do not establish WAN capacity or Pod resource requirements.
|
||||
|
||||
Evidence is retained under `local-data/test-results/readmix-v2-three-rounds/`: six per-variant JSON/log pairs plus `comparison.json`. An earlier smoke run under `readmix-smoke/` had an empty administrator fixture and variable counts at the end boundary; it is retained as diagnostic history and is not the result above.
|
||||
|
||||
Next investigation: attribute the remaining list/authorization reads and waits under the same workload, add realistic run/history payloads and query-plan/CPU/throttling telemetry, then complete continuation and workflow-write load coverage before the long acceptance soak. Do not lower response limits or broaden permissions to reach latency targets.
|
||||
|
||||
|
||||
## Authorization-state correction
|
||||
|
||||
The original v2 results above used the **legacy/uninitialized supplier-project authorization path**. Normal Mongo startup migration calls `InitializeSupplierProjectAuthorizations`, so they must not be presented as normal migrated-environment results. The runner now defaults to `--authorization-state initialized`; choose `legacy` explicitly to retain the historical recovery case. Both variants receive the same selected state, and each report records it.
|
||||
|
||||
The opt-in Go test also records Mongo command count, returned bytes and cumulative duration grouped by endpoint/collection/command. It does not record query filters, command bodies or returned documents. `POLL_POOL_CPU_PROFILE` optionally captures a local Go CPU profile. These probes exist only in test code.
|
||||
|
||||
## User-scoped membership change (0a40cf32)
|
||||
|
||||
A red/green API regression demonstrated two full member-list calls before the fix and two user-scoped calls afterwards. Memory/Mongo equivalence tests retained duplicate historical records and organization/project/user boundaries; disabling an account was observed on the next request. The Go baseline gate had no new failures (68 existing failures).
|
||||
|
||||
For an isolated comparison of this change, both sides must use summaries:
|
||||
|
||||
```sh
|
||||
python3 scripts/local/poll-pool-readmix.py \
|
||||
--baseline 95aaabf1 --baseline-mode summary --authorization-state initialized \
|
||||
--warmup 5 --duration 30 --repetitions 1 \
|
||||
--output local-data/test-results/member-scope-summary-only
|
||||
```
|
||||
|
||||
Each side completed 855 requests with zero errors/writes and matching task-ID sets. Across the 600 buffer polls, member reply bytes decreased from 14,336,400 to 247,110 (98.3%). Total Mongo commands stayed at 9,380; total reply bytes decreased from approximately 178.92 MB to 162.02 MB. Buffer p95 was 348.547 → 386.892 ms; quality all-project available p95 was 627.107 → 466.025 ms; prepackage acceptance all-project available was 404.779 → 414.543 ms. This single short pair establishes reduced data reads and equivalent results, **not a dependable latency gain**.
|
||||
|
||||
The earlier `member-scope-initialized` and `member-scope-legacy` pairs verified compatibility but used legacy responses for their baseline, so their latency/total-byte deltas combine summary-response and member-filter changes. Do not attribute those combined deltas solely to member filtering. In the legacy pair, seed derivation still legitimately reads the whole membership set, so member bytes only decreased from 28.674 MB to 14.585 MB. No legacy authorization recovery path was removed.
|
||||
|
||||
Diagnostics are retained under `local-data/test-results/member-scope-diagnosis/`; the JSON contains counts/bytes/times, not query filters or documents. CPU sampling did not isolate JSON processing as the dominant cost. The next profiling target is large task-candidate reads: in the legacy profile, 12 quality all-project available reads returned about 44.6 MB before supplier/permission filtering. Reducing that cost requires dedicated result-equivalence tests before changing projection or query pushdown.
|
||||
|
||||
## Pool candidate projection, 2026-10-28
|
||||
|
||||
Code comparison: `b1e2113f` → `219bb75f`, both summary mode, initialized authorizations. Identical fixture/resources/compression, alternating order across three pairs, each 5s warmup + 30s measurement. Outputs: `local-data/test-results/pool-candidate-summary-only`. These are short local handler comparisons, not the planned 30-minute capacity gate.
|
||||
|
||||
- 855 requests per variant per pair (2,565 each total), matching actor/endpoint/task sets, zero HTTP errors and stable writes in all three pairs.
|
||||
- Mongo reply volume: approximately 162.02 MB → 105.65 MB (34.8% less). Commands: 9,380 → 9,584 (2.2% more, due to selected-row batch hydration). HTTP list payload contract is unchanged; this optimization targets Mongo-to-API reads, not client bandwidth.
|
||||
- Median of three per-round p95 values (ms):
|
||||
|
||||
| Endpoint | Before | After | Reduction |
|
||||
| --- | ---: | ---: | ---: |
|
||||
| Quality all-project available | 433.518 | 375.593 | 13.4% |
|
||||
| Quality single-project available | 244.164 | 218.513 | 10.5% |
|
||||
| Final acceptance all-project available | 400.657 | 295.427 | 26.3% |
|
||||
| Final acceptance single-project available | 227.269 | 194.958 | 14.2% |
|
||||
| Annotation buffer | 354.619 | 239.503 | 32.5% |
|
||||
|
||||
The buffer code was unchanged; its gain is under this shared read workload, not a separate buffer optimization. Pool relative reduction remains below the required 50%. Small-fixture sub-2s results do not establish production p95.
|
||||
|
||||
Total allocated bytes median: 2.236 GB → 2.085 GB (-6.7%). End-of-run heap snapshots varied with GC timing: baseline 5.69/7.91/7.17 MB, candidate 13.74/18.73/5.72 MB. Added post-GC heap and GC-cycle counters **outside the measured interval**, then reran one same-condition pair (`pool-candidate-retained-heap`). Post-GC heap: 4,620,584 → 4,343,336 bytes; allocated bytes: 2,261,101,816 → 2,105,492,632. No retained-object growth demonstrated by this spot check; no long-soak CPU/RSS/Pod-throttling conclusion is warranted. Both variants received the identical updated harness; application candidate remains `219bb75f`.
|
||||
|
||||
Go gate: 68 failures, all registered baseline cases; no new failures. Candidate projection equivalence passed MemoryStore and isolated loopback Mongo, including multi-page ordering. HTTP tests cover legacy read-strategy response equality and fresh fallback for assignment/project changes without version increments and for version changes. No production reads/writes, indexes, resources, push, PR or deployment in this step.
|
||||
|
||||
Next unresolved evidence: realistic large run/history fixtures and query scan/execution-plan costs, remaining display enrichment reads, mixed workflow failure/recovery and three full warmup/steady-state rounds. Keep release/capacity status pending.
|
||||
|
||||
## Batched run display metadata, 2026-10-29
|
||||
|
||||
Comparison: `2230a4d1` → `8cc5cfc0`, same summary mode and initialized authorizations. Added an explicit `--run-payload-kib 256` fixture variant: task-linked shared runs contain 256 KiB synthetic execution logs. The previous fixture had no item RunID and could not measure this path. Both sides receive the identical new harness; do not compare these absolute figures with earlier no-run fixtures. Output: `local-data/test-results/run-display-large-history`.
|
||||
|
||||
Three alternating-order pairs, each 5s warmup + 30s measurement: 855 requests per variant per pair, 2,565 each overall, identical task-ID sets, zero errors and stable writes. The workload is still a small synthetic handler read mix, excluding ingress, video, workflow writes, production-sized history distribution and a long soak. Repeated synthetic log text is not a production payload distribution.
|
||||
|
||||
- Run collection reads per round: 408 → 204; replies approximately 107.219 MB → 0.080 MB. Page-level deduplication and batch projection replace full execution records; legacy directory fallback remains available.
|
||||
- Total Mongo replies approximately 213.236 MB → 106.097 MB (-50.2%); commands 9,992 → 9,788 (-2.0%). These are database reads, not a claim that public HTTP bandwidth halved.
|
||||
- Median per-round p95 (ms):
|
||||
|
||||
| Endpoint | Before | After | Reduction |
|
||||
| --- | ---: | ---: | ---: |
|
||||
| Quality all-project available | 516.397 | 393.577 | 23.8% |
|
||||
| Quality single-project available | 270.925 | 218.891 | 19.2% |
|
||||
| Final acceptance all-project available | 468.745 | 321.369 | 31.4% |
|
||||
| Final acceptance single-project available | 250.961 | 191.428 | 23.7% |
|
||||
| Annotation buffer | 306.363 | 258.721 | 15.6% |
|
||||
|
||||
Median allocated bytes 2,297,159,936 → 2,095,265,576 (-8.8%). Post-GC heap baseline 4,696,664 / 4,683,360 / 4,663,008 bytes; candidate 4,446,392 / 4,449,056 / 4,682,784. No sustained increase in these short samples; this is not Pod RSS/throttling or long-run memory acceptance. Relative p95 reduction versus this immediate baseline remains below 50%; reductions across different fixtures must not be added.
|
||||
|
||||
Final Go gate: 68 known failures, no new failures. The first gate captured an incorrect legacy fixture expecting a newly inserted run to lack persisted capture directories; fixed the test to explicitly simulate a historical missing field, then reran the complete gate successfully. Tests cover name fallback, capture precedence, duplicated/missing run IDs, legacy artifact fallback, isolated Mongo projection with a 1 MiB run log, and full record availability. No new index, migration, long-lived cache, resource change, push, PR or deployment.
|
||||
|
||||
Remaining work: query execution-plan/scan measurements on representative large history, complete failure/recovery coverage, and the planned long three-phase capacity comparison. Current release/capacity status stays pending.
|
||||
|
||||
## Mine author-history filtering, 2026-10-29
|
||||
|
||||
Local explain probe: `POLL_POOL_EXPLAIN=1 go test ./internal/store -run ^TestHumanPoolExplainLocal$ -v -count=1`. Hardcoded loopback Mongo, unique synthetic database dropped on exit, 40,000 rows and existing registered indexes only. QC dual stages, both acceptance stages, available/mine/reviewed, all/single-project scopes. Reports under `local-data/test-results/pool-explain/` omit query bodies/customer content.
|
||||
|
||||
The prepackage all-project mine query examined 4,000 records for an empty result; applying the existing HTTP mine author rule examined zero. QC raw candidate counts differ by design: the legacy query returns authors' ended rows before the HTTP filter; only end-to-end/post-filter equivalence establishes correctness. Some first-page QC explain times did not improve; therefore do not infer universal speed from individual plans or force a hint. No indexes added.
|
||||
|
||||
The new server-only MinePoolOnly applies `(assigned to actor) OR (authored by actor AND quality_review AND ready/submitted)` before pagination. It leaves AnnotationView active/submitted and other ActorUserID uses unchanged. API permission checks, self-review prohibition and cursor ordering remain. Raw fetches can finish earlier because irrelevant history is removed, but visible task sets and the returned-item cursor contract are retained. Memory/Mongo stage/status/ownership/project/view matrices and seven-row page traversal match legacy post-filter results. API differential fixture: 121 candidates → 1 with byte-identical response. Full Go gate has 68 known failures, no new ones; race tests passed.
|
||||
|
||||
Read-mix comparison: `34905aac` → `ca58c258`, both summary mode, initialized authorizations, --run-payload-kib 256 --author-history 1000. Twenty review/acceptance actors each have 1,000 ended authored records (20,000 added history rows), same fixtures per variant. Three alternating-order pairs, 5s warmup + 30s measurement, output `local-data/test-results/mine-author-history`. Each side performed 2,565 total requests, equivalent task sets, zero HTTP errors and stable writes.
|
||||
|
||||
Median of three per-round p95 values (ms):
|
||||
|
||||
| Endpoint | Before | After | Reduction |
|
||||
| --- | ---: | ---: | ---: |
|
||||
| Quality all-project mine | 1483.006 | 287.423 | 80.6% |
|
||||
| Quality single-project mine | 301.730 | 213.263 | 29.3% |
|
||||
| Legacy acceptance all-project mine (empty) | 1118.602 | 65.794 | 94.1% |
|
||||
| Final acceptance all-project mine | 1139.727 | 214.825 | 81.2% |
|
||||
| Final acceptance single-project mine | 265.390 | 160.989 | 39.3% |
|
||||
| Quality all-project available | 1145.282 | 363.263 | 68.3% |
|
||||
| Final acceptance all-project available | 885.284 | 305.377 | 65.5% |
|
||||
| Annotation buffer | 376.121 | 238.267 | 36.7% |
|
||||
|
||||
Available-pool and buffer code did not change in this step; their improvement reflects reduced contention from mine/history reads in this mixed workload. Do not claim their standalone query was rewritten. Mongo replies ~141.316 MB→106.097 MB (-24.9%); commands 10,124→9,788 (-3.3%). Median allocated bytes ~2.500 GB→2.089 GB (-16.4%); post-GC heap baseline 4,698,520 / 4,689,208 / 4,681,336 bytes and candidate 4,664,648 / 4,692,496 / 4,692,680, effectively unchanged.
|
||||
|
||||
This history-heavy short fixture now exceeds the 50% latency improvement target for all-project available/mine, with p95 below 2s. It is NOT the planned full capacity acceptance: no three 5-minute/30-minute phases, Pod CPU/throttling/RSS, ingress/bandwidth, media, submission/recovery workload, or live index verification. No production writes, index migration, resource changes, push, PR or deployment. Release/capacity acceptance remains pending.
|
||||
|
||||
|
||||
## Long-run evidence and remaining recovery scope
|
||||
|
||||
The instrumented comparison is pinned to baseline `80bdcee9`, stage one `a2eac93e`, and candidate `8b1f997c`. Output: `local-data/test-results/poll-pool-long-v3-instrumented`. Each variant has three rounds of 300-second warmup and 1,800-second steady measurement, with rotating order and identical v3 released-history fixtures. Consult `status.json` for live progress; this document does not assert completion. Archived source snapshots remain unchanged by later documentation commits.
|
||||
|
||||
The earlier `poll-pool-long-v3` attempt failed baseline warmup with two non-200 responses. Their cause remains unknown because that attempt lacked endpoint/error metadata. The 260-second diagnostic replay did not reproduce the failures; it does not resolve them. Preserve both attempts when evaluating the final evidence.
|
||||
|
||||
| Requirement | Existing evidence | Remaining verification |
|
||||
| --- | --- | --- |
|
||||
| Long read-load comparison | Instrumented runner, exact actor/endpoint schedule, task identity comparison, per-round latency/gzip/CPU/heap gates | Finish all nine runs and analyze; no partial acceptance |
|
||||
| Read timeout recovery | Injected candidate/detail/display timeout returns HTTP 500 without partial success; retry and fresh handler match expected response | Real socket interruption and OS process restart |
|
||||
| Buffer persistence | Local Mongo concurrent claims, capacity and receipt recovery regression | Restart during an in-flight request with lost response, integrated with realistic workload |
|
||||
| Browser recovery and edits | Intercepted API compatibility, draft preservation and reconnect regressions | Real transport failure and end-to-end submission/renew race |
|
||||
| Resource and bandwidth capacity | Local handler process CPU and heap; fixed gzip settings | Pod throttling/RSS, Mongo resource use, real ingress and video traffic |
|
||||
|
||||
After the read comparison, inspect the original error history and every round before making a performance claim. If a threshold fails, diagnose that endpoint/resource using the preserved samples before further optimization. Then complete isolated transport/process-recovery and mixed renew/submission validation. Local read success alone cannot approve production capacity or deployment. No production writes, resource changes, push, PR or deployment are authorized by this validation work.
|
||||
128
.scratch/poll-pool-optimization/work.md
Normal file
128
.scratch/poll-pool-optimization/work.md
Normal file
@ -0,0 +1,128 @@
|
||||
# Reduce polling cost and reviewer pool latency
|
||||
|
||||
Goal: Reduce polling payloads and pool latency without changing workflow or permissions.
|
||||
Agent: Codex
|
||||
Base: codex/reviewer-entry-guards @ 80bdcee9, deployed version selected by user; not yet in origin/dev.
|
||||
Scope: continuation and work-buffer polling, review pool display reads, compatibility and load validation.
|
||||
Out of scope: production configuration, migrations and release without separate authorization.
|
||||
Risk: mixed-version response compatibility, permissions, in-flight workflow recovery and database load.
|
||||
|
||||
## 2026-10-28 additional read optimization
|
||||
|
||||
- Buffer ledger validation now deduplicates active batch IDs and fetches only scope, workflow and stage fields in one Mongo query. Missing references are cached only within the ledger attempt; exceptional slots use the same projected fallback. Capacity and CAS logic are unchanged.
|
||||
- Display enrichment skips full annotation-task reads when capture/payload has already resolved the name. Legacy task fallback and request-local reuse remain covered.
|
||||
- Local isolated Mongo regression passed, including deduplicated query count, foreign-organization rejection, missing batch handling, stable poll ledger version and capacity update.
|
||||
- Targeted API regressions passed: continuation, annotation buffer, display cache and legacy display fallback. The varied deterministic fixture keeps the same task count; legacy/summary gzip sizes were 12,579/331 bytes (97.4% reduction). This is synthetic response evidence, not production capacity acceptance.
|
||||
- Remaining: frontend summary integration and task projection, broader display batching, exact pool query measurements and the approved 81-user repeated soak comparison. No push, PR or deployment performed.
|
||||
|
||||
## 2026-10-28 summary polling integration
|
||||
|
||||
- The annotation page now polls `view=summary` into an independent snapshot type. Legacy server responses and capacity PUT responses are explicitly converted. The 3-second interval is unchanged.
|
||||
- Existing full records retain their subject/draft payload; newly observed task IDs are hydrated once for sidebar compatibility. Explicit work entry still loads a full task. Scope/epoch/mutation fences are rechecked after hydration.
|
||||
- Added an explicit store summary method with an inclusion projection for state, ownership, slice phase and processing status. Claim reservation and default/PUT paths retain full behavior. Existing name-cache misses deliberately use original item inputs for historical nested capture names; no new cross-request cache was added.
|
||||
- Verification: 27 targeted frontend tests passed (entry, reconciliation, refill and mixed-version conversion); TypeScript/architecture passed; isolated Mongo summary/ledger tests and targeted API tests passed. Stable polls retain ledger versions and exclude large payload and processing-job input.
|
||||
- Go baseline gate passed with 68 known failures, no additions. Frontend gate still fails two source guards: `review-target-interaction.test.mjs :: source guard: resident editor binds the selected target with a tier label` and `scope-cycle-inline-editor.test.mjs :: source guard: resident inline editor promotes into edit state on focus`. Both reproduce unchanged at HEAD 8cdd2d79 in a separate archived baseline. The baseline full gate also had a temporary-copy local-stack/version failure and a hung devboot test that was terminated; these are not claimed as passes. Initial sandbox frontend run also needed termination of devboot before rerunning outside the sandbox.
|
||||
- Global format check reports four untouched files: ReviewHistorySummary.tsx, WorkforceStatisticsPanel.tsx, useAnnotationOutputData.ts, useReviewContinuation.ts. Modified frontend files were formatted; git diff --check passes. No baseline files were altered to hide failures.
|
||||
- Pending: browser end-to-end validation of this integration, batch/projected display fallback refinement, actual pool p95 and the specified repeated 81-user soak. This is not a release/capacity acceptance. No push, PR or deployment.
|
||||
|
||||
## 2026-10-28 browser and concurrent HTTP verification
|
||||
|
||||
- Added `node tests/browser/annotation-buffer-summary.mjs`: real application in Edge/Vite, every API intercepted with synthetic data and external hosts blocked. Passed real 3-second summary polling without repeated full-item hydration, old-server full-response compatibility, failed poll/reconnect, manual task selection retained after polling, and an unsaved action-description draft retained across two polls. No unexpected allocation/submission or page errors. Media playback and actual backend submission are outside this fixture.
|
||||
- `node tests/browser/review-continuation-errors.mjs`: all 12 quality/acceptance compact/legacy renew, error, empty and control-loss cases passed.
|
||||
- Extended `TestAnnotationBufferMongoHTTPConcurrencyAndReceipt`: mixed summary/legacy GETs alongside 16 concurrent claims per round, five rounds in a unique local Mongo database. Capacity remains two; settled summary/full state is equivalent; interrupted receipt recovery and a freshly constructed handler retain results. Passed normally and with Go `-race`.
|
||||
- `-race` also passed `TestMongoAnnotationWorkBufferPollIsReadOnly` and `TestReviewContinuationCompactRenewKeepsLegacyContract`. Targeted review read-count/permission-revocation, display and continuation regressions passed.
|
||||
- Browser artifacts: `local-data/test-results/annotation-buffer-summary-browser/{result.json,passed.png,page.txt}`. Initial test attempts exposed an assertion before React settled and an incorrect child-element click target; these were corrected to await the state and click the actual action block. Final run completed without source changes/HMR during execution.
|
||||
- No full 81-user mixed-role harness was found in the existing scripts/tests. These small synthetic concurrent tests are functional evidence only, not pool p95, production bandwidth or CPU/memory capacity proof. The baseline/stage1/stage2 dataset, workload runner and three repeated 5-minute-warmup/30-minute-steady comparisons remain required. Existing global frontend/format gate debt from the preceding entry remains unresolved. No release or production mutation.
|
||||
|
||||
## 2026-10-28 isolated 81-actor read-mix comparison
|
||||
|
||||
- Added local-only opt-in Go load harness and a Python baseline/candidate runner. Two projects, three suppliers, 60 annotation + 12 quality + 8 acceptance + 1 admin; stage-correct nonempty pool fixtures and administrator records; identical gzip settings, task-ID equivalence and zero stable-write checks. The runner archives the baseline into a temporary directory, never changes branches, and preserves output directories.
|
||||
- Three short pairs completed: 5s warmup/30s measurement, 855 requests per variant per round, 2,565 per variant total; zero HTTP errors/writes and matching returned task sets in every pair.
|
||||
- Synthetic buffer gzip fell 99.2%; Mongo commands fell 18.7%, reply bytes 18.8%. Median of per-round p95: buffer 444.725→463.224ms (no improvement demonstrated), quality all-project available 610.761→549.923ms, prepackage acceptance all-project available 608.618→491.782ms. Neither pool reached the 50% relative reduction goal. Details and interpretation limits are in readmix.md.
|
||||
- This is a handler/read-mix smoke comparison, not capacity acceptance: no network ingress/auth transport, continuation renew, video, submission writes, production-size history, long resource stability or three-phase 30-minute soak. No Pod/bandwidth/configuration change, push or deployment.
|
||||
|
||||
## 2026-10-28 member lookup diagnosis and scoped read
|
||||
|
||||
- Added test-only per-endpoint/collection/command Mongo counters and optional CPU profile. The legacy fixture showed 1,200 member-list reads (28.7 MB) for 600 buffer requests; supplier authorization seed derivation accounted for one of the two lists per request.
|
||||
- Corrected interpretation: previous v2 load runs did not initialize supplier-project authorizations; normal Mongo migration does. Those are retained as legacy-path evidence, not normal deployed-state proof. The comparison runner now supports both states and defaults to initialized.
|
||||
- Independent waste exists in `loadAnnotationMembershipsForUser`: it loaded a complete member list and immediately filtered by user ID. Added `ListProjectMembersForUser` retaining organization compatibility, all matching rows and ordering; account, supplier and grant checks remain unchanged and fresh.
|
||||
- Regression first failed with broad=2/scoped=0, then passed with scoped reads and immediate disabled-account rejection. Memory/Mongo equivalence tests preserve historical duplicate rows, project/organization boundaries and empty results. Buffer/review permission regression passed. No indexes, migrations or cross-request permission cache added.
|
||||
|
||||
### Scoped-member validation result
|
||||
|
||||
- Go gate completed with no new failures (68 known). Both initialized and legacy authorization pairs returned equivalent task sets with zero HTTP errors/stable writes.
|
||||
- Corrected a second comparison confounder: the runner originally forced baseline legacy/full mode. Added `--baseline-mode summary` and repeated the initialized comparison with both versions using summaries.
|
||||
- In that isolated pair, 855 requests per side; buffer member reply bytes 14,336,400→247,110 (98.3% reduction), total Mongo reply volume 178.92→162.02 MB, command count unchanged at 9,380. Buffer p95 348.547→386.892ms; do not claim latency improvement from this pair. Details in readmix.md, output `member-scope-summary-only`.
|
||||
- Remaining latency/capacity acceptance is unresolved. No production changes, push or PR.
|
||||
|
||||
## 2026-10-28 pool candidate payload reads
|
||||
|
||||
- Reproduced a three-row page reading 3,246,610 bytes of task payload from a 120-row synthetic backlog. Added an internal candidate projection retaining all metadata while omitting subject payload and processing input; final wire responses keep the existing list projection.
|
||||
- Extracted the existing visibility/claim checks without changing their rules. Filter metadata first, bulk hydrate only rows that can reach this page, preserve raw-page order/cursors/fetch limits. Compare all candidate metadata rather than only version; changed/missing selected rows trigger a fresh original full-page read before final filtering. No cross-request cache or index.
|
||||
- Targeted API tests passed: payload-read bound, legacy-strategy response equality, assignment/project changes without version bump, version changes, pagination, reviewer/self-review/acceptance/history regressions. Memory and local isolated Mongo candidate fields/pagination equivalence passed. Full Go gate and controlled performance comparison pending at this commit.
|
||||
|
||||
### Candidate projection validation
|
||||
|
||||
- Full Go gate: no new failures (68 known). Three same-mode 81-actor short pairs: 2,565 requests each, matching task sets, zero HTTP errors/stable writes. Mongo reply volume -34.8%; commands +2.2%; median per-round pool p95 improved 13.4% (quality all-project) and 26.3% (final acceptance all-project). Still below the 50% relative target; production/long-soak acceptance pending.
|
||||
- Added post-GC memory diagnostics outside measurement. One additional pair showed post-GC heap 4.62→4.34 MB and reduced allocations; end-of-run heap alone was GC-phase sensitive. Evidence and limitations in readmix.md. No expansion of deployment authorization.
|
||||
- Final `go test -race ./internal/api ./internal/store -run ^TestHumanPool` passed, with isolated Mongo projection tests enabled.
|
||||
|
||||
## 2026-10-29 run display metadata projection
|
||||
|
||||
- Found a coverage gap in the earlier read-mix fixture: human items had no RunID, so it did not exercise full execution-history reads in display enrichment. A regression first failed because an already-resolved capture still loaded the complete run.
|
||||
- Added independent HumanRunDisplay records and batch ID projection (names, task ID, persisted capture directories only), primed once for the returned human-item page. Preserve request-local missing-ID caching and the exact precedence of capture record → item metadata → annotation task → run. Only legacy run-directory fallback fetches full execution data; no authority checks rely on display metadata.
|
||||
- Targeted display/pool/pagination tests pass, including batch deduplication, missing runs and explicit missing historical header fields. Current UpsertRun auto-populates capture directories, so the old-record test deliberately removes that header field rather than assuming a newly inserted record is legacy. Memory/local Mongo projection equivalence passed with a 1 MiB execution log.
|
||||
- Added opt-in --run-payload-kib to the local comparison runner; zero preserves the earlier fixture, nonzero adds identical shared run records and task links to both variants. Full gate and performance evidence pending. No production mutation, index, resource, push or deployment change.
|
||||
|
||||
### Run display validation
|
||||
|
||||
- Final Go baseline gate passed with no new failures (68 known). Three local 81-actor short comparisons using identical 256 KiB run-history fixtures passed task-set equivalence and zero errors/stable writes.
|
||||
- Run queries 408→204, run reply volume ~107.219 MB→0.080 MB; total Mongo reply bytes -50.2%. Median per-round p95 improved 23.8% for quality/all and 31.4% for final acceptance/all. Allocations decreased; post-GC heap showed no sustained increase. Details/limitations in readmix.md.
|
||||
- This result does not establish production capacity or the planned 50% latency target. No push/deployment or resource change.
|
||||
- Final race-enabled display/run-projection/pool tests passed in API and store, with isolated local Mongo enabled.
|
||||
|
||||
## 2026-10-29 mine author-history query pushdown
|
||||
|
||||
- Added an opt-in loopback-only explain diagnostic with 40,000 synthetic rows, current registered indexes, QC dual-stage and both acceptance stages, all/single-project available/mine/reviewed queries. Reports only plan stages/index names/counts/times, not document bodies or credentials.
|
||||
- Found mine queries loading authored historical records the HTTP handler always discards. Empty prepackage mine examined 4,000 documents in the fixture. Narrowing the author arm to ready/submitted quality_review preserves the existing rule; assigned tasks remain unrestricted by this added condition. No new index or hint.
|
||||
- Added server-only MinePoolOnly, enabled only by human-items pool=mine. Dedicated AnnotationView queries and all other actor queries retain their original behavior. Existing API permission/visibility checks remain in place after query filtering.
|
||||
- HTTP before/after comparison reads 121 versus 1 candidates with identical response. A first fixture used a stage absent from its four-stage batch; corrected to the V5.8 stage definitions before accepting evidence. Memory/Mongo matrix covers all task states/ownership variants, project/stage scope, dedicated views and multi-page cursor traversal. Targeted regressions passed.
|
||||
- Added explicit --author-history fixture option to the local read-mix runner; existing zero-history comparisons remain reproducible. Final Go gate and same-fixture performance results pending.
|
||||
|
||||
### Mine/history validation result
|
||||
|
||||
- Full Go baseline gate: no new failures (68 known). Race-enabled mine/pool/pagination tests passed, including local Mongo equivalence.
|
||||
- Three short same-fixture 81-actor comparisons with 20,000 additional ended author records: each version 2,565 requests, task sets equal, zero errors/stable writes. Median p95 quality/all/mine 1483.006→287.423ms (-80.6%); final-acceptance/all/mine 1139.727→214.825ms (-81.2%). Mixed-workload available pools also improved by 68.3% / 65.5%. No sustained post-GC heap growth; allocations decreased.
|
||||
- Mongo replies -24.9%, commands -3.3%. Detailed query-plan evidence, scope and limitations are in readmix.md. This satisfies the short history fixture's latency thresholds, not formal long-run or production capacity acceptance. No new index, push, PR, deployment or resource change.
|
||||
|
||||
## 2026-10-29 long-run validation preparation
|
||||
|
||||
- Extended the read-mix runner to archive/pin every variant (including candidate), optionally include stage one, rotate execution order, checkpoint each run, validate completed evidence on --resume, preserve failed artifacts, and exclude concurrent runners with a filesystem lock. Harness hash, exact commits, timing and fixture parameters are part of the resume manifest.
|
||||
- Added 15-second resource JSONL and final time series: completed/retained requests, errors, heap/GC/goroutines and OS process CPU time. CPU includes the handler and in-process load client/compression, not Mongo or Pod throttling; heap includes retained benchmark samples. Warmup errors fail the run. These are not Pod capacity metrics.
|
||||
- Added failure-path HTTP regressions for candidate, detail and display read timeouts: no partial task success, identical retry/fresh-handler response, unchanged persisted task status/version/assignee. Passed under -race. Local Mongo buffer concurrent claim/receipt recovery, compact/legacy continuation and stale-page regressions passed. Full Go gate: 68 known failures, no new failures.
|
||||
- Three-version tooling pilot (80bdcee9 / a2eac93e / 3fe37a92), 1s warmup + 3s measurement passed; completed-run resume reused all three reports. Four Python tool tests cover invalid/stale evidence, atomic checkpoints and output locks. A race-enabled resource pilot crossed 15s sampling boundaries with zero errors. These are tooling checks, not performance comparisons.
|
||||
- Found a long-run fixture defect before starting: previously ended authored rows were accepted but unreleased, so the real 60s release sweeper could process them. Fixture v3 now creates dispatched synthetic partitions and links the historical rows; the sweeper remains enabled. A 1s/75s check with 20k history rows and 256 KiB run logs completed 2,095 requests with zero errors/stable writes. Do not conflate the v2 short evidence with v3 long-run data.
|
||||
- Next run: 80bdcee9 legacy, a2eac93e stage-one summary, pinned final summary; 300s warmup/1800s steady, three rounds, same v3 data/resources/compression. Approximately 5h15m excluding setup. This completes the long local read portion only; renew/media/submission/ingress and Pod resource acceptance remain outside this harness.
|
||||
|
||||
### First long-run attempt and diagnostic replay
|
||||
|
||||
- `poll-pool-long-v3` stopped during baseline 80bdcee9 warmup: two non-200 responses after roughly three/four minutes. The warmup guard correctly rejected the run before accepting steady-state evidence. Its original telemetry did not retain endpoint/status details, so neither root cause nor whether these were timeouts is established. Preserve this failure; do not describe it as fixed or discard it from acceptance history.
|
||||
- Added capped, sanitized failure metadata (synthetic actor, endpoint, HTTP status, elapsed time, known error class and code; no response bodies/queries/credentials). Replayed both baseline and candidate for 1s warmup + 260s steady with the same v3 fixture: each 7,090 requests, zero errors/writes and matching task sets. Failure did not reproduce; original cause remains unresolved. Output `long-run-error-diagnosis`.
|
||||
- Added a completed-run analyzer that separates local-read thresholds from capacity acceptance, checks every available-pool scope per round, and reports CPU/heap ratios. Full actor/endpoint schedule validation now rejects duplicates/missing requests even if totals match. Five runner tests and two analyzer tests pass. Short or partial runs can never be labeled long-run acceptance; capacity_accepted always remains false for this harness.
|
||||
- Repeat long comparison with diagnostic harness pinned in a new output directory; the failed attempt's manifest and artifacts remain intact. Application behavior is unchanged by these test/tool additions.
|
||||
|
||||
### Instrumented long run: first baseline complete
|
||||
|
||||
- Baseline round one completed 1,800 steady seconds with 48,750 requests, zero HTTP errors and zero Mongo writes. Available-pool p95 ranges 491.447–822.886 ms. Stage-one round one is running; no candidate long-run comparison is available yet. This does not resolve the original unclassified warmup failures.
|
||||
- Closed an analysis-only evidence gap: loading reports now reuses the runner's strict revision/mode/fixture/timing/request/resource validation before computing acceptance metrics. Tests reject reports from another commit or configuration and missing resource evidence. All eight Python runner/analyzer tests passed. No application or active load harness changes.
|
||||
|
||||
## 2026-10-29 post-release 50 Mbps latency diagnosis and repair
|
||||
|
||||
- Public HTTP read probes reproduced workforce waiting before first byte: QC 2.50–2.85s/~550 compressed bytes; admin 15.97–18.90s/~8.8KB; annotator 4.31s then 28ms. Download about 2–3ms. This identifies response-preparation delay, not egress-body saturation for these calls. API pods sampled at 3–10m CPU/51–188MiB; a snapshot is not throttling history.
|
||||
- Corrected probe fidelity: initial QC available probes omitted frontend pluginId and timed out at 30s. Those do not represent the actual page request. Complete frontend pool scope (annotation-qa, dual QC stages, limit 50) returned in 6.72s; mine in 0.163s. Actual default/trace and reviewed calls can differ; do not claim every task request is measured.
|
||||
- Read-only Mongo plans: existing sorted pool indexes are present. Complete plugin-scoped candidate plan scanned/returned 100 documents in 618ms; omitted-plugin diagnostic scanned 3,939 with blocking sort (~10s). Do not prescribe a missing pool index from that broader query.
|
||||
- Confirmed pool waste: API fetches up to six raw pages before permission filtering; other-project/supplier rows can exhaust that cap and leave visible tasks after its cursor. Added server-only QC project/supplier necessary-condition filters for annotation-qa available pool. Membership scope is request-local, legacy blank supplier remains, shared acceptance paths are excluded, and final role/supplier/self-review checks remain. No cross-request permission cache. Multi-page traversal regression checks final visible tasks, even though fewer invisible rows changes where a page boundary falls.
|
||||
- Read-only execution of the repaired GET handler against current data returned 17 tasks/119,034 raw response bytes in 735ms. This is local handler plus Mongo forwarding, not deployed public HTTP acceptance. The old first page could be empty while hasMore=true; do not claim equal first-page counts on that production sample.
|
||||
- Workforce loaded every slice revision of joined tasks. New calculator-derived version set applies canonical submission deduplication, skips valid frozen durations, and retains legacy quality-approved-version acceptance fallback. Mongo reads these task/version pairs in bounded groups of 200. A local 1,000-extra-history fixture reads one relevant version with unchanged output; matrix preserves Memory/Mongo reports for author/QC/acceptance/org and details scopes.
|
||||
- Real-data read-only stats diagnostic completed with 357 required slice versions. Earlier broad read exceeded its 120s diagnostic context. The forwarding channel transfers slowly; its ~99s completed time is not public HTTP timing and cannot establish a dashboard latency percentage. Submission, attribution/revision/task/run history still incurs reads; reviewOperations currently has only _id_ index and showed ~2s initial query. Further index work, if needed, requires a separately reviewed production plan; none created here.
|
||||
- Targeted tests and local isolated Mongo parity passed; full Go gate: 68 failures all in existing baseline (70 known), no new failures. Race-enabled added scope/statistics tests passed, including isolated Mongo and >six-round cursor traversal. No production mutations, index creation, push, PR update or deployment for these repairs.
|
||||
25
.scratch/production-quality-dashboard/progress.md
Normal file
25
.scratch/production-quality-dashboard/progress.md
Normal file
@ -0,0 +1,25 @@
|
||||
# Production quality dashboard implementation
|
||||
|
||||
Implemented:
|
||||
- Shared dashboard for admin, supplier manager, annotator, quality reviewer and acceptance reviewer; automatic entry, compact filters/cards/tables, role switching, pagination, CSV and six-day quality comparisons. Removed permanent explanatory copy.
|
||||
- First successful part submission selects an end-exclusive calendar-month cohort; subsequent outcomes remain visible. Legacy APIs keep their default semantics.
|
||||
- Role-specific independent rounds, original responsible-person attribution, supplier deduplication, duration-weighted rates, closed/open rework and part-level mean reworks.
|
||||
- Misreport facts preserve original opinion owners; carried opinions deduplicate; undo cancels the mark. New QC handling endpoint isolates the current source's acceptance opinions and checks ownership, stage, item version and handling CAS. Missing legacy opinion evidence produces null rates.
|
||||
- New review operations freeze reviewer supplier; historical rows retain existing account-directory fallback. Deliverability requires the current accepted partition's manifested delivery package.
|
||||
- Bounded shared snapshot schema v3, minimal source projections, independent list pagination. Request-local quality preparation is reused; new report avoids building unused legacy task/day details. No new indexes or migration.
|
||||
|
||||
Evidence:
|
||||
- Targeted cohort, role attribution (including same-timestamp QC/acceptance), permissions, export, date boundaries, supplier deduplication, history gaps, misreport revocation and concurrency-version tests pass. Workforce/snapshot race checks pass.
|
||||
- Five-role real-router browser test passes using isolated MemoryStore; exports and 390px viewport checked, zero page errors. Screenshots/report: `local-data/test-results/production-quality-browser/`.
|
||||
- Local isolated Mongo tests pass for source projection, preserved original opinions, CAS attribution/revocation, shared snapshot/restart/lease fencing.
|
||||
- Type/architecture checks and production build/boot pass. All changed frontend files pass formatting.
|
||||
- Full Go gate passes against the repository baseline (68 known failures, no additions).
|
||||
- Frontend full gate passes: 13 existing known failures, no additions (baseline contains 14). Updated the two stale focus source guards to require `editSelected` and reject captured `resident.scope`; 17 targeted tests pass. Existing real-browser quality and acceptance regressions pass, including focus before React commit retaining text/source with no background write. Known-failures list unchanged.
|
||||
- Global formatting reports the same 3 pre-existing files on b2324c19: ReviewHistorySummary, useAnnotationOutputData, useReviewContinuation; task files pass.
|
||||
- 5,000-part/25,000-work-fact local microbenchmark (3 iterations, Apple M5): legacy 12.75ms / 17.53MB allocated; new report 13.70ms / 17.33MB allocated. New report before request-local reuse and avoiding legacy expansion: 32.27ms / 68.66MB. This is not production capacity acceptance.
|
||||
- Small 24-part browser fixture JSON: admin 10.5KB / gzip 1.1KB; role-scoped reports 1.3–7.8KB / gzip 0.4–0.9KB. These are payload measurements, not a production bandwidth estimate.
|
||||
|
||||
Release limits:
|
||||
- Existing 120-second snapshot refresh remains; latest status is latest shared snapshot, not zero-delay streaming.
|
||||
- Historical supplier transfers cannot be reconstructed if old decisions never froze supplier. Unknown durations/opinions remain unavailable rather than guessed.
|
||||
- No customer data writes, push, PR or deployment. User-specific release authorization is still required. Global formatting still has the three inherited issues listed above; do not label every check green.
|
||||
62
.scratch/production-quality-dashboard/responsiveness.md
Normal file
62
.scratch/production-quality-dashboard/responsiveness.md
Normal file
@ -0,0 +1,62 @@
|
||||
# Responsiveness after the 50 Mbps upgrade
|
||||
|
||||
Status: in progress; first local improvement verified, production capacity not accepted.
|
||||
|
||||
Continue the user's current dashboard work on `codex/production-quality-dashboard`, starting at `6969411b`. The freshness check includes latest fetched `origin/dev` and the live API/annotation processor `005eb934`; the new dashboard is not deployed. Preserve the existing preview on ports 5197/3037. No production data/configuration/index change, push, PR or deployment is part of this increment.
|
||||
|
||||
## Observed baseline
|
||||
|
||||
Read-only production inspection on October 30: four API replicas, each requesting 1 CPU/2 GiB and limited to 2 CPU/4 GiB. An instantaneous sample showed 20–148 millicores and 244–643 MiB per API, which is not evidence of peak capacity or throttling. Four validator replicas each request 6 CPU/4 GiB, limited to 8 CPU/8 GiB; observed active validators used about 1.3–1.7 CPU. Do not infer a validator queue or need for expansion from CPU alone.
|
||||
|
||||
Across bounded 15-minute API log tails, 312 records exceeded the one-second slow-log threshold. Selected successful slow samples:
|
||||
|
||||
| Request | Samples | Median of slow samples | Maximum |
|
||||
| --- | ---: | ---: | ---: |
|
||||
| Annotation claim count | 49 | 15.49 s | 23.86 s |
|
||||
| Human-item lists | 26 | 10.32 s | 16.68 s |
|
||||
| Random claims | 24 | 6.47 s | 10.72 s |
|
||||
| Project metadata subroutes | 60 | 2.78 s | 4.30 s |
|
||||
| Workforce dashboard | 2 | 7.80 s | 7.80 s |
|
||||
|
||||
Five claim-count slow records returned 500. This sample excludes fast requests and cannot yield overall p95/error rate. Long 206 media responses measure streaming duration, not necessarily time to first byte. Identifiers, bodies, query strings and credentials are omitted.
|
||||
|
||||
A later single existing-test-account HTTP count read returned 200 with first byte 52 ms / total 54 ms. Its project/data scope and load differ from the slow-log population; it confirms that the endpoint is not uniformly slow, not that the 15-second cases are resolved.
|
||||
|
||||
Local Mongo checks on the current code: the sparse 1,200-batch fixture examined one candidate and one batch (~9 ms); 12,000 unclaimed tasks counted in ~189 ms. These do not reproduce production's 15-second waits, so a specific database/lock/network root cause remains unproven. No query rewrite, index hint, permission cache or resource increase is justified by these checks alone.
|
||||
|
||||
## Completed increment
|
||||
|
||||
- Project refresh/scope changes cancel obsolete pool, count, task-join and supporting metadata GETs for annotation, quality, acceptance and admin views. Successful review claims also invalidate pending pool reads. A cancelled read cannot publish a count, page or cursor, enter a legacy fallback, or start another task-join batch.
|
||||
- Pagination has a separate cancellation controller: loading more annotation tasks must not cancel the initial membership/workflow reads or pending count. Keep server eligibility, complete stage merging, row order and pagination rules intact. Save, claim, decision and continuation writes retain their existing recovery behavior.
|
||||
- The random-claim handler checks the existing directed-rework priority before reading the public candidate inventory. Account/project/supplier checks and receipt replay still happen first; returned task identity, version and ownership do not change. A regression first returned 500 when public inventory was unavailable, then returned the owned rework without querying that inventory. Existing random-claim/replay/concurrency/count/permission tests pass. This only removes unnecessary waiting for already-directed rework, not ordinary new-task claim latency.
|
||||
- Existing adapters accept an optional cancellation signal; existing callers remain valid. No API response, persisted schema or migration change. No additional page copy or visual elements.
|
||||
- Read-mix tooling supports explicit annotation/quality/acceptance actor counts (one administrator, maximum 250 total), optionally adds exact claim-count reads every 12 seconds, and checks every actor/endpoint schedule. Default 81-user runs and analysis of old evidence remain supported. Counts are included in result equivalence; missing requests or falsely labelled actor counts fail validation.
|
||||
|
||||
Verification:
|
||||
|
||||
- Three initial cancellation regressions failed on the original implementation, then passed. Targeted loading/pagination regression covers stale scope, refresh, permission errors, cursor ownership, metadata failure and preserving pending metadata during pagination.
|
||||
- Real browser + isolated local HTTP endpoints: quality cancelled 3 requests, acceptance 6, annotation 5, admin 1; all connections closed, no follow-up reads or stale updates, no page errors. This is a network-cancellation test, not a browser capacity test.
|
||||
- 121-user read smoke: 90 annotation, 18 quality, 12 acceptance, 1 admin; 5 s warmup + 60 s scheduled measurement; 100 historical items per reviewer, 256 KiB synthetic run payload. All 2,885 scheduled requests completed, zero HTTP errors and zero measured Mongo writes. Slowest endpoint p95 836.6 ms; claim count p95 513.0 ms, buffer p95 561.1 ms. Single-process local handler timing excludes authentication/network/ingress. It does not measure this frontend cancellation change's production speed benefit.
|
||||
- Existing shared snapshot scale test: 5,000 parts/25,000 work facts, four independent API handlers, cold 223 ms, warm p95 21 ms, one source build and one stored snapshot slot. This is the legacy annotation-output endpoint and sequential warm reads, not the new dashboard's concurrent acceptance.
|
||||
- Added a warm new-cohort-dashboard burst against the same isolated 5,000-part dataset: 121 concurrent wide-scope administrator reads over four independent handlers, p95 424 ms / max 443 ms. Every response retained the same snapshot ID and 5,000 submitted parts; no handler rebuilt raw history. This stresses report reads only, not distinct worker sessions, cold rebuilding or mixed editing/media load.
|
||||
- Evidence: `local-data/test-results/responsiveness-121/` (smoke report/resources, browser report, dashboard-scale log, build and full gate results). Frontend gate: 13 known failures, no new failures. Go gate: 68 known failures, no new failures. Baselines are unchanged.
|
||||
- Type/architecture checks, web build and changed-file formatting pass. Global formatting retains three inherited failures: `ReviewHistorySummary.tsx`, `useAnnotationOutputData.ts`, `useReviewContinuation.ts`; they are unchanged.
|
||||
- A repeated frontend gate hung in the unchanged `devboot` test while closing Vite with unread asset responses. The owned test child was terminated and that failed invocation retained. The test now consumes both response bodies before closing; its focused run completed in 1.4 s. No failure was added to the known-failure baseline; the complete rerun (`frontend-gate-complete`) passed with only the 13 known failures.
|
||||
|
||||
## Remaining work, ordered by impact
|
||||
|
||||
1. **Production query/claim waiting.** Capture bounded per-stage timings for authority lookup, candidate query, batch metadata, display enrichment, lock acquisition and response encoding on actual slow routes. Compare Mongo execution plans and command counts on representative local fixtures; separate server execution from diagnostic tunnel transfer time. Claim-count 500 responses need a classified error cause before considering the issue fixed. Index changes require their own production plan/approval.
|
||||
2. **Start-work critical path.** Measure page entry to usable pool, claim to editable task, first video frame and next-task handoff. Check hidden/obsolete history loads and eager all-stage pagination before optimizing. Any summary response is explicit and version-compatible; do not lose timestamps, source identity, server eligibility or task versions. Never hide tasks or turn errors into empty/zero data for speed.
|
||||
3. **Reporting.** Exercise the new cohort dashboard at production-sized histories, including cold rebuild, expiry, concurrent roles/filters, permission revocation, restart and export. Preserve cohort semantics and shared-snapshot time consistency; avoid refreshing source history on every page request. Existing 120-second refresh is not zero-delay live reporting.
|
||||
4. **Editing and processing.** Include autosave, version conflict, renewal, claim idempotency, submission, rework, reviewer decisions, reconnect and validator backlog/recovery in an isolated real HTTP/Mongo workload. Saving/claiming must retain confirmed outcomes and unknown-result recovery; lowering timeouts or cancelling writes is not a performance shortcut.
|
||||
5. **Capacity acceptance.** Start with the provisional 90/18/12 + 1 mix, add a 150-worker burst and simultaneous page entry. Pin dataset/resources/compression and versions. Each final variant needs 5-minute warmup + 30-minute steady state, repeated three times; test cold start/recovery separately. Record p50/p95/p99, errors, actual transferred bytes, Mongo scans/timing, CPU throttling, memory and queue length. Keep a mixed traffic test distinct from focused endpoint tests.
|
||||
|
||||
Working targets: pool/list/report read p95 <= 2 s; warm task metadata entry p95 <= 2 s; save/decision acknowledgement p95 <= 2 s. Improve previously slow pool requests by at least 50% under identical conditions. These are targets, not current guarantees; media startup and asynchronous processing completion require separate measured budgets. Correct ownership, current permissions, complete rows, drafts and final decisions are mandatory throughout.
|
||||
|
||||
## Bandwidth and resources
|
||||
|
||||
50 Mbps is theoretically 6.25 MB/s before overhead, shared by all traffic using that egress. At 121 equal active consumers that is only ~0.413 Mbps each. The 60-second synthetic read schedule compressed to 126,489,366 bytes (~16.9 Mbps per scheduled minute); deliberately large synthetic task payloads mean this is **not** a production traffic forecast. It does identify full pool payloads as a candidate for measured response-summary work.
|
||||
|
||||
The existing preview component already prefers object-storage signed redirects and deliberately avoids a browser-transcode fallback. Measure actual video bitrate, simultaneous streams, seek/range behavior and any other content routes independently; establish which flows consume this IP's egress instead of assuming all video does. For example, 100 concurrent 1 Mbps streams alone exceed 50 Mbps if all use that egress. Do not certify video capacity from small JSON responses. Reserve operational headroom based on actual sustained/peak measurements.
|
||||
|
||||
Keep current Pod sizes/counts while measuring code changes. Expand only against demonstrated CPU throttling, memory pressure, queue saturation or bandwidth limits, so resource changes do not hide query regressions. Prior 81-user long read tests explicitly recorded `capacity_accepted=false`; neither those tests nor this 121-user smoke grants whole-system acceptance. Production load/mutation tests and deployment remain subject to the user's specific authorization.
|
||||
8
.scratch/production-quality-dashboard/work.md
Normal file
8
.scratch/production-quality-dashboard/work.md
Normal file
@ -0,0 +1,8 @@
|
||||
# Production and quality dashboard
|
||||
|
||||
Goal: Show latest outcomes for part tasks selected by first submission date, with role quality metrics and a clean shared dashboard.
|
||||
Agent: Codex, current dashboard conversation
|
||||
Base: codex/poll-pool-optimization @ b2324c19 (user explicitly approved this unmerged base)
|
||||
Scope: workforce statistics, output snapshots/API, rework misreport handling, dashboard components, regression tests and contracts; continued responsiveness work for dashboard/pool entry, cancellation of obsolete reads, directed-rework query ordering, and configurable 121-user isolated read validation
|
||||
Out of scope: deployment, production data mutation, claim restrictions, sampling workflow, annotation reset feature
|
||||
Risk: new reporting semantics and reviewer handling permissions; keep legacy report behavior compatible and customer review history unchanged.
|
||||
68
.scratch/query-readmodels-scope-fix/work.md
Normal file
68
.scratch/query-readmodels-scope-fix/work.md
Normal file
@ -0,0 +1,68 @@
|
||||
# Bound reverse pool search to eligible references
|
||||
|
||||
Goal: Finish the authorized task-pool optimization after production read verification exposed a migrated-data scan regression.
|
||||
Agent: Codex / current deployment session
|
||||
Base: codex/query-readmodels @ 0fd7e367 (user-approved deployed candidate; isolated follow-up preserves release evidence)
|
||||
Scope: Mongo search candidate scoping, merged validity/reference reads, explicit opt-in local covering-index design and production-scale synthetic regressions
|
||||
Out of scope: permission/paging contract changes; production index/data writes, further push/PR/deployment without approval
|
||||
Risk: Query result equivalence, legacy recovery and false-negative avoidance
|
||||
|
||||
## Acceptance search follow-up (2026-11-09)
|
||||
|
||||
Follow-up base: 7a1231c7 (live API/processor source; freshness checked against origin/dev and cluster).
|
||||
|
||||
- Merge validity and eligible references in a covered facet; reuse its root relationships when resolving foreign hits.
|
||||
- Keep legacy/oversized/blind-annotation fallback, original final matching, scope, pagination and live permission checks.
|
||||
- Explicit scalar name key and five opt-in indexes; no startup DDL. Human-only CAS backfill is a separate production operation, not authorized by this local task.
|
||||
- Batch capture display metadata per page; retain legacy names and request-only negative caching.
|
||||
- Preserve Go Unicode lower-case semantics in the conservative Mongo prefilter.
|
||||
- Near-production synthetic mix: 26218 humanItems, 26490 runs, 29767 captures, 23611 tasks; 81 actors; distinct runs, large payloads and historical records. Actual page shape checked against AnnotationOperations (selected tab plus matching counts). Broad all-tab stress failures retained separately.
|
||||
- Local container failures retained: OOM during broad mix, file-descriptor exhaustion from retained fixtures, and maxTimeMS=8000 errors in 64–188ms with guest clock offset. Native Mongo7.0.45 comparison uses the same cache/config for both binaries; Mongo CPU/RSS are observed, not cgroup limited.
|
||||
- Evidence directory: local-data/diagnostics/acceptance-search. Formal sustained/production acceptance remains separate from short local read-mix checks. No new push, PR, deployment, production index or customer-data write in this follow-up.
|
||||
|
||||
### Traced page validation correction
|
||||
|
||||
- Read-only audit identified production Mongo 8.0.17-r1, 342694 target-organization humanEvents, 2552 unassigned eligible acceptance roots with valid run links, and single-directory runs. Global proposed new-index scalar types were checked, including the small other-organization populations. No production writes.
|
||||
- Added source-batch display batching and already-anonymous no-op; preserve point-read failure fallback. Red: 21 source point reads; green: zero point reads, two bulk reads. Added fallback/count/no-op regressions.
|
||||
- Corrected the load protocol to include trace=1, unfiltered 200-row pages, hit/miss searches, mine/reviewed, matching counts and project/all scopes. Aggregate/source batch topology and synthetic audit-event population now follow production shape. Earlier untraced results remain supplemental only.
|
||||
- Final task gate: local-data/test-results/verify-1794255798854468000/report.json (selected-checks-passed, no unmapped files). No source changes after the final freeze.
|
||||
- Native Mongo8 traced short mix: 2810 requests/variant, zero errors/writes; matching task/count/claim/trace fingerprints. Acceptance all-project hit p95 1570.9→356.9ms, miss1054.3→236.8ms. Short test is not sustained acceptance. Three 5min+30min paired rounds are running under the corrected protocol; no production-release status changed.
|
||||
|
||||
### Sustained v2 failure and follow-up
|
||||
|
||||
- Traced paired 30min round1: 42150 reads/version, zero HTTP/Mongo errors and writes, equal fingerprints. Hit p95 742.7→406.7ms (45.2%), hit counts749.7→562.9ms (24.9%). Relative target NOT met; remaining v2 rounds stopped, reports retained as failures.
|
||||
- Merged each foreign collection's name fields after a covered scalar facet; preserve old-algorithm fallback when a required name index is missing. Tests assert one name scan per collection and zero document fetches. Moved actor OR back behind facet after an isolated explain showed3396 FETCHes; corrected path0 FETCHes.
|
||||
- Count requests now share identical own-name candidate queries only within the HTTP context. Root/source/per-pool scope and server permissions remain fresh. Tests verify actor scopes differ correctly and a new request rereads names.
|
||||
- Overlap four independent reference reads using the existing errgroup dependency; fixed fan-out, no added queries, run→capture dependency retained, sibling cancellation on failure. No new index or permission contract change.
|
||||
- Subsequent benchmarks restart only the owned27019 native instance before each variant to remove allocator carryover. Shared27018 and production untouched. New full task gate and sustained comparison pending.
|
||||
|
||||
### Frozen production fix and isolated measurement
|
||||
|
||||
- In-flight-only coalescing of identical org/original-base candidate scans per MongoStore; no completed-result cache. Independent caller cancellation, bounded8s worker, independent final permissions/canClaim. Scope flight cancellation/expiry/error tests and race56.872s passed.
|
||||
- Formal v3 paired30min round1 query passed: hit760.7→185.1ms, miss698.6→127.2ms, hit counts776.8→252.3ms, miss counts716.9→183.3ms;42150requests/version,0errors/writes, equal fingerprints. Stopped v3 resource comparison after vmmap showed large preparation allocator residue even in baseline; retain inflight-v3-progress.json.
|
||||
- Split fixture preparation and measurement processes, restart owned Mongo with data retained before measurement. Reuse requires config digest/exact counts; mismatched or pre-existing fixture safety probes preserve sentinel. Final task gate report verify-1794271033888668000 passed; production implementation unchanged after flight freeze.
|
||||
- Isolated short pair: hit542.0→171.2ms, miss704.6→130.4ms; hit counts555.1→268.9ms, miss counts717.2→178.5ms. API CPU ratio0.927, post-GC heap1.025, Mongo commands0.795/reply bytes0.972. UUID-sorted production size-only sampling recorded privately; no customer data written.
|
||||
- New formal-isolated.py series: three paired5min warmup+30min steady, fresh API/Mongo readers after separate preparation; all relative/absolute/equivalence checks must pass. Results pending; no push/PR/deploy or production index/backfill performed.
|
||||
|
||||
### Final isolated acceptance completed
|
||||
|
||||
- Three paired rounds, each variant 5min warmup +30min steady; 252900 measured reads total. Zero HTTP/Mongo errors, zero steady writes, equal actor/endpoint task/count/canClaim/trace fingerprints.
|
||||
- Acceptance all-project search p95 173–417ms; counts231–453ms; all four targets in every round meet <=2s and >=50% improvement (60–83%). Every measured pool endpoint meets2s.
|
||||
- Aggregate API CPU ratio0.8969; Mongo commands0.7954/replies0.9716; public gzip1.0008 (unchanged). API GC heap~1.01 each round; no sustained Mongo RSS growth across rounds. Native Mongo has no hard CPU/RSS cap; production capacity remains pending.
|
||||
- Final gate verify-1794271033888668000 selected-checks-passed; flight race passed. Six executions have identical harness/candidate patch hashes. Final source freshness includes origin/dev and live commit.
|
||||
- Evidence: final-acceptance-summary.json, mongo8-isolated-formal-comparison.json, six formal reports and resource/execution logs in private diagnostics directory. Docs record failures, corrected protocol, limits, five-index authorization and human-only CAS rollout.
|
||||
- No new push/PR/deployment, production index/backfill or customer writes. Old release remains deployed_pending_acceptance. Local task complete; production enablement separate.
|
||||
|
||||
### Administrator pool timeout follow-up
|
||||
|
||||
Base: ae52e5d4; freshness includes origin/dev and live7a1231c7. Same authorized follow-up worktree; no production mutation/deployment.
|
||||
|
||||
- Production read-only logs: admin-pool500 at8000/8006ms. Separate endpoint missed by earlier81-actor harness (admin only read workforce).
|
||||
- Red loop: ADMIN_POOL_SCALE=1 TestAdminAnnotationPoolMongoParity,26218 isolated synthetic records; searches6.23–6.51s breach2s. Counts~2.04s. Evidence admin-scale-red.log.
|
||||
- Batch64 metadata joins for batch/stage validation, search names and source jobs; reuse original source-selection/decision expressions. Match legacy payloads in bounded batches; hydrate only matched page and preserve response shape/order. No new index, cache permission or task writes.
|
||||
- Batch display priming for admin response. Fix missing nodeId in per-actor counts cache scope. Existing5s expiry and server authorization unchanged.
|
||||
- Scale green searches0.90–1.02s,counts0.81s; equal reference IDs/counts/paging.192-source-case parity passed, including missing/failed/foreign/superseded proof.
|
||||
- Gate verify-1794289069683716000 selected-checks-passed, no unmapped/deferred: admin/QC/acceptance frontend+HTTP+Mongo/browser, official Go baseline gate, local81 read mix.
|
||||
- Post-gate changes only to opt-in harness scheduling for repeated admin measurements; production Go unchanged. First extended81 mix3410 reads,0errors/writes; admin searches0.75–1.56s but all-project available had one3.53s sample. Kept as diagnostic, not stable p95 evidence. Higher-frequency repetitions in progress.
|
||||
|
||||
- Repeated administrator supplement finished:30s warmup+200s steady,1 admin request/second,81 actors;5920 measured reads,0errors/writes. Ten admin scenarios each20samples. All-project availablep95=311.603ms, admin searchp95=475.048–670.738ms; other search maxp95=724.445ms. Same actor/endpoint fingerprints stable. Earlier3.53s sample retained; production cold-load/capacity acceptance pending. Private final-summary.json records limits. No push/PR/deployment or production index/data changes.
|
||||
25
.scratch/query-readmodels/work.md
Normal file
25
.scratch/query-readmodels/work.md
Normal file
@ -0,0 +1,25 @@
|
||||
# Root optimization of task queries and statistics
|
||||
|
||||
Goal: Remove broad-pool search timeouts and make task lists/counts and reporting reads bounded, with equivalent legacy data and live authorization results.
|
||||
Agent: Codex
|
||||
Base: origin/dev @ 5375074a, fast-forwarded to deployed 4170c74b before changes to preserve PR #75 fixes; no main-checkout branch change.
|
||||
Scope: Query summaries/search planning, explicit list summaries and scoped counts, reliable derived-data maintenance/backfill, incremental reporting/snapshot reads, regression/performance evidence.
|
||||
Out of scope: Production data/index writes, push, PR and deployment until separately authorized; unrelated local work; permission relaxation, truncated history or changed search semantics.
|
||||
Risk: Derived-state freshness and recovery, mixed clients, old payload search, authoritative claim permission, ordering/cursors, dates and supplier/source deduplication. Query speed must meet representative isolated concurrent p95 <= 2 seconds before release preparation; functional checks alone are insufficient.
|
||||
|
||||
## Implementation and compatibility
|
||||
|
||||
- Source-owned `poolSearch` fields are stamped atomically with HumanItem/Task/Project/Run/Capture writes after supplier scrubbing. Search narrows candidates before the existing joins/sorts; the final matcher and server eligibility remain authoritative. Missing/stale metadata uses the existing pipeline. Broad reference sets never truncate results.
|
||||
- Explicit `/api/human-item-summaries` and `/api/human-item-counts` protocols; legacy item API remains intact. Acceptance detail lives separately from list summaries. Counts traverse all authorized pages and do not return partial totals after errors.
|
||||
- Summary backfill is an explicit, read-only-by-default CLI. Full-document CAS, idempotent reruns, counters only, 64 KiB per-document summary ceiling; no startup/GET writes, index changes or customer-body rewrites. Production apply still needs authorization. Old servers invalidate summaries through source guards; state-only review updates preserve valid summaries without rewriting annotations.
|
||||
- Statistics reuse the existing shared immutable fact snapshots and add bounded (4 MiB / 128 entries) generation/query-scoped compressed result reuse and concurrent request coalescing. Personal/supplier scope, dates, timezone identity and generation are in the key; decoding/calculation remain bounded. This does NOT implement event-driven source ingestion: existing 120-second projected-source refresh/recovery stays in place. Its 5,000-part/25,000-event cold build measured 240 ms locally; there is no measured reason yet to replace that recovery path.
|
||||
|
||||
## Evidence so far (not release acceptance)
|
||||
|
||||
- Production base 4170c74b, fresh source preserved. Main and unrelated worktrees untouched.
|
||||
- Mongo modern/legacy search parity, payload-only legacy names, tenant poisoning, literal regex characters, category/cursor cases, dry run/retry, old-writer invalidation/rebuild, project rename and state-only review metadata passed locally.
|
||||
- API summary/full metadata equivalence, shared acceptance revocation and >1,000-row counts passed. Browser search/pagination/retry/unvisited-tab totals passed; quality/acceptance/legacy receipt focus and unsaved-opinion flows passed.
|
||||
- Dense isolated comparison, identical 81 actors, source payloads, 10-second warmup/60-second measurement: base had 52 errors; candidate 1,765 requests/zero errors. Search p95 7.4–12.4 s -> 257–358 ms; common successful identity sets matched for 1,691 samples, with no differences. Some base actor/endpoint pairs had no successful reference and remain covered by separate equivalence tests, not by that comparison.
|
||||
- Mongo reply bytes 7.21 GB -> 0.119 GB in that synthetic mix; do not extrapolate it into production savings. Compression settings fixed; no media. CPU/heap readings include the in-process harness, not standalone Pod capacity.
|
||||
- Statistics isolated 5,000 parts/25,000 events: cold build 240 ms, warm p95 30 ms, 121-request/4-handler cohort burst p95 60 ms, zero history reloads during warm burst.
|
||||
- First task gate caught legacy no-hit foreign-ID transfer exceeding 64 KiB. Fixed with a tiny legacy-readiness probe; legacy/modern/large-payload Mongo and snapshot regressions passed afterwards. Final task/integration and prolonged repeated performance checks remain pending. Keep this branch local; no production changes, push, PR or deployment authorized for this task.
|
||||
30
.scratch/query-recovery-hardening/work.md
Normal file
30
.scratch/query-recovery-hardening/work.md
Normal file
@ -0,0 +1,30 @@
|
||||
# Query recovery, role checks and cutover safety
|
||||
|
||||
Status: local implementation and scoped verification complete; not deployed.
|
||||
|
||||
Base: dev d0dfddaf; unified recent-integration. User authorized fixes and validation, then release preparation. No production query switch, customer-data writes, index build or cluster changes were performed. Prior count/cache/page-scan and UI improvements remain. Protected pre-existing AGENTS/docs/admin-pool changes are excluded.
|
||||
|
||||
## Changes
|
||||
|
||||
- SnapshotTooOld (Mongo239), before inputs are sealed: persist the original failure, yield, then replace only the unfinished capture generation with a fresh query-DB snapshot. Preserve source synchronization checkpoints, confirmed facts, published heads and retained input pages until replacement completes. Do not combine pages from different snapshots or re-bootstrap original Mongo. Three replacements without sealing remain a genuine no-progress failure. Sealed plans retain their existing recovery path.
|
||||
- Transient failure reset requires the model lease and majority+journal transaction; it cannot manufacture progress or clear lease/persistence/no-progress failures. Projector read retries remain; hard failures stop visibly.
|
||||
- Role changes use authoritative scoped existence queries with ID-only projection instead of loading an entire organization's payloads. The transaction rechecks the same rule against competing claims. Submitted history, unfinished-work blocking, legacy statuses and organization isolation are preserved. Proposed optional covering indexes are not startup migrations and require their own production plan.
|
||||
- Shadow startup retains the observer, safety run, approved cumulative budget, nonce and finite window. Mutations require an approved immutable plan, current synchronized source and UID/RV checks. Metadata probes get bounded diagnosed retries. Production cutover additionally requires actual live result and permission evidence; ready Pods/metadata/synthetic results do not qualify. Approved100/150/200 throughput/batch stages are preserved; there is no extra blanket100-row cap.
|
||||
|
||||
## Evidence
|
||||
|
||||
Evidence folder: local-data/test-results/query-recovery-hardening.
|
||||
|
||||
- final-task/report.json: other selected checks passed, including Go known-failure gate, API permissions/history/role guards, concurrent task-pool read mix, query-serving/cache/authorization and observer/release-helper checks. Two initial failures are retained: an incorrect explicit-null legacy fixture and Docker mount-array order comparison. No business rule was changed to satisfy those fixtures.
|
||||
- affected-rerun/report.json: both corrected cases and the complete registered isolated suite passed.116/116, missing=[], skipped=false, sourceChanged=false;6 bounded batches and6 same-volume/resource majority+journal canary recoveries. Batching does not establish continuous capacity.
|
||||
- cutover-final.log:19 Python protection cases passed, including approved100/150/200 stages, denied/expired scope, result/permission mismatch, mixed cohorts, probe retries and CAS behavior. Last changes only affect this Python helper/test; Go inputs are unchanged from the116-case run.
|
||||
- affected-rerun/02.log:12,000 synthetic tasks; old227ms/14,293,087 reply bytes versus new4ms/515 bytes. Before adding this candidate index, new query took2ms. Legacy missing/empty/default organization and status checks passed. Not a production latency claim.
|
||||
- same-scale.log:35,000 events,140,000 facts; reused125,186 and wrote14,814 across2 rounds in77.50s. Refreshes170.67ms/162.14ms; original-Mongo reads0, fixed512KiB/s and majority+journal unchanged. This is local1CPU/1Gi, not production offload acceptance.
|
||||
- physical-restart.log: actual owned-container restart mid-apply, same volume/resources,408 facts recovered, repeated native input reads0, majority+journal preserved.
|
||||
- compile.log: all cmd/internal packages compiled. Source/test/environment identities and original failed runs remain in the evidence folder. Final source digest is recorded separately.
|
||||
|
||||
## Release preparation and remaining scope
|
||||
|
||||
Proposed sequence is recorded in local-data/test-results/query-recovery-hardening/release-preparation.md. Release role-check fix with existing production read flags and advisory configuration unchanged; update/resume shadow components in a separate approved plan/window. Preserve all checkpoints and published results. Production result/permission comparison and measured original-Mongo offload remain pending; no claim of completed cutover or capacity acceptance.
|
||||
|
||||
Need explicit authorization for candidate push, clean release worktree and image uploads; then exact synchronized dev + immutable digests, formal release gates and fresh target/in-flight checks before presenting final deployment plans. Proposed account indexes require separate explain/build authorization; they are not automatically created. No existing customer annotations, ownership, review records or production data were reset or overwritten.
|
||||
77
.scratch/query-serving-options/research.md
Normal file
77
.scratch/query-serving-options/research.md
Normal file
@ -0,0 +1,77 @@
|
||||
# 任务池检索与统计面板服务方案调研
|
||||
|
||||
Status: resolved
|
||||
Type: research
|
||||
|
||||
日期:2026-11-11(America/Los_Angeles)。本地基线:`a35e8416`;新鲜度脚本已只读确认包含 `origin/dev` 和线上版本。本次只调研、记录方案,不安装组件,不改业务代码、生产配置或数据。
|
||||
|
||||
## 结论
|
||||
|
||||
用户提出的“服务器提前算好,请求只取结果”可行,适合统计和搜索候选。主要改变应是把读取全历史、关联和聚合移出用户请求,按变化维护轻量读表,再用共享缓存或专用引擎服务请求。Mongo 可继续保存权威业务状态,快路径只做必要的权限、归属、版本与领取竞争校验。一次廉价索引读取与一次大范围历史扫描不是同一种负担。
|
||||
|
||||
不建议把现有慢查询简单改成每个 API Pod 每几秒全量重跑。这会重复消耗 Mongo IO/CPU,仍无法覆盖所有筛选组合。后台由单一调度/租约协调,按项目或事实分区增量处理,完整代次原子发布,失败保留上一完整结果。
|
||||
|
||||
## 已核对的当前实现
|
||||
|
||||
以下是代码证据,不是本次线上性能实测:
|
||||
|
||||
- `internal/store/production_stats.go:120`:生产总览使用 45 秒进程内缓存,按数据库客户端、组织和项目范围分键;命中可避免重读,但冷启动、过期或新范围仍执行来源读取。`internal/api/production_dashboard.go:153` 随后仍调用 `productionstats.Build`,不是所有请求都直接复制最终 JSON。
|
||||
- `internal/outputsnapshot/reader.go:56`、`:88`、`:152`:产出/质量共享快照在请求时触发异步构建,已有完整代次可在刷新时继续读;不是无访问也持续预热的后台服务。
|
||||
- `internal/outputsnapshot/types.go:14`:当前快照刷新间隔 120 秒;`:19` 的范围容量为 8。按任意项目组合形成快照范围会增加容量压力,不能仅增加缓存数量而继续复制全历史。
|
||||
- `internal/store/human_pool_search.go:35`、`:79`、`:84`:搜索还保留来源关联与旧记录兼容,现有匹配包含大小写不敏感的子串规则。`human_pool_search_reads.go` 合并同请求/同时进行的重复读取,不是持续维护的独立搜索引擎。
|
||||
|
||||
这些说明已存在缓存和摘要基础,但“后台主动生成、共享快速读取、完整增量维护”尚未统一覆盖所有入口。单凭代码不能断言当前每个慢请求的耗时分布,实施前仍需使用已补充的请求阶段观察做对照。
|
||||
|
||||
## 六条可行路线
|
||||
|
||||
这些路线可组合,调度器、消息系统、缓存、搜索引擎和分析数据库承担不同职责,不能互相混称。
|
||||
|
||||
| 路线与项目 | 工作方式、适用范围 | 主要成本与边界 | 对本项目的判断 |
|
||||
| --- | --- | --- | --- |
|
||||
| 1. 后台物化读表;现有 Go Worker,调度可参考 Asynq | 定时或按变化把复杂来源整理成轻量任务当前表、源采集阶段事实、统计结果;HTTP 只读小表/完整代次。适合所有面板的起步改造。 | 仍有 Mongo 读取,但读的是专门计算好的小表;不能只设定时器继续扫描全库。Asynq 自带调度/重试但依赖 Redis,不必为本项目另建一套队列。 | 低至中改造,优先复用现有 Worker/租约。Mongo 官方物化视图可作为实现参考,不是额外开源组件。 |
|
||||
| 2. Valkey 共享结果缓存 | 后台把已计算的常用面板、页数据或快照代次写入 Valkey,多个 API 副本共享;应用按缓存失效消息和过期时间更新。 | Valkey 不会自动感知 Mongo 的业务变化;需要生产者、内存预算、失效/重建机制和权限分键。只加读穿缓存仍会留下首次访问慢的问题。 | 对多 Pod 重复构建和重复读取最直接,适合与路线 1 联用。 |
|
||||
| 3. Typesense,或 Meilisearch Community | 只同步任务 ID、名称、来源定位、阶段、状态、组织/供应商/项目等小字段,使用搜索索引查询、过滤、分页。 | 索引与主库有同步延迟;名称变更、删除和迁移需可靠同步。现有子串、特殊字符、排序、分页语义不能直接套用默认全文搜索。 | 适合全部项目搜索,优先做 Typesense 试验;Meilisearch 是同类备选,不应同时部署两套。 |
|
||||
| 4. ClickHouse 分析读库 | 将业务事实同步至独立分析库,使用列式查询、预聚合和物化视图服务生产/质量/作业统计。 | 增加分析库、同步、口径和运维成本。增量视图主要由 INSERT 触发,更新/删除和关联维表变化不会自动完整修正旧聚合。 | 历史统计持续增大时值得引入;不用于决定任务可否领取。 |
|
||||
| 5. RisingWave 流式物化视图 | 从 Mongo Change Streams 增量接入,SQL 维护 JOIN、分组和统计物化结果,查询读已经维护的状态。 | 需要流计算状态存储、检查点、初始回填和版本适配;Mongo 必须满足 Change Streams 前提。开源核心和具体连接器/部署功能须按选定版本核对。 | 对“长期自动增量预计算”最贴近,但作为中长期候选,先隔离 PoC。 |
|
||||
| 6. NATS JetStream + 消费者维护读模型;可选 Debezium CDC | 成功业务变更形成可靠事件,消费者更新读表、Valkey 或搜索索引;事件可重放恢复。 | 这是更新机制,不是直接查询引擎。重复投递必须幂等,事件顺序/检查点/积压须可观测;业务提交与事件不能普通双写。 | 多个读取系统共用一条变化流时有价值。可以与 1~5 配合,不必起步就部署 Kafka。 |
|
||||
|
||||
### 官方证据与限制
|
||||
|
||||
1. [Mongo 物化视图](https://www.mongodb.com/docs/manual/core/materialized-views/) 将聚合结果存盘,`$merge`/`$out` 用于更新;普通 view 仍在查询时计算。需自行触发/组织更新,不是自动增量索引。[Asynq 仓库](https://github.com/hibiken/asynq) 提供定时、重试、崩溃恢复与至少一次执行;[官方调度说明](https://github.com/hibiken/asynq/wiki/Periodic-Tasks) 要求同一计划只有一名调度者,避免重复任务。
|
||||
2. [Valkey 仓库](https://github.com/valkey-io/valkey) 提供自部署共享键值服务;[失效机制](https://valkey.io/topics/client-side-caching/) 描述键变化通知客户端。该机制追踪的是 Valkey 键变化,不能替代 Mongo→缓存的更新链。
|
||||
3. [Typesense 仓库](https://github.com/typesense/typesense) 与 [数据访问控制](https://typesense.org/docs/guide/data-access-control.html) 支持过滤和限定搜索范围。项目仍应经后端鉴权,不能让引擎密钥取代实时服务端业务约束。[官方 FAQ](https://typesense.org/docs/guide/faqs.html) 明确中间子串搜索须额外启用 infix,会增加 CPU/内存;不能宣称默认搜索等价于当前 `strings.Contains`。[Meilisearch 仓库](https://github.com/meilisearch/meilisearch) 区分 MIT 社区引擎与商业企业能力;[异步索引说明](https://www.meilisearch.com/docs/capabilities/indexing/tasks_and_batches/async_operations) 表明更新受理不等于已经可搜索。
|
||||
4. [ClickHouse 增量视图](https://clickhouse.com/docs/materialized-view/incremental-materialized-view) 将计算从查询时移至插入时;[CREATE VIEW](https://clickhouse.com/docs/reference/statements/create/view) 明确更新、删除、分区删除不会自动更新增量视图。应用须采用版本化事实、补偿/撤销或刷新重建,不能只累计。官网 Mongo ClickPipes 页面涉及 ClickHouse Cloud,本方案不把该托管产品当作免费自建组件;自建同步管道需另选并验证。
|
||||
5. [RisingWave 仓库](https://github.com/risingwavelabs/risingwave)、[CDC 机制](https://docs.risingwave.com/ingestion/cdc-with-risingwave)、[Mongo 接入](https://docs.risingwave.com/ingestion/sources/mongodb-cdc) 描述原生 Mongo Change Streams 接入及检查点恢复,无需独立 Kafka/Debezium 部署。不要把 PostgreSQL 多表事务一致性承诺直接推到所有 Mongo 查询上;具体一致性按目标连接器测试。[Mongo Change Streams](https://www.mongodb.com/docs/manual/changestreams/) 要求副本集/分片部署,恢复还取决于 oplog 保留窗口;本次未核实生产拓扑及 CDC 权限。
|
||||
6. [NATS JetStream](https://docs.nats.io/concepts/jetstream) 提供持久、确认和重放,默认至少一次投递,消费者须抵御重复。[Debezium Mongo Connector](https://debezium.io/documentation/reference/stable/connectors/mongodb.html) 和 [Mongo Outbox](https://debezium.io/documentation/reference/stable/transformations/mongodb-outbox-event-router.html) 可供可靠更新链参考;后者的业务记录/outbox 原子写要求多文档事务。当前部署若不具备此前提,不能假装普通双写等价,需采用经过验证的同文档持久意图或其他恢复协议。
|
||||
|
||||
## 推荐组合与推进顺序
|
||||
|
||||
第一步先复用现有 Go 后台与共享快照:建立轻量当前任务/源采集阶段事实,后台持续预热常用范围,冷启动在切流前预热;生产总览减少请求中的历史重建。只预计算有界基础粒度,不按“人员 × 任意日期 × 所有项目组合”枚举缓存。旧数据兼容读取集中在后台规范化/重建,迁移覆盖完成前保留受控兜底,不在每个热查询中重新关联完整历史。
|
||||
|
||||
第二步引入 Valkey 共享已计算结果,多个 API 副本读取同代次。统计失败保留上一完整版本及其时间,不把不完整结果当成零。缓存丢失由后台限速重建,避免所有请求同时回源;权限不确定时不能发送历史敏感结果。
|
||||
|
||||
第三步单独验证 Typesense 承接全部项目搜索,搜索索引只含必要字段。权威状态仍在 Mongo;响应时按当前权限验证候选,领取时使用现有 CAS/锁/归属/版本校验。列表、数量、分页必须基于同一套过滤语义,不能先截断候选再过滤导致漏题或数量虚高。按任务 ID、完整 Capture/part、子串、特殊字符、旧记录做结果等价和完整分页对照。
|
||||
|
||||
后续再评估 CDC/JetStream 与 ClickHouse/RisingWave。先在隔离环境按同一批事实做回放和正确性对照,选择其中一条满足规模与运维条件的分析路线,不把所有组件一起引入。CDC 不具备条件时,可先使用带重叠窗口的增量轮询、稳定游标和定期全量对账;删除必须有可追踪的删除事实或重建对账,不能只看 `updatedAt`。
|
||||
|
||||
## 不能省略的业务边界
|
||||
|
||||
- 展示统计可接受明确的刷新延迟;权限、领取竞争、送检、质检和最终验收决策继续核对权威状态。读取加速组件故障不应把正常作业入口一起锁死。
|
||||
- 源采集去重、全部 part 完成条件、正式重跑导致旧完成失效、事件当时供应商归属、自然日时区及复审统计沿用 `CONTEXT.md`。不能简单累加每日 distinct 数,不能把多个通过率直接取平均。可加指标预聚合;跨期去重保留源采集身份;比率由原始分子/分母重算。
|
||||
- 缓存/读表键包含组织、可见项目范围及必要的个人/角色/权限版本。撤权即时生效,不依赖长 TTL。统计快照时间与业务事件时间分开保存。
|
||||
- 投影按业务版本/事件 ID 幂等,支持乱序、重复、重启和断点恢复。完整代次发布后再切指针;旧数据、旧标注与正式审查记录不被重建覆盖。
|
||||
- 查询返回页数据和必要聚合,不把所有历史大 JSON 传给每个用户。缓存不能消除响应编码、传输、解压和前端渲染成本。
|
||||
- 后台构建单独限并发、CPU/内存与 Mongo 读取速率,避免将用户侧慢查询搬成持续后台争抢。视频读取链路与本文元数据/统计读取加速分开验证。
|
||||
|
||||
## 验证目标(建议,尚非实测收益)
|
||||
|
||||
同一接近线上规模的隔离数据、固定资源、压缩设置与脚本,覆盖正常/旧任务、多供应商、受限权限、全部项目和单项目。对照冷启动、稳定运行、集中进入、撤权、事件重复乱序、索引/缓存重启、回填与失联恢复。
|
||||
|
||||
- 沿用既定任务池门槛:81 人并发读取混合负载下,实际搜索 p95 ≤ 2 秒,无漏题/越权/新增业务错误;缓存未命中不能隐藏在 warm-only 指标中。
|
||||
- 建议面板常见查询暖态 p95 ≤ 500 ms,预热后首次进入 p95 ≤ 2 秒;这是待验证目标,不是产品性能承诺。
|
||||
- 建议目标新鲜度:任务候选投影 1~3 秒、统计 10~30 秒;需由业务确认。领取/提交时即时核验不受此延迟替代。
|
||||
- 测量主库命令次数、扫描/字节与 CPU/IO 总量,包含后台同步和重建;同时记录读库资源、API 延迟、响应字节、队列积压与刷新落后时间。不能只测接口变快而忽略后台把主库压满。
|
||||
|
||||
## 调研记录
|
||||
|
||||
使用 Exa 进行了 10 次有效搜索,共返回 43 条结果,覆盖缓存、物化视图、搜索、分析、流计算和事件更新六个方向;返回结果含重复,不视为 43 个独立证据。关键结论以官方文档/项目仓库复核。一次 Meilisearch 旧文档路径抓取超时,已通过官方现行异步操作文档确认,不把抓取失败当成能力缺失。未安装或压测这些组件,不依据项目宣传的毫秒数推断本平台收益。
|
||||
38
.scratch/query-serving-options/spec.md
Normal file
38
.scratch/query-serving-options/spec.md
Normal file
@ -0,0 +1,38 @@
|
||||
# 后台物化读表、Valkey 与 Typesense 实施
|
||||
|
||||
Status: claimed
|
||||
Type: task
|
||||
Base: 9232bace
|
||||
|
||||
用户批准依次实施物化读取与共享缓存,再接搜索;正确性与性能达标后才准备发布。本次仅本地实现、隔离验证和提交,不推送、不部署、不写生产。
|
||||
|
||||
- 后台独立进程构建完整代次,复用已有统计口径与旧记录解析;读取不触发新组件的全量构建。后台并发有界、分布式租约、原子发布,失败保留上一完整代次,支持重启恢复和删除对账。
|
||||
- Valkey 共享不可变统计/查询结果,包含数据库、组织、项目范围、代次与查询参数;缓存故障、丢失与未准备就绪退回现有读取,不能阻断作业。复用既有快照发布协议,不重写标注/审核写路径。
|
||||
- Typesense 仅提供搜索候选;保留精确子串、Capture/part、特殊字符、旧记录、排序、完整分页与统计语义。实时权限、可领取、自审禁止、归属、状态、版本与写锁仍由现有服务端代码判定。
|
||||
- 新能力默认关闭,运行地址/凭证从环境或现有私有配置读取。新增集合只存可重建派生数据,后台和查询组件的生产安装、索引及回填另列计划。
|
||||
- 使用隔离 Mongo、真实 Valkey/Typesense 和合成数据,对照旧路径、撤权/归属变化、删除/重启、组件故障、并发与查询资源;接近线上规模,搜索 p95≤2秒,面板暖态 p95≤500ms、预热首访≤2秒。未实测或未达标保持待验收。
|
||||
- 保留原工作树两个 admin pool 测试及旧发布笔记,阶段性本地提交;不修改既有标注和正式审查记录。
|
||||
|
||||
## 本地进展
|
||||
|
||||
后台读表、Valkey、Typesense 已实现,默认关闭。真实三组件24项(含竞态、范围、失联、重启、旧数据和缓存损坏)通过;既有五阶段作业/恢复、搜索与统计浏览器回归通过。官方 Go 基线为68项已有失败、无新增;前端基线与构建/生产启动检查通过。范围总报告保留了原生产诊断跳过、原测试债务和最初三组件瞬时回退断言失败,不将其写成全绿;修正的专项已重跑通过。
|
||||
|
||||
81人、约2.6万任务/34万事件的首轮短测:候选零错误,347组账号/接口业务结果一致;管理员全部项目搜索p95 2592→799ms、生产总览3516→162ms;Mongo内部返回字节199215338→152507258,Go CPU +3.3%。这是短测,不是容量/生产验收。1GiB Mongo 对照OOM已作废,两版统一固定4GiB重新测得上述结果。
|
||||
|
||||
独立后台镜像构建和启动帮助检查已通过。待完成:冻结源码后的三轮持续对照和资源审查。未达标不准备发布;生产拓扑、新组件及派生索引/构建范围仍需具体计划与单独授权。现有两个受保护文件的哈希保持不变。
|
||||
|
||||
复查新增两项保护:Capture 候选按原 EqualFold 的 Unicode 简单折叠规范化,保留自由搜索原 ToLower/Contains 语义(含终形 sigma、长 s 和 Kelvin 符号回归);新候选与原历史条件组合超出 BSON 预算时退回旧路径,不截断。派生 schema 已升至v2,避免读旧候选。首次长测因发现此边界主动中止,不能作验收证据;24项真实三组件回归已通过,长测须重新冻结运行。
|
||||
|
||||
恢复边界补充:后台启动先递增观察代次使旧追平证明失效,只有变更流能推进 observedAt;单次预热复用完整观察路径,不能在重启或迟滞时重新信任旧索引。构建失败有界退避,搜索失联时普通孤儿载荷仍回收,远端意图恢复后清理。新增未重建失败窗口、发布不伪造追平、退避及断连清理回归。进程最大RSS(含预热)纳入规模报告。
|
||||
|
||||
新增代次发布前活跃查询预热,避免120秒代次切换造成80人同时解码;另补长词筛选预算、完整BSON预算、凭证字段回退和时钟健康验收。长词超过Typesense默认运算限制的根因已修复;测试夹具补齐既有计数覆盖索引,两版相同。最新Docker短测仍失败,日志证实本机时钟异常,不能作为稳定性通过;已采用独立原生Mongo重建夹具继续验证,环境资源差异必须单列。
|
||||
|
||||
原生Mongo 8.0.17(官方SHA256已核对)、同一约2.6万任务/34万事件、81账号的180秒短测:552组结果一致、零错误、零业务写入,全部搜索p95<2秒,生产总览1763→101ms,Go CPU约-11.9%、保留堆约-52.7%。但审核/验收/管理员面板各有一次约0.94秒尖峰,10秒预热短测不通过500ms门槛,不能作为最终验收。两版最大时钟变化62/28ms,旧Docker时钟失败单列保留。接下来必须按完整5分钟预热/30分钟稳态、三轮对照验证,不能丢弃尖峰或放宽门槛。
|
||||
|
||||
最新官方Go门禁仍为68项已知失败、0新增;24项真实三组件竞态/恢复回归、6项证据判定测试、格式和独立后台镜像构建/启动检查通过。尚未推送、部署、补写生产或变更生产索引。
|
||||
|
||||
复查发现空变更批次不能直接证明追平,已在352c405b之后补改:仅消费私有控制标记的准确更新增量推进证明,标记每秒一次且受同一租约约束,派生schema升级v3;不会以空批次、发布或后续fullDocument刷新时间。新增准确标记与消费者暂停回退测试。第一轮长测因该正确性边界主动中止,不计验收;需冻结最终代码重新运行。
|
||||
|
||||
标记协议专项24项真实三组件竞态/恢复测试全部通过;快速检查中本任务用例通过,整体仍因受保护的生产只读诊断未启用而为incomplete,不执行生产诊断凑全绿。对照为同一候选关闭/启用加速的兼容路径比较,不能冒称两个生产二进制的直接A/B。原生环境与Docker环境资源差异单列。
|
||||
|
||||
标记修正后官方Go基线再次通过(68项原有失败、0新增),后台镜像构建/帮助启动通过。中止长测记录保存在 local-data/diagnostics/query-serving-20261112T114057Z/ABORTED.json;不是验收完成。
|
||||
8
.scratch/recent-integration/work.md
Normal file
8
.scratch/recent-integration/work.md
Normal file
@ -0,0 +1,8 @@
|
||||
# Integrate recent dashboard, acceptance and pool repairs
|
||||
|
||||
Goal: Consolidate the user's recent changes in one local worktree.
|
||||
Agent: Codex current conversation
|
||||
Base: origin/dev @ 5d1135a0; user authorized integration of recent unmerged work.
|
||||
Scope: Merge codex/acceptance-capacity-120 and codex/source-gate-pool-search, resolve overlaps, run integration gates.
|
||||
Out of scope: Other worktrees' uncommitted edits, production writes, push, PR and deployment.
|
||||
Risk: Shared pool and workbench changes require regression checks; previous capacity limitations remain.
|
||||
20
.scratch/reliability-guardrails/work.md
Normal file
20
.scratch/reliability-guardrails/work.md
Normal file
@ -0,0 +1,20 @@
|
||||
# Reliability guardrails
|
||||
|
||||
Base: dev 8d4b6726. User authorized local implementation of retrospective improvements.
|
||||
|
||||
Scope: mandatory source-admission and annotation-preservation checks wired to CI/release; strict-mode readiness and explicit source-mode plans; private redacted failure logs and immutable check evidence; bounded request/DB/lock observations; reproducible runtime builds and reviewed combined image/config plans.
|
||||
|
||||
Compatibility: keep current advisory policy, permissions, optimistic versions, annotations, legacy reads and historical release records. No production configuration/data changes, backfill, index/backup writes, push or deployment in this task. Existing unrelated admin pool test edits are protected.
|
||||
|
||||
Verification: synthetic media and isolated local Mongo, existing baseline gates, release state-machine/CLI and security regression tests. No test may silently skip critical cases. Keep failures and unverified coverage visible.
|
||||
|
||||
Acceptance:
|
||||
|
||||
1. New releases require explicit effective source modes; a reviewed combined image/mode patch preserves all other configuration. Strict activation requires a complete, current deployment inventory under the candidate rules, without enqueueing validation or changing work.
|
||||
2. Existing annotation preservation, submission/deletion races, restart recovery, permissions and legacy-data regressions become mandatory, with missing/skipped cases rejected.
|
||||
3. The same gate exercises real local Mongo equivalence and advisory browser work/recovery in CI and release checks.
|
||||
4. Local checks preserve bounded private redacted output and immutable evidence; browser failures retain unique artifacts. Reuse is explicit and limited to unchanged, unexpired successful pure checks.
|
||||
5. Request-scoped numeric Mongo/query/lock observations reveal phase costs without customer data, extra queries or production explain.
|
||||
6. Authoritative image builds pin runtime dependencies and record recipe provenance. Image/source-mode changes form one reviewable processor-before-API plan. Other production configuration, backups and data mutations remain outside this task.
|
||||
|
||||
Limitations: inventory is point-in-time, not a data freeze or certificate; strict activation requires a controlled cutover window. Local tests do not prove production write acceptance, capacity or backup recovery. Remote CI awaits a separately authorized push.
|
||||
39
.scratch/review-pool-search/index-plan.md
Normal file
39
.scratch/review-pool-search/index-plan.md
Normal file
@ -0,0 +1,39 @@
|
||||
# Broad pool search: rejected metadata index experiment
|
||||
|
||||
Base: c942a8ce on codex/review-pool-search; live source e4969acc. This is an opt-in follow-up, not a startup migration.
|
||||
|
||||
## Evidence
|
||||
|
||||
Production read-only phase counts on 2026-11-08 found about 11,900 quality/semantic candidates. The current source-generated wide search still exceeds the 8-second deadline. Root explain examined 11,903 full documents in 1,018 ms in one warm sample; the window/group prefix and foreign joins add more work. These samples are diagnostic, not an end-to-end p95 or a fixed dataset benchmark. Random claim uses a separate path.
|
||||
|
||||
Hash batching and removing foreign lookup pipelines did not resolve the timeout and were not adopted. An initial synthetic index with an arbitrary prefix still fetched all documents. Ordering equality scope first is material: organizationId/pluginId/currentStageId, then createdAt/id, followed by projected metadata.
|
||||
|
||||
`TestHumanPoolSearchMongoCoveringIndex` uses the actual aggregation with 1,000 synthetic 64 KiB payloads. With the candidate index, its root cursor examines zero documents, and matching results remain identical before creation, after creation, and after dropping the index. There is no hint in the tested aggregation. A separate 10,000-row projection experiment also examined zero documents with the correctly ordered index. It does not establish full-query latency or concurrency capacity.
|
||||
|
||||
## Exact proposed production change
|
||||
|
||||
- Target: Fanyu cluster, namespace droboticflow-fanyu; Mongo database drobodata-fanyu, collection humanItems.
|
||||
- Create one non-unique, non-sparse index `pool_search_metadata_v1` using the ordered keys in `local-data/pool-v4-followup-20261108/rejected-index/index-spec.json`.
|
||||
- No customer record updates, backfill, deletion, existing index removal, Pod/bandwidth changes, or deployment.
|
||||
- The candidate API code's compact projection is still local; the live legacy projection may not gain the same coverage. After index creation, run the **local candidate's source-generated pipeline read-only** against the same filter/cursor and compare all matching IDs and count. Also check live API latency/errors because planner selection can change.
|
||||
- Do not automatically add this index in MongoStore startup. Creation requires separate production-change authorization under AGENTS.md.
|
||||
|
||||
## Cost, stop and rollback
|
||||
|
||||
A 10,000-row synthetic 16 KiB-payload experiment measured about 1.8 MiB for the 16-field version and a 51 ms local build. The final spec adds supplier/author scope fields. These figures do not predict production build time, disk size, replication lag, CPU or write amplification; inspect actual capacity and active builds before creation. All indexed fields are scalar by contract; abort if historical array values make this a multikey/parallel-array index.
|
||||
|
||||
Build adds CPU, storage I/O, disk usage and ongoing index maintenance. Monitor the existing service and cancel a build on sustained pressure rather than changing resources simultaneously. If the index worsens plans or gives no useful gain, drop **only this newly created index** with the same authorization. No customer-data rewrite is needed for rollback.
|
||||
|
||||
Root coverage alone is not acceptance. If foreign lookups still dominate or total p95 does not meet the agreed threshold, retain pending status and profile the next phase. Do not widen permissions, omit legacy rows, change pagination, or increase the 8-second timeout.
|
||||
|
||||
## Executed result and rollback
|
||||
|
||||
The user explicitly authorized creation of this index and dropping only this index if ineffective. Preflight: humanItems had 25,802 records, about 250 MB uncompressed data, 62.5 MB storage, 19.3 MB existing indexes; Mongo cache used 3.54 / 7.86 GB. A paged read-only field check examined all 25,802 records and found no arrays in the indexed fields. The original one-shot type aggregate exceeded its 8-second diagnostic bound; the 52 bounded batches completed in 11.3 seconds.
|
||||
|
||||
Creation took 4,597 ms; the new index occupied 15,835,136 bytes. The source-generated production root explain really used this index and examined zero documents, but the full **actual Go Store** candidate queries still took 8,001 ms and timed out for broad/all and available scopes. The acceptance example returned one match in 5,915 ms. These are scoped backend reads, not a customer browser/capacity pass.
|
||||
|
||||
A direct old/new root projection comparison measured old index: 2,065 ms, 11,903 documents, 11,904 keys, 1 seek; candidate: 3,377 ms, zero documents, 11,904 keys, 9 seeks. Coverage did not translate to reduced overall cost. Hash batching and native equality batching also still timed out. Production activity and warm caches vary, so these do not establish a fixed-dataset percentage regression; they are sufficient to reject retaining an unproven extra index.
|
||||
|
||||
The authorized rollback dropped only pool_search_metadata_v1 in 140 ms and verified it absent. Health/readiness returned HTTP 200 in 38/32 ms afterwards. No customer record, old index, resource or application image was changed. The experiment and local synthetic test are retained only under ignored local-data/, not installed by startup or made a permanent CI requirement.
|
||||
|
||||
Next work remains: avoid performing full candidate-set sorting/grouping and foreign metadata joins before selective search. Candidate discovery must preserve direct IDs, capture/part combinations, historical payload/input names, categories, ordering and tenant/claim rules. A new implementation needs differential tests and realistic latency evidence before another production change. The broad-pool issue is **open**, not fixed by this experiment.
|
||||
58
.scratch/review-pool-search/nov5-fixes.md
Normal file
58
.scratch/review-pool-search/nov5-fixes.md
Normal file
@ -0,0 +1,58 @@
|
||||
# 旧任务 V4 交付及 11 月 5 日反馈核验
|
||||
|
||||
Base: 6d8b011c67ecadfb9354cd1871d20c21b58d1f87;在现有 codex/review-pool-search 上继续,不改其他工作树。
|
||||
|
||||
授权范围:本地修改、验证、提交,生产只读诊断;未推送、未建 PR、未部署,未改客户记录或 BOS 文件。飞书仅阅读。
|
||||
|
||||
## 相比现网的新改动
|
||||
|
||||
重新核对结果:当前工作树包含最新 origin/dev 与线上源码 e4969acc;本地已有三个尚未发布提交:
|
||||
|
||||
- adc63af8:审核/验收按当前任务池独立请求,取消过期请求;批量关联搜索元数据,减少大载荷读取。已审核搜索不再被可领取池超时连带清空;**广范围搜索未完成性能验收**。
|
||||
- c942a8ce:修正工作树 hooks、验证入口与浏览器工具运行问题。
|
||||
- 6d8b011c:V4 历史包本地预览转换、可恢复批处理及查询索引实验记录。索引无端到端收益,已按原授权删除,没有保留生产索引。
|
||||
- 本批:旧任务 V4 打包快照与发布格式防护;鼠标进入批注时暂停并固定位置;舍弃切片批注目标;字幕上下位置偏好;Go 已知失败用官方基线门禁核对。
|
||||
|
||||
## 证据来源及日期
|
||||
|
||||
[数据平台测试](https://pcno45pc3jv8.feishu.cn/wiki/TImwwnFqyiIuC3kgIDHcIlHDnTc),读取修订 7543,11 月 5 日表格两条问题的解决栏均为空。
|
||||
|
||||
[平台调优群](https://applink.feishu.cn/client/chat/open?openChatId=oc_ff3c7f66ecfd607ffebd120f0113dbca)。CLI 时间为 America/Los_Angeles;北京时间 11 月 5 日主要反馈显示为本地 11 月 4 日。下面保留来源位置,不把当地 11 月 5 日晚的新反馈混称为北京时间同一天。群内“我看看/可以加设置”不算修复证据。
|
||||
|
||||
## 问题及处理状态
|
||||
|
||||
| 问题 | 核验与处理 | 状态 |
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------- |
|
||||
| 马迪:保存时间点意见后位置跳动(测试文档 11/5) | 下载原演示,画面是秒级位置变化;不能直接认定为源视频时间偏移。确认鼠标入口没有暂停/捕获当前帧,而 F 入口会暂停。补齐鼠标入口;既有编辑不追随播放头。旧钩子真实播放回归在暂停断言失败。 | 本地修复,三种播放器回归通过 |
|
||||
| 马迪:舍弃切片无法批注(测试文档 11/5) | 服务端允许切片意见,拒绝舍弃片段的动作/时间点意见。验收未把舍弃状态传入工作台,前端仍提供被拒绝的目标。传递状态并回退到切片目标,不修改服务端业务规则。 | 本地修复,三种播放器保存回归通过 |
|
||||
| [切片倍速重置](https://applink.feishu.cn/client/chat/open?openChatId=oc_ff3c7f66ecfd607ffebd120f0113dbca&position=452)、[快捷键切片后无法播放](https://applink.feishu.cn/client/chat/open?openChatId=oc_ff3c7f66ecfd607ffebd120f0113dbca&position=453) | 已在现网 e4969acc 修复,本批扩大原有验收真实播放器回归,防止回归。 | 现网已有修复;本批 45 次切片回归通过 |
|
||||
| [当前意见卡显示“无”](https://applink.feishu.cn/client/chat/open?openChatId=oc_ff3c7f66ecfd607ffebd120f0113dbca&position=451) | 原截图当前为来源 1 / 切片 3,列表那条意见属于切片 2、01:37.152;不是同一个当前目标。不能据该截图证明批注丢失;保留当前目标卡与全部意见列表的不同范围。 | 原截图不构成同目标丢失证据;不宣称修复未知场景 |
|
||||
| [审核搜题超时](https://applink.feishu.cn/client/chat/open?openChatId=oc_ff3c7f66ecfd607ffebd120f0113dbca&position=454) | 本地已有当前池请求隔离修复。此前与本轮生产只读实际 Store 对照:广范围 all / available 仍各 8001ms 超时,验收示例 5638ms、1 条。按来源聚集查询的实验也未达标,已撤回;不扩超时、不删候选、不保留无效索引。 | **未解决广范围慢查询** |
|
||||
| [字幕遮挡手部](https://applink.feishu.cn/client/chat/open?openChatId=oc_ff3c7f66ecfd607ffebd120f0113dbca&position=456)(客户端当地 11/5 晚) | 加“字幕位置”上方/下方选择,保留隐藏字幕;保存本机偏好,切片、刷新后保持。仅移动展示层,不改视频、标注或快捷键。 | 本地修复,正常/只读/错误视觉核验通过 |
|
||||
| [2x / 4x 视频卡顿](https://applink.feishu.cn/client/chat/open?openChatId=oc_ff3c7f66ecfd607ffebd120f0113dbca&position=440) | 用户提供的办公网报告:平台健康 107–148ms;同一 BOS 视频 Range 请求约 15s 超时,实收仅 0.02 / 0.22Mbps,另一次连接失败。这证明该次 BOS 到客户端传输异常,不能单靠通用测速判定播放链路正常;不足以判定 BOS 服务端或哪段网络的唯一责任。当前缺少新同条件链路复测,不改播放器掩盖传输故障。 | **未确认消除**;一般测速不等于视频链路测速 |
|
||||
|
||||
## V4 根因与修复范围
|
||||
|
||||
V4 工作流实际已于 11 月 2 日建立并启用,镜像和参数正确。库存 35 个包均来自旧工作流的源任务;源父 Run 在切换前创建,11 月 6 日新产生的打包子 Run 仍用旧节点。这是“旧任务后续打包未纳入新格式要求”,不是 V4 开关未上线。
|
||||
|
||||
按用户最新“不得再新生成旧包”的要求,替代原 10 月 22 日在途任务继续旧协议的约定:
|
||||
|
||||
1. 在同组织、项目、版本家族中选择唯一已发布且可见的 V4 配置,人工放行时冻结兼容打包节点、五项参数和摘要镜像;保留原任务及工作流归属。
|
||||
2. 执行、成功作业重启恢复和重试使用冻结节点。重试保留已验收基线及原始输入,更新交付分区关联;不重新进入人工关卡。
|
||||
3. 在任何目标写入前拒绝新的旧格式;V4 客户目录只能包含 part.json。审核历史是独立内部产物。
|
||||
4. 已完整交付旧包仍可逐成员校验后**只读**恢复状态;缺失、冲突或未完成旧包不续传,不原地转换。
|
||||
5. 缺少冻结原始选择、字典、分类或 PTS 的历史任务会明确失败,必须恢复可信证据后重发;不会用当前字典或猜测帧率补齐。已排队但没有新运行快照的旧子任务会被最终格式防护拦截,需要重新生成候选,不会自动改写已运行作业。
|
||||
|
||||
历史转换仍为 18/35 个已校验本地预览,另 17 个因证据缺口阻塞(10 个缺冻结切片字典、6 个缺固定 JSON、1 个全舍弃旧记录缺来源/字典)。6 个全舍弃预览存在历史标定版本证明限制,不能当成正式可发布。没有把预览上传或替换线上包。
|
||||
|
||||
## 验证
|
||||
|
||||
忽略目录 local-data/nov5-triage 保存脱敏诊断、旧版失败与候选验证;完整飞书文档捕获含账号表,不进入提交或对话输出。
|
||||
|
||||
- 旧行为复现:legacy-v4-baseline-red.log(旧格式成功新发、旧任务未收审计);note-baseline-red.log(鼠标意见入口不暂停);discard-baseline-red.log(舍弃状态仍提供时间点档)。
|
||||
- V4:v4-cutover-tests.log,隔离 MemoryStore / 假对象存储;新发防护、完整旧包零写入恢复、损坏/归属/多余成员、跨组织/项目/家族、固定镜像、重试祖先与分区恢复。
|
||||
- 最终任务门禁:local-data/test-results/verify-1794160542009742000/report.json,15 项全部通过,unmapped 为空,运行期间输入未改变。包括类型、格式、工具回归、前端相关回归、官方 Go 基线、V4 打包、三种验收播放器、返修边界、质检/验收草稿、决定竞态与只读权限。
|
||||
- 额外全量前端:frontend-baseline-gate-final.log,13 个失败均在既有 14 项基线内,无新增。首次沙箱运行的两个 EPERM 端口监听失败保留原始记录;允许本机测试服务后重跑通过,未改失败基线。
|
||||
- V4 Python 门禁 37 passed / 4 opt-in skipped;随后生成真实合成双目物化修订(real-materialization.log),补跑四项实际 V4 消费测试(real-v4-consumption.log)均通过,未把跳过直接算通过。
|
||||
- 真实验收截图与报告:local-data/test-results/acceptance-playback-rate/。native、movi、movi-fractional 各 15 次切片;鼠标写意见暂停真实媒体并固定保存位置;舍弃切片意见读回;字幕上下选择及刷新保持;加载失败、只读编辑锁均通过。已实际查看正常、只读及错误画面。
|
||||
- 最终候选未部署、未生产写验收、未容量验收;广范围搜索和 BOS 链路卡顿仍未完成。
|
||||
51
.scratch/review-pool-search/work.md
Normal file
51
.scratch/review-pool-search/work.md
Normal file
@ -0,0 +1,51 @@
|
||||
# Reviewer pool search isolation and metadata reads
|
||||
|
||||
Goal: Restore the reported reviewer history search without making it wait for unrelated pool queries.
|
||||
Agent: Codex
|
||||
Base: live e4969acc (codex/acceptance-playback-rate, PR #72), preserving its playback fixes.
|
||||
|
||||
## Changes
|
||||
|
||||
- Review/acceptance pages explicitly read the selected pool. Switching tabs cancels the old read; an available-pool timeout no longer discards a successful reviewed-pool search. Unread counts show an unknown value instead of zero.
|
||||
- Keep action ownership scope unchanged when switching pool tabs; stale initial/page results are guarded separately by the active view.
|
||||
- Separate page-read errors from action errors. A successful retry/refresh clears the read error without clearing an unresolved write error.
|
||||
- Search sorts compact metadata, batches foreign lookups in groups of 64, uses one conservative text prefilter, and hydrates matching records in original order. Legacy recursive payload names are read in batches only where needed.
|
||||
- Preserve dynamic legacy run-input reference names, tenant isolation, stable cursors, server eligibility, old response shapes and the 8-second deadline. No production data/index writes, migrations, or resource changes.
|
||||
|
||||
## Verification
|
||||
|
||||
Evidence directory: local-data/pool-search-verification/ (ignored).
|
||||
|
||||
- final-freshness.log: contains current origin/dev and the live version.
|
||||
- frontend-red.log: the new independent reviewed-search assertion fails against the exact baseline JavaScript (requests available instead of reviewed).
|
||||
- baseline-regression.log: raw historical input-reference fixture fails against baseline Go source; current Mongo/memory parity passes.
|
||||
- final-mongo-all.log: Mongo parity, 10,000 modern records, and a >100MB synthetic payload fixture pass, including cancellation, same-time cursor ties, cross-tenant links, category equivalence, payload-only fallback, candidate and identity responses. Find replies are included in traffic accounting.
|
||||
- final-search-browser.log: selected-pool search, old history, slow/failed unrelated pool, cancellation, pagination retry and cleared read errors pass; screenshot inspected at local-data/test-results/review-pool-search/review-search.png.
|
||||
- final-permissions-browser.log: review and acceptance authoring permissions pass using installed Edge. Initial default-browser attempt lacked a downloaded Playwright browser; rerun with Edge passed.
|
||||
- final-lint.log: lint and lint-related frontend checks pass.
|
||||
- remaining-checks-results.json and task-extra-*.log: source admission Mongo, source validation browser, review trace, rework boundaries, review drafts and decisions pass. The task plan was invoked but stopped at existing opt-in skips (RandomClaimLocalPreview and SourceValidationBrowserReplica); remaining checks were run separately with their prescribed environments. Do not describe the aggregate task gate as green.
|
||||
- final-frontend-gate.log: the only remaining global frontend failure is fanyu-comment-followup.test.mjs :: dashboard routes all workforce roles to the clean production quality panel. baseline-frontend-gate.log reproduces the identical failure at e4969acc via the official gate. No failure baseline was expanded.
|
||||
|
||||
## Production read-only evidence and limits
|
||||
|
||||
- The reported part exists and is accepted; its current state was not changed.
|
||||
- reviewer-scoped-readonly.log: the exact source-generated Mongo pipeline, restricted to each of the two actual reviewers' history IDs (79 and 98), finds one matching row in 583ms and 734ms. These are backend pipeline timings, not customer-browser end-to-end acceptance. No impersonation or customer writes.
|
||||
- Wide administrator/all-history and broad available-pool search can still exceed 8 seconds. The selected-pool isolation fixes the reported history page being blocked by that failure; it does not prove all broad-pool latency or capacity has been resolved.
|
||||
- No production write acceptance, 81-user load test, or release gates were performed for this task. Push, PR and deployment require new task-specific authorization.
|
||||
|
||||
## Retrospective follow-up (base adc63af8)
|
||||
|
||||
Scope: Repair worktree hook bootstrap, verification selection/dependencies/results, browser executable resolution and stale dashboard assertions. Wire the existing synthetic pool Mongo suite into CI. Reuse existing installed dependencies and isolated local services.
|
||||
Risk: Local/CI tooling only; no business query, delivery contract, customer record, migration, resource or deployment changes in this follow-up. Keep the wide-pool performance limitation above open.
|
||||
|
||||
Verification follow-up evidence: local-data/retro-guardrails/. The unchanged browser/product inputs passed all 23 task checks in verify-1793952872699139000/report.json (338.854s, no source drift). Earlier failures and the 600-second budget exhaustion remain recorded. Subsequent Docker COPY ordering and its regression affect only the dependency-install bootstrap: Docker-prepare regression and final quick checks are run separately; application/browser/Mongo inputs are unchanged. No known-failure baseline was expanded. CI wiring is validated locally; the remote CI has not run because this branch remains local.
|
||||
|
||||
## 2026-11-08: wide-pool and all-delivery continuation (base c942a8ce)
|
||||
|
||||
- Production freshness was confirmed against origin/dev and live e4969acc before investigation. No application deployment or customer-record mutation was performed.
|
||||
- Full production delivery inventory: 35 records (27 accepted, 8 legacy no_deliverables). Added a local-only resumable V4 preview converter that reuses the native builder, preserves fixed revision checksums, refuses conflicting output, records every blocked item and never claims a complete audit/publication. All-discard conversion requires the fixed child-run confirmation to name the exact revision/artifact/hash. Historical source recovery requires the published Capture snapshot and an exact persisted Run captureUnit/objectKeys selection; it never uses the mutable current Capture association or current dictionaries.
|
||||
- Converted and independently verified 18 previews: 12 published packages and 6 all-discard records. All 18 pass original left/right PTS coverage and calibration byte checks. The 6 all-discard cases have no historical calibration SHA: their checksums come from current bytes of the frozen BOS object selection, explicitly recorded. Historical object-byte version proof, complete internal audit, video decoding/downstream cuts and formal publication remain unverified. No online package/pointer was replaced.
|
||||
- 17 records remain blocked: 10 missing frozen slice classification dictionaries; 6 unavailable/incomplete fixed revision JSONs (5 published + 1 all-discard); 1 older all-discard record lacks original-source and dictionary snapshots. Historical original selection was recovered for 9 of the 10 dictionary-blocked packages by cross-checking the published Capture snapshot with the original Run's explicit selection and the existing Go validator; this does not supply missing historical classification tags. A per-record Chinese follow-up list and historical-name confirmation list are included with the local evidence.
|
||||
- Preview archive: local-data/delivery-v4-all-preview-20261108/V4交付包_18个已校验预览.zip. Full reports/evidence: local-data/pool-v4-followup-20261108/ and local-data/delivery-v4-all-preview-20261108/. Customer ZIP contains only 18 part.json files, README and public validation summary; no video/IMU/audit files.
|
||||
- Broad pool remains open. The separately authorized metadata-index experiment really achieved zero root document fetches, but actual Go Store broad/all and available queries still timed out at 8,001 ms, acceptance example 5,915 ms. The index was explicitly rolled back and verified absent; health/readiness 200 afterwards. No unproven index or runtime query rewrite was retained. See index-plan.md for exact scope, cost, evidence and rollback.
|
||||
- Earlier full task evidence (including synthetic covering-index, pool Mongo parity, permission and browser checks): verify-1794155814156557000/report.json passed. The rejected index experiment was then moved to ignored local-data rather than installed/added as a permanent CI requirement. Final converter/compatibility/tooling checks, including exact historical source recovery and all-discard acceptance guards: verify-1794157259610133000/report.json passed (8 converter cases plus native V4/real-materialization/legacy compatibility suites). These are scoped verification, not release or 81-user capacity acceptance.
|
||||
@ -0,0 +1,25 @@
|
||||
# Acceptance caption recovery after discarded slices
|
||||
|
||||
Base: e44cd959, codex/review-random-claim-fetch. Freshness confirmed against origin/dev and live source. Existing claim and heartbeat fixes remain intact.
|
||||
|
||||
## Confirmed defect
|
||||
|
||||
Focused final acceptance with source-index media reuses one Movi player and URL across slices. A keep -> discard -> keep selection can measure a temporarily unavailable picture and hide the subtitle overlay. The initial retry timers were cancelled on the first successful measurement and never rearmed on a later measurement failure. Playback could resume with no caption DOM even though the caption toggle stayed on and the caption data remained available; window resize restored it.
|
||||
|
||||
The actual acceptance component reproduced this in both source-index fixtures (ordinary and fractional media offset). A real `ReviewVideoCaption` lifecycle regression additionally ran against the fixed base source and failed at the recovery visibility assertion after late shadow-video dimensions, without resize or playback. Old-source evidence: `local-data/test-results/acceptance-caption-fix/lifecycle-red.log`. Earlier full-flow symptom capture: `local-data/diagnostics/acceptance-caption-switch/discard-recovery-probe.log` (these initial diagnostic runs also reported a browser cleanup failure; they are not passing-gate evidence).
|
||||
|
||||
## Change
|
||||
|
||||
- Re-arm bounded picture measurement retries after a failed measurement or media reload.
|
||||
- Refresh on seek completion and playback readiness; time updates only recover a missing overlay and do not repeatedly measure a healthy picture.
|
||||
- Cancel retries after recovery, media error or effect cleanup. Decode errors hide stale captions; readiness events allow recovery; unmounted effects cannot revive an old overlay.
|
||||
- Preserve caption visibility/placement preferences, all caption text, review permissions, draft/decision behavior, playback controls and rates. No network/API, database, migration or resource changes.
|
||||
- Extend the existing acceptance browser test with the exact single-camera keep -> discard -> keep click sequence and playback assertions for native, Movi and fractional-offset Movi. Add isolated error/readiness/unmount lifecycle coverage.
|
||||
|
||||
## Verification
|
||||
|
||||
`npm run verify:task -- --base e44cd959` passed 8/8, `inputsChangedDuringRun: false`, no unmapped/deferred checks. Final report: `local-data/test-results/verify-1794205856525025000/report.json`. Coverage includes type/architecture checks, changed-file format, verification-tooling tests, caption/preferences/navigation units and both browser fixtures. Screenshot checked: `local-data/test-results/acceptance-playback-rate/movi-caption-after-discard.png`.
|
||||
|
||||
Initial full browser runs passed functional assertions but failed browser-process cleanup. A scoped probe isolated the failure to killing a process that had exercised all three decoder modes with zero remaining contexts; running one mode completed cleanup normally. The acceptance test now uses and closes a separately owned browser process for each mode. Shared cleanup deadlines and failure reporting were not relaxed. Final task checks run serially and exit successfully; original failed reports remain unchanged.
|
||||
|
||||
No push, PR, image upload, deployment or production write performed. Online business acceptance remains pending deployment authorization.
|
||||
@ -0,0 +1,32 @@
|
||||
# 完整回归失败排查
|
||||
|
||||
基线:aaf1a663(包含质检随机领取修复),最终整批验证以5375074a为起点,覆盖领取修复与本轮测试修正。
|
||||
|
||||
## 追溯编辑框只读
|
||||
|
||||
最初定向复现:REVIEW_TRACE_BROWSER_TEST=1 go test ./internal/api -run '^TestReviewTraceBrowserReplica/quality$' -count=1 -timeout=90s -v。
|
||||
|
||||
本地诊断捕获 MOVI-PLAYER readyState=0/error=3,输入框聚焦后提示视频未就绪。补有效H264后 readyState=4,但原夹具仍无帧时间轴,编辑保护继续阻断。这个追溯夹具来自API规则单测,sourceVideo为占位路径,不能直接用作要求画面与统一帧范围就绪的浏览器编辑用例。
|
||||
|
||||
修正仅在测试侧生成10秒30fps视频并提供相匹配的300帧/301边界时间轴,等待媒体和时间轴就绪后再编辑。真实草稿、租约、连续审查、专注模式切换及续期仍走原路径;没有绕过产品侧的权限或就绪校验。修正后的quality正常/专注路径已通过,报告 local-data/test-results/full-regression-diagnosis/trace-after-fixture.log。
|
||||
|
||||
## 审核异常脚本卡住
|
||||
|
||||
原整组输出已显示quality与acceptance全部业务断言PASS,仍未退出。独立复测两轮正常后再次复现,增加分阶段清理期限后明确报 browser cleanup timed out:问题在浏览器退出清理,不是审核请求/决定断言卡死。
|
||||
|
||||
两个独立脚本改为通过BrowserServer持有本测试专属浏览器进程;断言结束后终止该专属进程,再断开客户端,避免等待安装版浏览器的缓慢或挂起的正常退出。清理分别有10秒上限;仍超时就报错、只强制结束自有进程/连接,继续清理Vite,退出码非零,不把清理失败变成通过。故障注入使用真实子进程和未结束的本地HTTP响应,确认超时会失败且释放资源。
|
||||
|
||||
串行复测:异常脚本、启动竞态脚本、异常脚本均在约11秒正常结束;质检/验收断言均PASS。见 local-data/test-results/full-regression-diagnosis/fixed-scripts.json 与 cleanup-tests.log。
|
||||
|
||||
## 证据边界
|
||||
|
||||
原失败报告、超时记录和known-failures均保留,不删除失败或扩大基线。临时诊断日志已从版本库文件移除,只在忽略的本地诊断目录保留。全批最终验证和前端基线门禁另行记录;不涉及生产业务写入、部署或线上领取测试。
|
||||
|
||||
|
||||
## 最终结果
|
||||
|
||||
- `npm run verify:task -- --base 5375074a --budget-seconds600`:17组全部通过,unmapped/deferred为空,执行期间输入未变化。报告 `local-data/test-results/verify-1794197252344521000/report.json`。包含领取/自审/权限规则、真实Mongo等价、追溯三种模式、源校验、任务池浏览器、返工、草稿保存、审核提交竞态与权限隔离。
|
||||
- `npm run test:frontend:gate -- --log-dir local-data/test-results/full-regression-diagnosis/frontend-gate`:13项既有失败,无新增失败;known-failures未改动。
|
||||
- 已查看质检追溯正常模式截图;合成视频和已编辑后取消的批注流程正常。
|
||||
|
||||
本结果替代verification.md中aaf1a663初轮“Remaining verification”的两项待验证状态,不改写历史失败记录。完整项目既有测试债务、生产发布门禁和生产业务写验收不由本批17组通过替代。当前仍为本地提交,未推送或部署。
|
||||
31
.scratch/review-random-claim-fetch/renewal-resilience.md
Normal file
31
.scratch/review-random-claim-fetch/renewal-resilience.md
Normal file
@ -0,0 +1,31 @@
|
||||
# Review renewal resilience follow-up
|
||||
|
||||
Base: f6c29749 on codex/review-random-claim-fetch; contains origin/dev and live source (freshness confirmed remotely).
|
||||
|
||||
## Confirmed local defect
|
||||
|
||||
`node tests/browser/review-renewal-recovery.mjs` exercised the actual session hook. Before the fix, one synthetic 503 on renew produced `session: transient renewal must recover without pausing work`, actual `error`, expected `owned`. Session handleError permanently disabled subsequent heartbeats; continuation failure also paused immediately. This is a reproducible failure mode, not proof of the historical supplier incident.
|
||||
|
||||
## Repair and compatibility
|
||||
|
||||
Retry only renew, at most two additional attempts, 250/500ms backoff. Retry network TypeError/APITimeoutError and uncoded HTTP 502/503/504 only. Require the same active scope and enough previously confirmed lease lifetime for a complete default HTTP timeout plus a safety margin. Never retry claims, start/next/bind, decisions, permission rejection, ownership rejection, unknown/near-expiry leases, or a cancelled page. Exhaustion follows existing fail-closed behavior; server authorization, generations, lease TTL, draft storage and explicit resume contracts are unchanged. Earlier random-claim repair remains in this branch.
|
||||
|
||||
## Production evidence limitations
|
||||
|
||||
Read-only recent logs across four live API pods returned continuation status counts 71 x 200 and 3 x 409. This request log did not retain rejection codes/actor identity. It does not establish that the supplier's incident was a 503, nor distinguish expired leases from another page takeover. No customer writes, push, PR or deployment performed. Affected reviewer name and exact pause banner requested separately to correlate the historical incident. The prior ad-hoc Mongo helper belonged to a removed worktree and could not run; no Mongo state evidence is claimed.
|
||||
|
||||
## Environment
|
||||
|
||||
The former shared node_modules symlink targeted a removed worktree. Replaced the broken symlink with a task-local `npm ci --ignore-scripts --no-audit --no-fund` installation from the existing lockfile. Initial quick formatter failure was missing executable, not a source failure; full affected task checks run afterwards using independent dependencies.
|
||||
|
||||
## Final verification
|
||||
|
||||
`npm run verify:task -- --base f6c29749` passed 12/12 checks with `inputsChangedDuringRun: false`, no unmapped/deferred checks. Report: `local-data/test-results/verify-1794201197277935000/report.json`. Includes real quality/acceptance/receipt workbench flows, new renewal recovery browser scenarios, draft persistence, formal decision races and permission regression. Production business acceptance and exact historical 409 attribution remain pending.
|
||||
|
||||
## Follow-up: supplier-wide report and read-only metadata
|
||||
|
||||
User clarified all quality reviewers experience the symptom. Reconfirmed branch freshness against origin/dev and live. Restored a disposable read-only Mongo transport using the existing API Pod; checked namespace UID, kept connection credentials in memory, hashed page identifiers and cleaned owned transport processes. No customer writes.
|
||||
|
||||
The metadata snapshot contains 23 non-deleted quality reviewers, 24 continuation records and 20 bound task sessions. The three recently working Star supplier reviewers are active accounts, with paused continuation records; their latest task states differ (one already accepted, others still claimed or moved to another assignee). Therefore a paused continuation's old item ID is not proof a task disappeared or should be reassigned. Other supplier queues were actively renewing during the observation. A bounded read of the latest 30 Star review operations since 2026-11-09T02:00Z found 8 completed formal quality decisions (HTTP 201) and 22 completed draft operations (HTTP 200), with no unknown/pending result in that sample.
|
||||
|
||||
This rules out a blanket account-disable explanation for the three observed users and supports inspecting the shared continuation path. It does not prove every account fails on every request, nor identify the historical 409 rejection code. Store records do not contain pause reasons or enough history to attribute the incident to transient 503, timeout, lease expiry, task transition or takeover. Keep that limitation; do not present the bounded heartbeat retry as a verified production root-cause fix. Source repair remains local at faa44932, not deployed.
|
||||
26
.scratch/review-random-claim-fetch/verification.md
Normal file
26
.scratch/review-random-claim-fetch/verification.md
Normal file
@ -0,0 +1,26 @@
|
||||
# Random review claim dispatch verification
|
||||
|
||||
Base: origin/dev 5375074a, source equivalent to live 327759af. Dedicated branch excludes the unshipped worktree-salvage changes on local dev 8b69030d.
|
||||
|
||||
## Behavior
|
||||
|
||||
The mine/reviewed sidebar intentionally reads only the selected pool. Random quality/prepackage acceptance claim now explicitly loads current-scope available candidates on click, independent of the sidebar cache. Eligibility remains server canClaim; rejected/self-review rows are skipped across bounded cursor pages. A missing eligibility flag, broken cursor or failed read raises an error instead of inventing an empty pool. Project/workflow/run/capture/stage scope remains explicit; CAS claim API is unchanged. Ref-based duplicate dispatch guard and pre/post read scope/selection/draft checks stop stale writes. No automatic claim retry was added.
|
||||
|
||||
## Evidence
|
||||
|
||||
- Red before fix: tests/frontend/review-random-claim.test.mjs exercised the actual page callback and reproduced zero candidate reads/zero claims from an unloaded pool. Original output retained in local-data/test-results/review-random-claim-fetch/before.log.
|
||||
- After fix: 14 focused tests passed, including quality mine/reviewed entry, acceptance stage scope, empty versus failed reads, missing flags, continuation pagination, double clicks, project/selection changes and drafts entered during the read.
|
||||
- npm run verify:quick -- --base 5375074a passed (8 selected groups): type/architecture, formatting, verification tooling, 212 selected frontend cases, backend permission/claim/search/source rules and store admission rules. Report local-data/test-results/verify-1794195567571455000/report.json. Initial sandbox failures were local listen/cache/hook permissions, then rerun with local verification access.
|
||||
- REVIEW_POOL_BROWSER_TEST=1 go test ./internal/api -run '^TestReviewPoolSearchBrowserReplica$' -count=1 -timeout=3m -v passed. Real application and isolated API cover existing pagination/search/retry cases plus mine/reviewed first-entry random claim. Only clicking claim fetches available, and both paths dispatch a claim with server conflict feedback; claim POST is intercepted with synthetic409, not a customer write. Screenshot local-data/test-results/review-pool-search/review-search.png was inspected. Unit callback also covers a successful claim response; this browser test does not claim production recovery.
|
||||
- npm run verify:task -- --base 5375074a --budget-seconds600 completed with failures retained, source inputs unchanged; local-data/test-results/verify-1794195615227615000/report.json. Source validation, real Mongo pool equivalence, review-pool browser, rework, draft persistence and review permissions passed. Full frontend known-failure gate reported no NEW failures.
|
||||
|
||||
## Remaining verification
|
||||
|
||||
- TestReviewTraceBrowserReplica/quality still fails at a readonly opinion textarea. The same exact failure was already reproduced on unchanged327759af through the formal Go baseline gate during the preceding diagnosis/migration work; known-failures was not expanded. This run does not certify that case.
|
||||
- test:browser:review-decisions: its real API controller cases completed, but standalone review-decision-failure.mjs did not finish after more than3 minutes. Only the owned local process (cwd verified) was terminated, so the composed command is FAILED/unverified; its following start-race subcommand was not certified in this run. Timeout evidence local-data/test-results/review-random-claim-fetch/harness-timeout.json. No claim that the full gate passed, and no baseline was edited to hide it.
|
||||
- Production release gates and online business acceptance remain pending. No production claim/save/submit, image upload, push, PR or deployment was performed for this repair. Earlier broad missing-pluginId query timeout is a separate diagnostic path, not this incident's root cause.
|
||||
|
||||
|
||||
## Follow-up resolution
|
||||
|
||||
The two initial regression failures above are resolved by the test-only changes described in [full-regression-resolution.md](full-regression-resolution.md). The full affected task suite now passes17/17 with unchanged inputs; the complete frontend baseline gate has no new failures. Original failed logs remain available. Production acceptance and release gates still require their own evidence.
|
||||
20
.scratch/review-random-claim-fetch/work.md
Normal file
20
.scratch/review-random-claim-fetch/work.md
Normal file
@ -0,0 +1,20 @@
|
||||
# Fetch review candidates at random-claim dispatch
|
||||
|
||||
Goal: Fix reviewers reporting no available tasks from mine/reviewed when the available pool was never loaded.
|
||||
Agent: Codex
|
||||
Base: origin/dev @ 5375074a (same source tree as live 327759af)
|
||||
Scope: Quality/prepackage random-claim entry, on-demand bounded candidate reads, stale-scope and duplicate-click guards, regression coverage.
|
||||
Out of scope: Production writes/deployment, unrelated unshipped local-dev changes, broad query optimization, permission-rule changes.
|
||||
Risk: Preserve server canClaim/self-review policy, drafts and claim CAS; failed reads must not become empty pools. Scope changes must not claim or navigate stale tasks.
|
||||
|
||||
## Follow-up: full regression investigation
|
||||
|
||||
User requested investigation of remaining full-regression failures. Scope also includes review-trace synthetic video/timeline fixtures, standalone browser cleanup ownership/deadlines, cleanup fault-injection tests, and verification mappings. No production editing/readiness/permission rule changes are part of this follow-up. Historical failed reports remain unchanged; final results are recorded separately.
|
||||
|
||||
## Follow-up: review renewal resilience
|
||||
|
||||
User asked to address a second supplier's automatic-pause report. Local red-capable browser reproduction confirms a single transient renewal failure permanently disables subsequent session heartbeats. Add bounded, same-generation renew-only retries while the previously confirmed lease has adequate lifetime; preserve terminal permission/ownership failures, explicit resume, drafts and claim behavior. Historical production 409 attribution is still unconfirmed. Evidence: [renewal-resilience.md](renewal-resilience.md). No production write, push, PR or deployment included.
|
||||
|
||||
## Follow-up: acceptance captions after discarded slices
|
||||
|
||||
User authorized the fix after confirming that entering focused acceptance, selecting a discarded slice and returning to a kept slice permanently removes captions. Base: e44cd959. Scope: shared picture-box recovery and browser coverage of the actual acceptance component; preserve subtitle preferences, playback/rate, review permissions, drafts and all earlier fixes. No API, customer data, push or deployment changes. Reuse this task worktree to avoid disturbing unrelated local work.
|
||||
8
.scratch/reviewer-dashboard-20261027/work.md
Normal file
8
.scratch/reviewer-dashboard-20261027/work.md
Normal file
@ -0,0 +1,8 @@
|
||||
# Add QC and acceptance reviewers to the production output dashboard
|
||||
|
||||
Goal: 生产总览 and 供应商产出 show QC and acceptance reviewer output next to annotators (same layout), with per-day efficiency for all three roles, durations in hours (one decimal), and rework re-reviews counted per part each time.
|
||||
Agent: Claude Code (Opus 5.5), desktop session 2026-10-27
|
||||
Base: codex/release-review-video-20261027 @ 2840d669 — the build live on Fanyu; origin/dev lacks the reviewer-statistics commits this builds on, so the PR also carries that branch's commits.
|
||||
Scope: internal/workforcestats (output dataset/report), internal/store/annotation_output.go (projection fields only), internal/api/annotation_output.go (response + pagination), internal/outputsnapshot schema key, src/components/AnnotationOutputDashboard.tsx, src/features/annotation-output, src/services/api/annotation-output.ts, docs/workforce-statistics.zh-CN.md
|
||||
Out of scope: reviewer self view (reviewers keep WorkforceSummaryPanel), CSV export columns, work-hour (工时) tracking, settlement/ranking formulas
|
||||
Risk: additive API fields; snapshot schema key bumps to v2 so a fresh generation builds once after deploy; no Mongo writes, migrations or index changes
|
||||
8
.scratch/reviewer-entry-guards/work.md
Normal file
8
.scratch/reviewer-entry-guards/work.md
Normal file
@ -0,0 +1,8 @@
|
||||
# Reviewer entry and self-review eligibility
|
||||
|
||||
Goal: Open personal work records automatically and prevent QC claiming their own annotations.
|
||||
Agent: codex
|
||||
Base: claude/workbench-poll-cost @ b2a4f16a (user requested optimization base)
|
||||
Scope: dashboard defaults, server claim eligibility, regression tests and contracts
|
||||
Out of scope: deployment and customer data migration
|
||||
Risk: claim permission tightening; existing self-review decisions remain blocked
|
||||
13
.scratch/rework-boundary-20261021/map.md
Normal file
13
.scratch/rework-boundary-20261021/map.md
Normal file
@ -0,0 +1,13 @@
|
||||
# Wang Ziyu rework feedback
|
||||
|
||||
## Notes
|
||||
|
||||
11:41 Enter feedback and 11:42 discard-boundary feedback are tracked separately, with a shared failing save path. A missing Capture title alone does not establish the cause. Repair base is deployed fab5be57; delivery classification v4 work is a separate branch.
|
||||
|
||||
## Decisions-so-far
|
||||
|
||||
- [Resolved repair](spec.md): route shortcuts through atomic slice application, preserve kept classifications, await confirmation and retain failed choices. Existing archive authority, CAS and undo contracts are reused.
|
||||
|
||||
## Fog
|
||||
|
||||
Local synthetic verification is not production acceptance. No customer records were changed, and this branch has not been deployed. Historical records that users explicitly invalidated require a separate evidence-based recovery decision; this fix does not infer their intended classifications.
|
||||
18
.scratch/rework-boundary-20261021/spec.md
Normal file
18
.scratch/rework-boundary-20261021/spec.md
Normal file
@ -0,0 +1,18 @@
|
||||
# Repair Wang Ziyu's discard-boundary and Enter feedback
|
||||
Status: resolved
|
||||
|
||||
Base: deployed fab5be57. Local changes only; no deployment, push or production writes.
|
||||
|
||||
Use the existing atomic slice application for boundary edits and conflict confirmation, with server-owned archives, version checks, authoritative recovery and one persisted undo step. Keep discarded portions archived and preserve kept-side action text/status/dictionary. Explicit invalidate remains a deliberate whole-action decision.
|
||||
|
||||
Enter/button confirmation must await persistence, reject duplicate writes, expose failures beside the confirmation controls, retain choices for retry and prevent cancellation while a result is pending. No outcome is inferred from the Capture title.
|
||||
|
||||
Verify through the actual AnnotationOperations page and real HTTP slice API with isolated synthetic data: left/right expansion, pending/described, mouse/keyboard confirmation, fresh read, error/retry, lost response, cancel, undo/redo and first-pass/rework. Keep existing split/merge, permission and autosave contracts.
|
||||
|
||||
## Answer
|
||||
|
||||
The deployed drag path had bypassed the atomic slice application and validated raw pieces before server archive semantics. Both failures are now handled by the existing authoritative application/reconciliation flow. Discarded portions are archived; kept portions preserve classification. Confirmation is asynchronous with an inline failure and a duplicate/cancel guard.
|
||||
|
||||
Regression command: `REWORK_BOUNDARY_BROWSER_TEST=1 go test ./internal/api -run '^TestReworkBoundaryBrowserReplica$' -count=1 -v` (local loopback and isolated MemoryStore; ffmpeg, Node dependencies and a Playwright browser required). Unit regression: `node --test tests/frontend/rework-boundary.test.mjs`.
|
||||
|
||||
Details: [map](map.md), [verification](../../docs/verification/rework-boundary-20261021.md).
|
||||
8
.scratch/slice-generation-sync/work.md
Normal file
8
.scratch/slice-generation-sync/work.md
Normal file
@ -0,0 +1,8 @@
|
||||
# Recover failed generation state without losing editing
|
||||
|
||||
Goal: Keep external slice-generation recovery visible and preserve unsaved work.
|
||||
Agent: Codex current conversation
|
||||
Base: codex/recent-integration @ e351ddce; user explicitly requested work in the unified worktree.
|
||||
Scope: Failed-generation status polling, concise recovery feedback, frontend regression.
|
||||
Out of scope: Production mutations, automatic regeneration, unconfirmed first-failure root cause, push and deployment.
|
||||
Risk: Detail refresh must not overwrite dirty editing or accept stale task responses.
|
||||
17
.scratch/source-gate-pool-search/work.md
Normal file
17
.scratch/source-gate-pool-search/work.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Source validation admission and complete authorized pool search
|
||||
|
||||
Goal: Prevent invalid source data from being claimed and make review pool search/page all authorized tasks without a 500-item ceiling.
|
||||
Agent: Codex current conversation, root coordinating delegated lanes.
|
||||
Base: origin/dev @ 5d1135a0; includes live API/processor 005eb934 and Worker 63512da7. Existing acceptance-capacity-120 and dirty workbench-ui-polish worktrees remain untouched.
|
||||
Scope: source validation/admission/recovery; authorized human-item search/pagination; affected UI and local isolated regressions/contracts.
|
||||
Out of scope: customer source repair, production writes, resource changes, push, PR, deployment; unrelated unmerged dashboard/acceptance features.
|
||||
Risk: eligibility, legacy source compatibility, source retry and draft preservation; pagination/cursor/permission consistency. No automatic customer file mutation or deletion.
|
||||
|
||||
## Comments
|
||||
|
||||
- Root owns integration, source-error UI in CaptureAnnotationWorkbench.tsx, verification and shared contracts. Keep necessary actionable errors concise; customer opinions remain intact.
|
||||
- Source lane owns source validation, ingestion and annotation claim/recovery backend, related tests/docs. New source admission module preferred. Do not edit human_loop.go list handler or AnnotationOperations.tsx; coordinate any claim helper change in human_loop.go with root before editing.
|
||||
- Pool lane owns internal/api/human_loop.go list handler, pool search storage support, src/services/api/human-loop*, src/lib/annotation-project-loading*, pool hooks/UI in AnnotationOperations.tsx, and related tests/docs. Do not edit source validation/ingestion modules or human_loop.go claim helpers. Coordinate shared types before editing.
|
||||
- User's explicit authorization boundary overrides repository defaults: remain local; do not push/create PR/deploy or mutate company data.
|
||||
- Contract/meta lane owns worker/capture_layout.go raw-human default required files, authoritative backend/operators/builtin/orbbec_data_normalize/operator.py and generated mirror, related normalization tests/docs. Reuse documented segment metadata checks; reject malformed IMU while preserving legitimate part boundary gaps.
|
||||
- Pool lane reused only QC candidate project/supplier scope and its two regression files from existing local commit b2324c19; unrelated workforce/statistics changes are not included. Modern Mongo search prefilter preserves old metadata fallback, no new indexes. Frontend source retry/timeline edits remain root-owned.
|
||||
22
.scratch/submission-loss-guard/validation.md
Normal file
22
.scratch/submission-loss-guard/validation.md
Normal file
@ -0,0 +1,22 @@
|
||||
# Local validation and recovery evidence
|
||||
|
||||
Source baseline: deployed API/processor `7a1231c7`; branch freshness confirmed against remote and live. No production writes, push, PR or deployment performed.
|
||||
|
||||
## Verified
|
||||
|
||||
- Before the fix, the actual handler/cleanup regressions reproduced ordinary blank regeneration clearing work, slice-only pruning deleting prior annotation revisions, failed job input replacement without recovery evidence, and storage errors reported as version conflicts. Log: `local-data/diagnostics/submission-guard-red.log`.
|
||||
- Final quick checks passed, including frontend state/retry regressions and API preservation, snapshot compatibility, CAS and cleanup regressions. Report: `local-data/test-results/verify-1794296345449703000/report.json`.
|
||||
- Final task run used frozen inputs (`inputsChangedDuringRun=false`). API guards, frontend tests, pool search browser/Mongo, private snapshot Mongo, domain tests and official `npm run test:go:gate` passed. Report: `local-data/test-results/verify-1794296455222371000/report.json`.
|
||||
- Actual rework browser recovery/edit/save/history/reload passed (48.12 s). Recovery tests cover archive failure without replacement, duplicate requests, restart, old worker fencing and JSON privacy. Private snapshot Memory/Mongo also passed independently in `local-data/diagnostics/private-recovery-mongo.log`.
|
||||
|
||||
## Failed or incomplete; not waived
|
||||
|
||||
- `TestSlicePhaseBrowserReplica` still times out waiting for the Delete slice button. Identical symptom reproduced on an untouched `git archive 7a1231c7` with the same dependencies and browser, via official `REWORK_BOUNDARY_BROWSER_TEST=1 npm run test:go:gate`. Baseline report: `local-data/verification/submission-baseline/local-data/test-results/go-2026-11-10T07-40-36.938Z-29146/summary.json`. This optional test is not in known-failures; the baseline was not modified. This coverage remains pending, so the task gate is not fully passed.
|
||||
- The untouched baseline opt-in gate also reported `TestDispatchTwoWorkersAndRestartDoNotDuplicateClaims`; the final candidate's ordinary official Go gate passed. No worker code changed.
|
||||
- Full store package returned exit 0 but the verifier marks it incomplete because unrelated opt-in Mongo/replica-set tests were skipped. Relevant private recovery Mongo and pool Mongo tests were explicitly enabled and passed. Skips remain recorded in final task `13.log`.
|
||||
- The first task run is not final evidence: wrong dependency symlink caused hooks/frontend failures and source changed during that run. Dependencies were corrected before final quick/task runs.
|
||||
- Production business write acceptance, release gates and deployment remain unperformed. Underlying account mutation lock contention is outside this guard patch and remains under investigation.
|
||||
|
||||
## Affected capture recovery
|
||||
|
||||
Capture: `FYLX_B11_AZEC86400SC_19700108_121818/part0001`. Read-only evidence confirmed failed rework submission revision 3, then ordinary slice generation revision 4 and predecessor cleanup. BOS revision 2/3 manifests return 404; versioning is not enabled. Mongo provides no accessible oplog. User reports no backup/PITR entry and the original browser was refreshed/closed. The surviving return baseline is not the completed rework. No complete latest recoverable snapshot was found in available evidence, and no old snapshot was applied to production.
|
||||
8
.scratch/submission-loss-guard/work.md
Normal file
8
.scratch/submission-loss-guard/work.md
Normal file
@ -0,0 +1,8 @@
|
||||
# Preserve annotation data across failed submission and regeneration
|
||||
|
||||
Goal: Prevent failed submissions or slice-only regeneration from erasing saved annotations; investigate the reported B11 rework without overwriting production data.
|
||||
Agent: Codex
|
||||
Base: origin/dev fast-forwarded to deployed 7a1231c7, required by the live-commit freshness rule; independent of the unpushed pool-search optimizations.
|
||||
Scope: Submission error classification, failed-input recovery evidence, blank regeneration guards, revision cleanup publication gates, cancellation-safe project lock acquisition, durable bounded submission retry, related search-only metadata projection and failure/restart/legacy regressions.
|
||||
Out of scope: Push, PR, deployment, production restores/mutations, lock protocol/lease duration changes and unrelated pool performance.
|
||||
Risk: Preserve old-client recovery, in-flight job fencing, legitimate explicit reset and successful submission; never replace current production work with an old return baseline.
|
||||
39
.scratch/submission-loss-guard/write-lock-validation.md
Normal file
39
.scratch/submission-loss-guard/write-lock-validation.md
Normal file
@ -0,0 +1,39 @@
|
||||
# Project lock contention and durable submission recovery
|
||||
|
||||
Base: `d1dc4a38` on verified live API/processor source `7a1231c7`. This follows the annotation preservation guard; unrelated unpushed pool optimizations remain excluded.
|
||||
|
||||
## Confirmed and inferred causes
|
||||
|
||||
- Actual processor logs contain seven failed jobs with eight busy-error lines in the UTC 06:38–06:40 incident window. API traces immediately before/during this window contain 30-second continuation failures, query timeouts and many roughly five-second write failures. Logs are under ignored `local-data/diagnostics/write-lock/`.
|
||||
- Isolated Mongo reproduced a concrete amplification defect: cancellation before the final project stripe executes no protected body but leaves 32 acquired prerequisite locks held. The old cleanup treats cancellation during lock acquisition like an uncertain business write; default leases last two minutes. After the patch, unused locks are released by owner. Actual started writes returning an unknown result retain all 33 protection locks.
|
||||
- The project/record/account lock code is unchanged between query optimization parent `8c2ae878` and live `7a1231c7`. Therefore recent query code did not introduce this lock-retention mechanism. There is no historical lock-owner trace to prove which exact request first triggered the incident; database read pressure remains a possible trigger, not a proven sole cause.
|
||||
- Actual async submission with one injected `ErrAccountMutationBusy` permanently failed and cleared its reservation before the patch. It now retains the same job/input/reservation, defers with bounded backoff, revalidates permissions/source, and finishes idempotently. Business/ownership errors are not retried. Post-handoff projection recovery does not duplicate submission revisions.
|
||||
- A synthetic 2.7 MB / 10,000-action payload added about 2.7 ms of metadata computation in the local sample, not seconds. This single-machine measurement cannot exclude contention under production CPU/I/O pressure.
|
||||
|
||||
## Recent query overhead and correction
|
||||
|
||||
Same Mongo, dependencies and 420-record large-payload fixture: optimization-parent source versus live-compatible migrated metadata, then the trimmed candidate. Result identities and permissions/legacy tests agree; no record count reduction or permission cache was introduced.
|
||||
|
||||
| Query | Pre-optimization Mongo reply bytes | Live-compatible bytes | Trimmed bytes |
|
||||
| ------------------------- | ---------------------------------: | --------------------: | ------------: |
|
||||
| Broad name, 200 rows | 131542 | 268737 | 234137 |
|
||||
| Pending quality, 200 rows | 153342 | 309142 | 239942 |
|
||||
|
||||
Search-only `poolSearch.text/source` had been carried through search/list hydration. Removing these duplicate fields reduces these representative reads by 12.9% / 22.4% against live-compatible code. Display, duration, freshness and legacy fallback evidence remain. Other summary overhead remains; this is not proof that all database pressure or all-project production latency is resolved. These are Mongo reply bytes, not an EIP/video bandwidth measurement. Timing samples are small and not a capacity claim.
|
||||
|
||||
Comparison logs: `pre-query-large-payload.log`, `query-and-safety.log`, `query-trimmed.log`, `query-comparison.json` under the ignored write-lock diagnostics directory.
|
||||
|
||||
## Verification
|
||||
|
||||
- Red reproduction: `submission-busy-red.log`, `lock-contention-red.log`, `metadata-list-red.log`.
|
||||
- Task report: `local-data/test-results/verify-1794297878860663000/report.json`, frozen inputs. API recovery/permission/CAS checks, explicit Mongo lock and private snapshot checks, migrated and legacy query parity, 81-reader smoke and official Go baseline passed. The quick store group records opt-in skips; the relevant cases were explicitly enabled in task/integration runs, not counted as quick passes.
|
||||
- Integration report: `local-data/test-results/verify-1794298148552521000/report.json`, frozen inputs: 19 commands passed, one browser command failed. Type/architecture, formatting, frontend and Go baseline gates, web build and anonymous production-bundle startup passed.
|
||||
- The failed browser command contains passing `TestReworkBoundaryBrowserReplica` and failing `TestSlicePhaseBrowserReplica` (Delete slice button timeout). The same latter failure was already reproduced on untouched live source and recorded in the prior validation document. No known-failure baseline was changed; full integration is not green.
|
||||
- Additional local Mongo tests cover live lease renewal, expired lease recovery, cancellation immediately after acquisition, preserved protection after actual writes, restart/backoff persistence, revoked users and old-worker fencing. A race run is recorded in `final-lock-race.log`.
|
||||
- Local shared-helper/diagnostic changes require no migration, index or lock-mode change. No production records, resources or configuration were changed. No push, PR or deployment performed.
|
||||
|
||||
## Release and rollback bounds
|
||||
|
||||
All lock users must receive the fix for full coverage: API, annotation processor, validator and Worker. Updating only API leaves older lock-acquisition behavior in other writers. The mixed-version lock protocol remains compatible, but old processes can still retain unused locks; existing leases are not cleared by this patch.
|
||||
|
||||
Retry bookkeeping is optional BSON data and private JSON state. Rollback readers can consume queued jobs but lose the new transient recovery behavior. Preserve the prior annotation-loss guard, and retain current drafts/recovery evidence. The five-minute store-wait budget does not promise successful submission during a prolonged database outage. Production verification and release approval remain pending.
|
||||
8
.scratch/verification-flow/work.md
Normal file
8
.scratch/verification-flow/work.md
Normal file
@ -0,0 +1,8 @@
|
||||
# Targeted development verification
|
||||
|
||||
Goal: implement the approved fast development / task / integration verification workflow and align AI rules, branch-freshness reporting, and release/env docs.
|
||||
Agent: Codex, current unified-worktree conversation
|
||||
Base: codex/review-focus-layout-stability @ c8aa1ae7; continue the user's unified worktree without moving other work.
|
||||
Scope: AGENTS.md, CLAUDE.md, verification/branch/domain/issue-tracker guidance, release-checklist/HANDOFF/local-dev-guide docs, branch-freshness.sh, npm aliases, local selector/runner and tests.
|
||||
Out of scope: changing release policy, bypassing approvals, production actions, capacity acceptance, or resetting the main checkout branch.
|
||||
Risk: false-positive verification or freshness reporting; test unmapped changes, skips, empty tests, timeouts, affected-scope expansion, and unconfirmed remote/cluster freshness states.
|
||||
8
.scratch/work-buffer-query/work.md
Normal file
8
.scratch/work-buffer-query/work.md
Normal file
@ -0,0 +1,8 @@
|
||||
# Make work-buffer polls cheap and read-only
|
||||
|
||||
Goal: the workbench's 3s work-buffer poll stops scanning each annotator's authored history and stops writing the buffer ledger when nothing changed (live p50 556ms store time, 4,095 >1s requests in 3h20m on 2026-10-27)
|
||||
Agent: Claude Code (Opus 5.5), desktop session 2026-10-28
|
||||
Base: origin/dev @ bc17d505
|
||||
Scope: internal/store/annotation_work_buffer.go, internal/store/annotation_work_buffer_mongo_test.go
|
||||
Out of scope: dashboard cache invalidation, claim-count latency, enrich step, poll interval, worker CPU limits
|
||||
Risk: no API, data-format or index change; the ledger is written only when capacity, slots or a reservation change
|
||||
8
.scratch/workbench-poll-cost/work.md
Normal file
8
.scratch/workbench-poll-cost/work.md
Normal file
@ -0,0 +1,8 @@
|
||||
# Cut the remaining work-buffer poll cost and keep dashboard caches warm
|
||||
|
||||
Goal: after #63, the 3s work-buffer poll still spent ~126ms re-resolving display labels (full run documents, up to 6MB) and ~136ms in the store; dashboard caches were flushed by every autosave
|
||||
Agent: Claude Code (Opus 5.5), desktop session 2026-10-28
|
||||
Base: origin/dev @ 8b96632e
|
||||
Scope: internal/api/annotation_work_buffer.go (2-minute display cache), internal/store/annotation_work_buffer.go (skip rereads for slots the active scan already counted), internal/api/server.go (draft, review-session, review-draft and work-buffer saves keep dashboard caches), tests
|
||||
Out of scope: run document size, other list endpoints' enrichment, poll interval, dashboard computations themselves
|
||||
Risk: no API, data or index change; pool labels may lag a project/workflow rename by up to 2 minutes; dashboards may lag a draft save by up to the existing 45s TTL
|
||||
9
.scratch/workbench-ui-polish/work.md
Normal file
9
.scratch/workbench-ui-polish/work.md
Normal file
@ -0,0 +1,9 @@
|
||||
# Polish annotation, review, acceptance and rework workbench UI
|
||||
|
||||
Goal: make the annotator / QC / final-acceptance workbenches (normal and focus layouts, rework and re-review states) tidier and smoother without changing any function; interaction changes need the user's approval first
|
||||
Agent: Claude Code (desktop session, 2026-10-27)
|
||||
Base: codex/frontend-polish-20261026 @ de96cfc2 (unmerged; it carries the production line review-runtime-trace, whose annotation workbench differs from origin/dev by ~1300 lines). Confirmed by the user on 2026-10-27.
|
||||
Scope: src/index.css, src/styles/{capture-workspace,review-workspace,review-captions}.css, display-only class names in src/pages/AnnotationOperations.tsx and src/components/* used by the four workbenches
|
||||
Approved interaction changes (2026-10-27 compare sheet): the task-scoped 当前任务连接诊断 link joins each layout's top row; a read-only quality review shows its own footer and takeover hint instead of the annotator slice bar. Declined: moving the QC opinion panel below the video; adding an action list to review focus.
|
||||
Out of scope: other interaction changes (entry points, shortcuts, panel positions, confirmations, auto-claim/continuation behaviour), API, data, other pages
|
||||
Risk: display plus one footer-routing fix; no API, data or shortcut changes
|
||||
76
AGENTS.md
76
AGENTS.md
@ -2,46 +2,23 @@
|
||||
|
||||
## Working Root
|
||||
|
||||
- This repository directory is the single working root; the sibling `~/Desktop/fanyu` folder is legacy and will be retired.
|
||||
- Cluster kubeconfig (`fanyu.conf`), BOS credential CSV, downloaded captures, and the local workspace mount are being migrated under this repo's untracked local data path (see `docs/HANDOFF.md` § 0 for the live layout).
|
||||
- The repository root is `/Users/d-robotics/Desktop/fanyu/droboticflow`. The unified development checkout is `local-data/worktrees/recent-integration` on `dev`. The main checkout and existing unmerged worktrees retain protected work; do not reset, switch or discard them as part of routine development.
|
||||
- Cluster kubeconfig (`fanyu.conf`), BOS credential CSV, downloaded captures, and the local workspace mount live under this repo's untracked `local-data/` directory; `~/Desktop/fanyu` still holds legacy copies (`fanyu.conf`, `泛宇-aksk.csv`) and is being retired (see `docs/HANDOFF.md` § 0).
|
||||
- Before reading code to explain production behavior or starting changes, run `bash scripts/local/branch-freshness.sh` (read-only). If it reports the checkout is behind `origin/dev`, missing a live build commit, or only locally compared without remote/live confirmation, tell the user and work in a worktree that contains the live commit instead of a stale checkout.
|
||||
|
||||
## Engineering Principles
|
||||
|
||||
These principles guide implementation choices. Specific business contracts and this document's release, authorization, and data safety rules take precedence.
|
||||
|
||||
1. Check contracts and implementation first. Follow the Domain docs reading rules to review relevant business documentation,
|
||||
ADRs, code, and tests. Distinguish current behavior, approved designs that are not yet implemented, and superseded rules.
|
||||
Identify specific conflicts between the current request and existing agreements; ask the user when a conflict affects business outcomes and cannot be resolved independently.
|
||||
1. Check contracts and implementation first. Read `CONTEXT.md`, relevant ADRs, business docs, code, and tests (`docs/agents/domain.md`). Distinguish current behavior, approved unimplemented designs, and superseded rules. Use the controlled Chinese terms from `CONTEXT.md` in customer-facing copy, specs, issues, and domain discussions; ask the user when a request conflicts with existing agreements and affects business outcomes.
|
||||
|
||||
2. Define the compatibility scope before making changes. For APIs, Mongo records, workflow definitions, operator inputs and outputs,
|
||||
delivery formats, or task states, check callers, existing data, and in-flight tasks.
|
||||
Before removing an old path, establish that compatibility is no longer needed or migration is complete, and explain the rollback impact.
|
||||
Preserve migration and recovery paths that still serve a purpose. Internal implementations may be refactored directly when contracts remain unchanged.
|
||||
2. Define the compatibility scope before making changes. For APIs, Mongo records, workflow definitions, operator inputs/outputs, delivery formats, or task states, check callers, existing data, and in-flight tasks. Preserve active migration and recovery paths; before removing an old path, verify migration completion and explain rollback impact. Internal implementations may be refactored directly when contracts remain unchanged.
|
||||
|
||||
3. Choose the simplest solution that meets current requirements and known constraints. Abstractions, configuration, and indirection must serve a concrete purpose.
|
||||
Authentication, permission isolation, data consistency, and necessary retries and recovery are part of the requirements.
|
||||
For temporary solutions, state their scope, limitations, and replacement conditions; avoid shortcuts known to fall short of confirmed requirements.
|
||||
3. Keep solutions simple, incremental, and verifiable. Abstractions and indirection must serve a concrete requirement; authentication, permission isolation, data consistency, retries, and recovery are part of requirements. For multi-layer changes, connect the smallest complete flow first and validate replacement paths before removing old ones. State the scope, limitations, and replacement conditions of any temporary solution.
|
||||
|
||||
4. Implement incrementally through verifiable business flows. For changes spanning multiple layers, first connect the smallest complete flow required by the current request,
|
||||
then extend its capabilities. Validate replacement paths before removing existing implementations.
|
||||
A minimal version determines implementation order; the final delivery must still meet all acceptance criteria for the current request.
|
||||
4. Follow responsibility boundaries and reuse existing capabilities. Place changes in the module responsible for that behavior. Enforce permissions and business constraints on the server; use frontend validation for interaction feedback and keep generated files updated from authoritative sources. Inspect existing code, standard libraries, and installed dependencies before adding new ones, and consult primary sources for unfamiliar or hard-to-reverse choices.
|
||||
|
||||
5. Follow existing responsibility boundaries. Locate the relevant components, API wrappers, business logic, storage, and execution entry points,
|
||||
and place changes in the module responsible for that behavior. Enforce permissions and business constraints on the server;
|
||||
use frontend validation for interaction feedback. Keep shared rules consistent and update generated files from their authoritative sources.
|
||||
|
||||
6. Reuse before adding dependencies. Before writing a new implementation or adding a dependency, inspect existing project code, standard libraries,
|
||||
and the documentation, types, and available capabilities for installed dependency versions. When existing capabilities are insufficient, choose well-maintained
|
||||
libraries that reduce overall complexity, and explain their purpose and adoption costs.
|
||||
|
||||
7. Consult established approaches where useful. For unfamiliar, consequential, or hard-to-reverse design choices,
|
||||
consult official sources or relevant approaches in mature products, and explain the conditions under which they apply.
|
||||
Follow existing project patterns for routine changes; adapt external approaches to this project's business contracts.
|
||||
|
||||
8. Complete delivery with verification evidence. Run the checks required for the scope of the change and verify relevant behavior in the local replica environment.
|
||||
For changes involving asynchronous processing, persistence, or compatibility, cover the relevant failure, restart recovery, and legacy data scenarios.
|
||||
Compare existing failures against the baseline by specific test case and cause, rather than failure counts alone.
|
||||
Update the corresponding contracts when behavior changes, and clearly report what passed, failed, or remains unverified.
|
||||
5. Complete delivery with verification evidence. Run the scoped checks (`docs/agents/verification.md`) and verify relevant behavior in the appropriate local environment. Cover failure, restart recovery, and legacy data scenarios for async, persistence, or compatibility changes. Compare existing failures against the baseline by specific test case and cause (`npm run test:frontend:gate` / `npm run test:go:gate`), update contracts when behavior changes, and clearly report what passed, failed, or remains unverified.
|
||||
|
||||
## Deployment Environment
|
||||
|
||||
@ -52,34 +29,43 @@ These principles guide implementation choices. Specific business contracts and t
|
||||
|
||||
## Git Workflow
|
||||
|
||||
- Before assuming a remote target, run `git remote -v`.
|
||||
- After making code or documentation changes for the user, stage only the files changed for that task.
|
||||
- Before assuming a remote target, inspect the remote URL with credentials redacted (`git remote -v | sed -E 's#//[^@/[[:space:]]+@#//<redacted>@#g'`). Never print raw credential-bearing `.git/config` URLs into logs or reports; prefer migrating Git credentials to the system Keychain.
|
||||
- After making code or documentation changes for the user, stage only the files changed for that task. Do not stage or commit unrelated user changes already present in the working tree.
|
||||
- Commit with an English, emoji-prefixed commit message.
|
||||
- **Push only when the user explicitly says push.** Default action after commit: stay local.
|
||||
- When push is approved, push the user's personal feature branch only; never push `dev` or `poc` directly.
|
||||
- Do not stage or commit unrelated user changes already present in the working tree.
|
||||
- `dev` is the single integration and release mainline. Reuse the unified `dev` checkout for normal authorized work. Create a branch or worktree only when the user explicitly requests it; record its purpose and merge-back plan first. Read-only diagnosis creates neither.
|
||||
- Existing unmerged branches and uncommitted work remain untouched until the user requests their integration or disposal. Completed branches are cleaned only after their commits are in `origin/dev`, their work is preserved, and no service uses the worktree. Follow `docs/agents/branch-workflow.md` for synchronization and cleanup.
|
||||
- Push and PR each require explicit user authorization. An explicit request to synchronize remote `dev` authorizes that bounded fast-forward push; it does not authorize a deployment or unrelated pending changes. Never force-push or rewrite `dev` history. Otherwise commit locally and report the state.
|
||||
- When a task ends, run `python3 scripts/agent_status.py --no-fetch` (or with fetch if network/remote checks are needed) and report the branch's local state to the user.
|
||||
|
||||
## Release Workflow
|
||||
|
||||
- For release preparation, deployment, rollback, or resuming release work, read `docs/release/README.md` first and run `python3 scripts/release.py status <release-id>` when a record exists. Follow the recorded state and evidence; a successful rollout alone is not business acceptance.
|
||||
- Fanyu image releases use `scripts/release.py`. Configuration changes or migrations outside its supported scope require a separately reviewed plan and the corresponding user authorization.
|
||||
- Every new release must use exactly the synchronized local `dev` and remote `origin/dev` tip at release time. Integrate and verify fixes on `dev` before preparing a release; unmerged-branch releases have no exception. `scripts/release.py` checks both refs during prepare and refreshes `origin/dev` again before deployment. Existing release records and unchanged components retain their historical identities; later development may advance `dev` beyond the deployed version.
|
||||
- Fanyu image releases use `scripts/release.py` (`scripts/deploy-k8s.sh` blocks Fanyu). Configuration changes or migrations outside its supported scope require a separately reviewed plan and the corresponding user authorization.
|
||||
|
||||
## Credentials
|
||||
|
||||
- Never hardcode credentials (BOS AK/SK, Mongo, Gitea token, cluster kubeconfig) in any tracked file.
|
||||
- Read secrets from untracked local files or environment variables; see `scripts/local/` for the established pattern.
|
||||
- Never hardcode credentials (BOS AK/SK, Mongo, Gitea token, cluster kubeconfig) in any tracked file, and never echo raw credentials from untracked files (`.git/config`, `local-data/*`) into conversation output, `.scratch/` notes, or test logs.
|
||||
- Read secrets from untracked local files, environment variables, or the system Keychain; see `scripts/local/` for the established pattern.
|
||||
|
||||
## Release Approval and Customer Data Safety
|
||||
|
||||
- Creating or submitting a pull request requires the user's explicit approval for that specific action; local review and commits may remain unsubmitted.
|
||||
- Deploying to any company cluster requires the user's explicit approval immediately before the deployment; verification work must stop when that approval is absent.
|
||||
- Pushing branches, creating/submitting a pull request, and deploying to any company cluster require explicit user approval (either individually or via an explicit combined instruction such as "push and open PR"); approving one action never implicitly authorizes another. Local review and commits remain unsubmitted until approved.
|
||||
- Cluster verification is read-only against customer data: use isolated synthetic fixtures or existing records without mutation, and never delete, overwrite, or add customer data. If a test requires a write or destructive operation, stop and obtain explicit approval for that exact operation.
|
||||
|
||||
## Development verification
|
||||
|
||||
- Before choosing checks for a change, read `docs/agents/verification.md`. Start with `npm run verify:plan -- --base <task-base>`; use quick checks while editing and affected task checks once before delivery. Expand only for changed dependencies, failures or uncovered risk.
|
||||
- Reuse unchanged evidence within a task using the recorded source, dependency, configuration and environment identities. Report skipped, timed-out and unmapped coverage as pending; quick checks never replace release evidence.
|
||||
- Keep local implementation and verification moving within the authorized scope. The existing push, PR, production-data and deployment approval rules still apply.
|
||||
|
||||
## Local Environment
|
||||
|
||||
- Local replica stack (Vite 5173, Go API 3001, snapshot Mongo 27018) is the default verification surface before any PR.
|
||||
- Local Mongo environments serve distinct purposes (`docs/HANDOFF.md` § 0, `docs/local-dev-guide.zh-CN.md` § 0):
|
||||
- **Snapshot Mongo (`127.0.0.1:27018`, `env-local-snapshot.sh`)**: realistic replica of production data structure for workbench/API verification before a PR. Keep shared snapshot task claim states clean before running Go baseline gates (`npm run test:go:gate`).
|
||||
- **Empty/isolated Mongo (`127.0.0.1:27017`, `env-local.sh`, or per-test isolated databases on 27018)**: synthetic fixtures, unit/integration tests, and clean-slate workflow CRUD debugging.
|
||||
- Verification commands and known pitfalls (upstream test debt, session auth flag, workspace mount) are documented in `docs/HANDOFF.md`.
|
||||
- Comparing test failures against the known-failure baseline ALWAYS goes through `npm run test:frontend:gate` / `npm run test:go:gate` (they diff against `tests/known-failures.json`; only NEW failures fail). Never hand-diff failure lists with stash/scratch files. Formatting gate: `npm run format:check`.
|
||||
- Comparing test failures against the known-failure baseline ALWAYS goes through `npm run test:frontend:gate` / `npm run test:go:gate` (they diff against `tests/known-failures.json`; only NEW failures fail). Never hand-diff failure lists with stash/scratch files. Quick edits check changed-file formatting; the full formatting gate remains `npm run format:check` at integration/release scope.
|
||||
- The company cluster and BOS bucket are read-only by default; any write requires explicit user approval.
|
||||
|
||||
## Agent skills
|
||||
@ -99,3 +85,7 @@ Use a single-context layout: root `CONTEXT.md` and `docs/adr/`. Before exploring
|
||||
### Coding standards
|
||||
|
||||
Before writing or reviewing pool/list eligibility logic (claim buttons, `canClaim`, task-pool gating), read `docs/CODING_STANDARDS.md` — eligibility flags are server-shipped; the UI renders them, it never rebuilds them.
|
||||
|
||||
### UI copy and presentation
|
||||
|
||||
Before adding or changing any customer-facing page, component, or copy, read `docs/ui/copy-guidelines.md`. Its minimal-copy rules and applicable visual checks are required acceptance criteria for implementation and review, including bug fixes and generated UI. Apply them to new work as well as existing pages.
|
||||
|
||||
28
CONTEXT.md
28
CONTEXT.md
@ -2,6 +2,14 @@
|
||||
|
||||
以下词汇描述人工标注与审核中的业务对象。
|
||||
|
||||
**分类标签**:管理员为字典词条明确维护的 tags 集合,用于按已确认类别归组;它不同于词条分类 category、别名 aliases 或动作描述文本。确认后的词条身份、版本和标签共同构成当次分类快照,字典后续更新不改写该快照。
|
||||
|
||||
**最终分类结果**:最终验收通过的固定版本中,视频各区间的基础分类、动作细分、显式无效及舍弃判断。未写动作描述不撤销基础分类;审核批注和返工过程不属于分类结果。
|
||||
|
||||
**动作有效标签**:动作独立选择描述字典词条时,使用当次选择冻结的标签;未独立选择时,继承所属切片冻结的分类标签。是否填写自由描述不决定继承,无效判断与标签分别保留。
|
||||
|
||||
**原始区间定位**:以原始采集及 part 的文件身份和硬件时间戳定位人工确认区间;切片内相对时间与原始 part 相对时间是不同坐标,不能混用。下游按定位和分类处理原始数据,不依赖平台内部审核文件。
|
||||
|
||||
## 标注对象
|
||||
|
||||
**Capture(源采集)**:一次源采集所关联的双目视频、时间戳与传感器数据,是本流程组织人工处理和审核的对象。
|
||||
@ -20,6 +28,12 @@ _Avoid_:操作次数(同一份数据可以重复操作,但期间完成份
|
||||
|
||||
**返工重提次数**:任务被退回后再次成功送检的次数,与收到正式打回决定的次数分别统计。内部数据版本的增加不代表发生返工。
|
||||
|
||||
**审查次数**:质检员或验收员在所选期间作出的正式通过与退回决定,按决定所涉 part 计数;同一 part 返工后再次审查重复计入,其中再次审查另计为复审。终审一次决定涉及多个 part 时按 part 分别计入。它与标注员产出分开,不相加。
|
||||
_Avoid_:审查份数(同一 part 可以计入多次)
|
||||
|
||||
**人天**:一名人员在一个本地自然日至少有一次本角色正式工作即计 1 人天:标注员为成功送检(含返工重提),质检员、验收员为正式审查决定。人均日产出为期间视频小时除以人天,不是实际工时。
|
||||
_Avoid_:工时、出勤时长
|
||||
|
||||
**问题对象数**:每轮正式打回中具有意见的切片、动作及时间点对象数,同一对象的旧版多条意见只计一个对象,原文保留。停用前的整体意见不再计入。它不等于已独立证实的错误数量。
|
||||
|
||||
**问题覆盖视频时长**:正式打回意见所定位的视频区间,在每轮同一来源内去除重叠后的覆盖时长,跨轮累计。时间点意见只定位单一时间点,不计入覆盖时长;缺少可靠区间的记录不推定为整段视频,也不等于实际工时或精确缺陷持续时间。
|
||||
@ -96,6 +110,8 @@ _Avoid_:公共可领取任务池(其中的任务尚未归属当前标注员
|
||||
|
||||
## 审查
|
||||
|
||||
**审查追溯**:已授权任务的只读事件投影。任务来源与流转记录合并为右栏顶部的一张可折叠卡片,标题行显示当前版本与打回次数,默认展示最近两条流转;普通任务卡可批量附加人员、供应商和退回统计。缺失值用 `-`,已知零次保留 `0`;版本来自修订字段,退回次数来自正式退回事件,不使用轮数或版本相减。历史没有创建起点时,首次提交和总退回次数保留未知。最终验收继续遵守供应商匿名规则。辅助统计失败不阻断任务列表,不回填或改写历史数据。
|
||||
|
||||
**审查**:质检审核与最终验收的统称,操作者核对已有结果、记录问题并作出通过或退回决定,不直接修改原标注结果。
|
||||
|
||||
**质检审核**:对标注员提交的切片、动作结果及相关证据进行检查的环节。不通过的结果回到标注环节返工。
|
||||
@ -121,7 +137,9 @@ _Avoid_:回退意见(易与撤销操作混淆)
|
||||
|
||||
**连续审查**:审查者在当前审核环节接续处理任务的工作方式;最终验收跟随项目筛选,“全部项目”跨有权限的项目接续,指定项目仅在该项目接续,质检仍在当前任务所属项目接续。单纯领取保留可领取列表,“继续处理”进入任务并启动连续审查;当前决定实际成功后才进入下一条,暂停不撤回已提交决定。
|
||||
|
||||
**返工任务**:质检退回后定向归还给原标注员、按意见修改并重新送检的任务;原标注员仍有资格时直接归还本人,不再有资格时按既有任务归属规则处理,不回到公共池随机领取。
|
||||
**返工任务**:质检退回后按意见修改并重新送检的任务。原标注员仍有资格时定向归还本人;原标注员已删除时,保留正式标注和质检意见,在原供应商有项目权限且容量允许的标注员中按负载优先、同负载随机分配,不混入普通随机领取。
|
||||
|
||||
**接手返工**:接手已删除原标注员留下的返工任务。每名标注员跨项目最多同时接手一条,不触发本人返工阻止领取新任务的规则;历史意见与责任不因接手而改写。
|
||||
_Avoid_:公共池任务(返工任务定向归属,不参与随机领取)
|
||||
|
||||
**意见处理状态**:标注员对某条退回意见的处理在界面上的呈现——"未修改(红)"或"已修改待复审(灰)"。已修改由"意见目标相对退回基线已改动"自动判定(切片内容含片内动作,不落库、不等于质检确认解决);另有免打字的一键"不改了"(跳过留痕,落库且复审可见),用于误报/不适用。它不是审核意见,也不改写原意见。
|
||||
@ -138,6 +156,8 @@ _Avoid_:删除意见(确认解决不删除任何历史记录)
|
||||
|
||||
## 账号与项目授权
|
||||
|
||||
**已删除账号身份**:保留原用户 ID、姓名、手机号和历史归属的不可重新启用记录。删除完成后手机号可用于创建新身份,新账号不继承旧账号的任务或历史;仅停用及删除未完成的账号继续占用手机号。
|
||||
|
||||
**账号角色**:一个账号只有一个角色。管理员独立;供应商管理员、标注员、质检审核员和最终验收员均归属一个供应商。
|
||||
|
||||
**项目成员**:账号参与项目的授权关系,生产职责继承账号角色。一个项目可以同时包含多个供应商,各供应商可以在该项目内处理其归属的任务;不能把项目成员角色当作额外账号权限。
|
||||
@ -165,6 +185,12 @@ _Avoid_:客户公共池(内部测试不参与客户任务的竞争领取)
|
||||
**测试任务副本**:以经批准的客户样本为来源、拥有独立身份和处理历史的内部测试任务;副本的修改不回写来源任务。
|
||||
_Avoid_:供应商任务副本(不代表给每家生产供应商复制客户任务)
|
||||
|
||||
**内部测试环境**:与客户生产隔离、一次运行一个候选版本的完整平台,用经批准的少量客户样本模拟客户生产处理流程;其中的账号、任务、审查和交付不计入客户生产、统计或交付出口。
|
||||
_Avoid_:测试 pod(一套环境包含多个组件)、生产内测试项目(与客户共用业务数据,不构成环境隔离)
|
||||
|
||||
**版本晋升**:把已在内部测试环境验收的同一候选版本发布到客户生产;只带走版本本身,不带走测试数据、账号或配置,每次发布仍需单独授权。测试通过不等于获准发布。
|
||||
_Avoid_:推送 pod、迁移测试环境
|
||||
|
||||
**撤销供应商项目授权**:停止供应商领取该项目的新任务,但保留其既有任务的标注、质检与返工处理资格,直至存量完成;不等于停用账号或释放已领取任务。
|
||||
|
||||
**生产统计异常**:仅指当前正式处理中的执行故障,包括运行失败、源采集处理失败、切片或送检处理作业失败、交付打包失败。供应商归属不同、部分未领取、归属待核对、审核退回、业务升级处理及正常等待不单独计为异常;这些状态保留在明细,不增加红色异常数量。
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
ARG DROBOTICFLOW_BUILD_COMMIT=unknown
|
||||
ARG DROBOTICFLOW_BUILD_TIME=unknown
|
||||
ARG API_RUNTIME_IMAGE=debian:bookworm-slim
|
||||
|
||||
FROM node:22-alpine AS web-build
|
||||
FROM node:22-alpine@sha256:c610fcdfb1d5b4740dd70c284ed3cb16bb857e0f7166196e36a5501df7a3aa32 AS web-build
|
||||
WORKDIR /app
|
||||
|
||||
COPY package*.json ./
|
||||
COPY scripts/check-git-hooks.mjs ./scripts/check-git-hooks.mjs
|
||||
COPY scripts/lib/git-hooks.mjs ./scripts/lib/git-hooks.mjs
|
||||
RUN npm ci
|
||||
|
||||
COPY index.html metadata.json package.json tsconfig.json vite.config.ts ./
|
||||
@ -14,7 +16,7 @@ COPY src ./src
|
||||
COPY public ./public
|
||||
RUN npm run build:web
|
||||
|
||||
FROM golang:1.24-bookworm AS go-build
|
||||
FROM golang:1.24-bookworm@sha256:1a6d4452c65dea36aac2e2d606b01b4a029ec90cc1ae53890540ce6173ea77ac AS go-build
|
||||
WORKDIR /src
|
||||
ARG GOPROXY=https://proxy.golang.org,direct
|
||||
|
||||
@ -25,23 +27,31 @@ COPY cmd ./cmd
|
||||
COPY internal ./internal
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /out/droboticflow-api ./cmd/api
|
||||
|
||||
FROM debian:bookworm-slim AS runtime
|
||||
FROM ${API_RUNTIME_IMAGE} AS runtime
|
||||
# Production release script supplies a pinned prepared runtime. Direct local/POC
|
||||
# builds retain the original Debian setup unless explicitly opted in.
|
||||
ARG API_RUNTIME_PREPARED=0
|
||||
USER root
|
||||
WORKDIR /app
|
||||
RUN if [ "$API_RUNTIME_PREPARED" = "1" ]; then \
|
||||
test -x /usr/bin/ffprobe && getent passwd 10001; \
|
||||
else \
|
||||
apt-get update && apt-get install -y --no-install-recommends ca-certificates ffmpeg && rm -rf /var/lib/apt/lists/* && \
|
||||
groupadd --system --gid 10001 droboticflow && useradd --system --uid 10001 --gid droboticflow --home-dir /app --shell /usr/sbin/nologin droboticflow; \
|
||||
fi
|
||||
# A compatibility runtime may be an older API image. Never retain its old app.
|
||||
RUN rm -rf /app/dist /usr/local/bin/droboticflow-api
|
||||
COPY --from=web-build --chown=10001:10001 /app/dist ./dist
|
||||
COPY --from=go-build /out/droboticflow-api /usr/local/bin/droboticflow-api
|
||||
|
||||
# Application identity must not invalidate the OS dependency layers.
|
||||
ARG DROBOTICFLOW_BUILD_COMMIT
|
||||
ARG DROBOTICFLOW_BUILD_TIME
|
||||
WORKDIR /app
|
||||
ENV PORT=3001
|
||||
ENV DIST_DIR=/app/dist
|
||||
ENV PORT=3001 DIST_DIR=/app/dist
|
||||
ENV DROBOTICFLOW_IMAGE_BUILD_COMMIT=${DROBOTICFLOW_BUILD_COMMIT}
|
||||
ENV DROBOTICFLOW_IMAGE_BUILD_TIME=${DROBOTICFLOW_BUILD_TIME}
|
||||
LABEL org.opencontainers.image.revision=${DROBOTICFLOW_BUILD_COMMIT}
|
||||
LABEL org.opencontainers.image.created=${DROBOTICFLOW_BUILD_TIME}
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates ffmpeg && rm -rf /var/lib/apt/lists/*
|
||||
RUN groupadd --system --gid 10001 droboticflow && useradd --system --uid 10001 --gid droboticflow --home-dir /app --shell /usr/sbin/nologin droboticflow
|
||||
|
||||
COPY --from=web-build --chown=10001:10001 /app/dist ./dist
|
||||
COPY --from=go-build /out/droboticflow-api /usr/local/bin/droboticflow-api
|
||||
|
||||
EXPOSE 3001
|
||||
USER 10001:10001
|
||||
CMD ["droboticflow-api"]
|
||||
|
||||
9
Dockerfile.api-runtime
Normal file
9
Dockerfile.api-runtime
Normal file
@ -0,0 +1,9 @@
|
||||
# Build/publish separately after approval; record this image's immutable digest
|
||||
# in docs/release/api-runtime.json. No application or customer data is copied.
|
||||
FROM docker.io/library/debian:bookworm-slim@sha256:88200866dfff7ea7f5cbcb6ec7c8a701889efe6fe859fe64d6990e4b07ea4171
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates ffmpeg && \
|
||||
dpkg-query -W > /runtime-packages.txt && rm -rf /var/lib/apt/lists/* && \
|
||||
groupadd --system --gid 10001 droboticflow && \
|
||||
useradd --system --uid 10001 --gid droboticflow --home-dir /app --shell /usr/sbin/nologin droboticflow
|
||||
WORKDIR /app
|
||||
USER 10001:10001
|
||||
18
Dockerfile.package.prebuilt
Normal file
18
Dockerfile.package.prebuilt
Normal file
@ -0,0 +1,18 @@
|
||||
# The base must be the reviewed independent package runtime, pinned by digest.
|
||||
# The runner and its dependencies stay on that base; only package source changes.
|
||||
ARG PACKAGE_BASE_IMAGE
|
||||
FROM ${PACKAGE_BASE_IMAGE}
|
||||
ARG DROBOTICFLOW_BUILD_COMMIT=unknown
|
||||
ARG DROBOTICFLOW_BUILD_TIME=unknown
|
||||
ENV DROBOTICFLOW_IMAGE_BUILD_COMMIT=${DROBOTICFLOW_BUILD_COMMIT}
|
||||
ENV DROBOTICFLOW_IMAGE_BUILD_TIME=${DROBOTICFLOW_BUILD_TIME}
|
||||
ENV DROBOTICFLOW_OPERATOR_ID=operator-builtin-package
|
||||
ENV DROBOTICFLOW_OPERATOR_SLUG=package
|
||||
ENV DROBOTICFLOW_OPERATOR_HANDLER=builtin_result_package
|
||||
ENV DROBOTICFLOW_OPERATOR_SOURCE=/app/backend/operators/builtin/package/operator.py
|
||||
LABEL org.opencontainers.image.revision=${DROBOTICFLOW_BUILD_COMMIT}
|
||||
LABEL org.opencontainers.image.created=${DROBOTICFLOW_BUILD_TIME}
|
||||
COPY --chown=10001:10001 operator-repos/builtin/package/src/operator.py /app/backend/operators/builtin/package/operator.py
|
||||
COPY --chown=10001:10001 operator-repos/builtin/package/src/operator.py /app/operator-repos/builtin/package/src/operator.py
|
||||
USER 10001:10001
|
||||
ENTRYPOINT ["python", "/app/backend/operator-runner/main.py"]
|
||||
19
Dockerfile.query-read-builder
Normal file
19
Dockerfile.query-read-builder
Normal file
@ -0,0 +1,19 @@
|
||||
FROM golang:1.24-bookworm@sha256:1a6d4452c65dea36aac2e2d606b01b4a029ec90cc1ae53890540ce6173ea77ac AS build
|
||||
WORKDIR /src
|
||||
ARG GOPROXY=https://proxy.golang.org,direct
|
||||
COPY go.mod go.sum ./
|
||||
RUN GOPROXY="${GOPROXY}" go mod download
|
||||
COPY cmd/query-read-builder ./cmd/query-read-builder
|
||||
COPY internal ./internal
|
||||
RUN mkdir -p /out/tmp && chmod 1777 /out/tmp
|
||||
RUN CGO_ENABLED=0 go build -trimpath -o /out/query-read-builder ./cmd/query-read-builder
|
||||
|
||||
# A static binary only needs trusted CA roots; no media/worker tools or app code.
|
||||
FROM scratch
|
||||
COPY --from=build --chmod=1777 /out/tmp /tmp
|
||||
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
||||
COPY --from=build /out/query-read-builder /query-read-builder
|
||||
ARG DROBOTICFLOW_BUILD_COMMIT=unknown
|
||||
LABEL org.opencontainers.image.revision=${DROBOTICFLOW_BUILD_COMMIT}
|
||||
USER 10001:10001
|
||||
ENTRYPOINT ["/query-read-builder"]
|
||||
19
Dockerfile.query-replica
Normal file
19
Dockerfile.query-replica
Normal file
@ -0,0 +1,19 @@
|
||||
FROM golang:1.24-bookworm@sha256:1a6d4452c65dea36aac2e2d606b01b4a029ec90cc1ae53890540ce6173ea77ac AS build
|
||||
WORKDIR /src
|
||||
ARG GOPROXY=https://proxy.golang.org,direct
|
||||
COPY go.mod go.sum ./
|
||||
RUN GOPROXY="${GOPROXY}" go mod download
|
||||
COPY cmd/query-replica ./cmd/query-replica
|
||||
COPY internal ./internal
|
||||
RUN mkdir -p /out/tmp && chmod 1777 /out/tmp
|
||||
RUN CGO_ENABLED=0 go build -trimpath -o /out/query-replica ./cmd/query-replica
|
||||
|
||||
# A static binary only needs trusted CA roots; no media/worker tools or app code.
|
||||
FROM scratch
|
||||
COPY --from=build --chmod=1777 /out/tmp /tmp
|
||||
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
||||
COPY --from=build /out/query-replica /query-replica
|
||||
ARG DROBOTICFLOW_BUILD_COMMIT=unknown
|
||||
LABEL org.opencontainers.image.revision=${DROBOTICFLOW_BUILD_COMMIT}
|
||||
USER 10001:10001
|
||||
ENTRYPOINT ["/query-replica"]
|
||||
25
Dockerfile.query-shadow-monitor
Normal file
25
Dockerfile.query-shadow-monitor
Normal file
@ -0,0 +1,25 @@
|
||||
FROM scratch AS kubectl-artifact
|
||||
|
||||
FROM --platform=$BUILDPLATFORM golang:1.24-bookworm@sha256:1a6d4452c65dea36aac2e2d606b01b4a029ec90cc1ae53890540ce6173ea77ac AS build
|
||||
WORKDIR /src
|
||||
ARG GOPROXY=https://proxy.golang.org,direct
|
||||
COPY go.mod go.sum ./
|
||||
RUN GOPROXY="${GOPROXY}" go mod download
|
||||
COPY cmd/query-replica ./cmd/query-replica
|
||||
COPY internal ./internal
|
||||
ARG TARGETARCH
|
||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH="${TARGETARCH}" go build -trimpath -o /out/query-replica ./cmd/query-replica
|
||||
ARG KUBECTL_SHA256
|
||||
COPY --from=kubectl-artifact /kubectl /out/kubectl
|
||||
RUN test -n "${KUBECTL_SHA256}" && \
|
||||
echo "${KUBECTL_SHA256} /out/kubectl" | sha256sum --check --strict
|
||||
|
||||
FROM python@sha256:9534e5a8e315485d4061ed659af0fd78a284c015f9b73661b41d6bab25604534
|
||||
COPY --from=build --chmod=0555 /out/kubectl /usr/local/bin/kubectl
|
||||
COPY --from=build --chmod=0555 /out/query-replica /ops/query-replica
|
||||
COPY --chmod=0444 scripts/local/query-shadow-monitor.py scripts/local/query-shadow-observer.py scripts/local/query-shadow-work-health.py scripts/local/query_shadow_health.py /ops/
|
||||
ARG DROBOTICFLOW_BUILD_COMMIT=unknown
|
||||
LABEL org.opencontainers.image.revision=${DROBOTICFLOW_BUILD_COMMIT}
|
||||
ENV HOME=/tmp PYTHONDONTWRITEBYTECODE=1
|
||||
USER 10001:10001
|
||||
ENTRYPOINT ["python3", "-u", "/ops/query-shadow-monitor.py"]
|
||||
@ -120,8 +120,10 @@ def _validate_transcoded_pts(video: pathlib.Path, pts: pathlib.Path, expected_fr
|
||||
return {"videoFrames": frames, "ptsRows": count, "sourceDurationSeconds": duration, "startTimestampUs": first, "endTimestampUs": previous, "validation": "count_and_timestamp_checks_passed", "timestamps": "original_unmodified"}
|
||||
|
||||
|
||||
def _validate_raw_imu(path: pathlib.Path, start: int, end: int) -> None:
|
||||
def _validate_raw_imu(path: pathlib.Path, start: int, end: int, *, require_coverage: bool = True) -> None:
|
||||
ranges = {}
|
||||
previous = None
|
||||
pair = set()
|
||||
with path.open(encoding="utf-8-sig", newline="") as handle:
|
||||
reader = csv.DictReader(handle)
|
||||
if not {"timestamp_us", "x", "y", "z", "type"}.issubset(reader.fieldnames or []):
|
||||
@ -133,9 +135,27 @@ def _validate_raw_imu(path: pathlib.Path, start: int, end: int) -> None:
|
||||
raise ValueError("invalid value")
|
||||
except (ValueError, TypeError) as exc:
|
||||
raise RuntimeError(f"原始 IMU 第 {reader.line_num} 行无效") from exc
|
||||
kind = row["type"].strip().lower()
|
||||
kind = (row.get("type") or "").strip().lower()
|
||||
if kind not in {"accel", "gyro"}:
|
||||
raise RuntimeError(f"原始 IMU 第 {reader.line_num} 行类型无效,只支持 accel/gyro")
|
||||
if previous is not None and timestamp < previous:
|
||||
raise RuntimeError(f"原始 IMU 第 {reader.line_num} 行时间戳未递增")
|
||||
if timestamp != previous:
|
||||
if previous is not None and pair != {"accel", "gyro"}:
|
||||
raise RuntimeError(f"原始 IMU 时间戳 {previous} 缺少 accel/gyro 配对")
|
||||
pair = set()
|
||||
if kind in pair:
|
||||
raise RuntimeError(f"原始 IMU 第 {reader.line_num} 行 {kind} 重复")
|
||||
pair.add(kind)
|
||||
previous = timestamp
|
||||
low, high = ranges.get(kind, (timestamp, timestamp))
|
||||
ranges[kind] = (min(low,timestamp), max(high,timestamp))
|
||||
if previous is None:
|
||||
raise RuntimeError("原始 IMU 没有有效数据")
|
||||
if pair != {"accel", "gyro"}:
|
||||
raise RuntimeError(f"原始 IMU 时间戳 {previous} 缺少 accel/gyro 配对")
|
||||
if not require_coverage:
|
||||
return
|
||||
for kind in ("accel", "gyro"):
|
||||
if kind not in ranges or ranges[kind][0] > start or ranges[kind][1] < end:
|
||||
raise RuntimeError(f"原始 IMU {kind} 未覆盖视频 PTS 时间范围")
|
||||
@ -218,9 +238,8 @@ def _validate_fallback_pair(path, paired, entries, source_path, output_dir, para
|
||||
if raw_human:
|
||||
if not paired.get("imu"):
|
||||
raise RuntimeError("原始数据人工版缺少 IMU")
|
||||
# Temporarily bypass the raw-human IMU content/coverage gate: source
|
||||
# sensor streams can cross part boundaries. Keep the paired IMU intact.
|
||||
# _validate_raw_imu(materialize(paired["imu"]), validation["startTimestampUs"], validation["endTimestampUs"])
|
||||
# Validate content without requiring the part's IMU to cover video endpoints.
|
||||
_validate_raw_imu(materialize(paired["imu"]), validation["startTimestampUs"], validation["endTimestampUs"], require_coverage=False)
|
||||
return validation
|
||||
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ import hashlib
|
||||
import bisect
|
||||
import csv
|
||||
import json
|
||||
import math
|
||||
import pathlib
|
||||
import re
|
||||
import shutil
|
||||
@ -702,9 +703,31 @@ def _part_index_capture_record(summary_payload: dict[str, Any], revision_manifes
|
||||
return {}
|
||||
|
||||
|
||||
def _part_index_discard_evidence(evidence: dict[str, Any], *, classification_v4: bool = False) -> dict[str, Any]:
|
||||
# New workflow metadata must not change the bytes of a legacy package.
|
||||
result = {
|
||||
"reason": str(evidence.get("reason") or ""),
|
||||
"reasonLabelId": str(evidence.get("reasonLabelId") or ""),
|
||||
"reasonName": str(evidence.get("reasonName") or ""),
|
||||
"note": str(evidence.get("note") or ""),
|
||||
"discardedByUserId": str(evidence.get("discardedByUserId") or ""),
|
||||
"discardedAt": str(evidence.get("discardedAt") or ""),
|
||||
}
|
||||
if classification_v4:
|
||||
result.update(
|
||||
note=str(evidence.get("note") or evidence.get("reasonNote") or ""),
|
||||
reasonVersion=evidence.get("reasonVersion"),
|
||||
dictionary=evidence.get("dictionary"),
|
||||
discardedAt=str(evidence.get("discardedAt") or evidence.get("at") or ""),
|
||||
)
|
||||
return result
|
||||
|
||||
|
||||
def _part_index_discarded_slice(
|
||||
row: dict[str, Any],
|
||||
source_root: pathlib.Path,
|
||||
*,
|
||||
classification_v4: bool = False,
|
||||
) -> dict[str, Any]:
|
||||
"""Classify a discarded interval without shipping its media or old text.
|
||||
|
||||
@ -748,14 +771,7 @@ def _part_index_discarded_slice(
|
||||
},
|
||||
"classification": {
|
||||
"deliveryDisposition": declared,
|
||||
"discardEvidence": {
|
||||
"reason": str(evidence.get("reason") or ""),
|
||||
"reasonLabelId": str(evidence.get("reasonLabelId") or ""),
|
||||
"reasonName": str(evidence.get("reasonName") or ""),
|
||||
"note": str(evidence.get("note") or ""),
|
||||
"discardedByUserId": str(evidence.get("discardedByUserId") or ""),
|
||||
"discardedAt": str(evidence.get("discardedAt") or ""),
|
||||
},
|
||||
"discardEvidence": _part_index_discard_evidence(evidence, classification_v4=classification_v4),
|
||||
},
|
||||
"segments": [],
|
||||
}
|
||||
@ -843,13 +859,189 @@ def _description_status(actions: list[dict[str, Any]]) -> str:
|
||||
return "empty_confirmed"
|
||||
|
||||
|
||||
def _emit_part_index_v3(run_id, node_id, output, node_data, helpers, payload):
|
||||
"""Use the established immutable directory publisher for the two JSON files.
|
||||
def _v4_tags(selection: Any, kind: str) -> list[str]:
|
||||
if not isinstance(selection, dict) or selection.get("kind") != kind or not str(selection.get("id") or "").strip() or type(selection.get("version")) is not int or selection["version"] < 1 or not str(selection.get("name") or "").strip():
|
||||
raise RuntimeError(f"v4 missing frozen {kind} dictionary; confirm historical classification before delivery")
|
||||
tags = selection.get("tags")
|
||||
if not isinstance(tags, list) or not tags or any(not isinstance(tag, str) or not tag.strip() or tag != tag.strip() for tag in tags) or len(set(tags)) != len(tags):
|
||||
raise RuntimeError(f"v4 missing frozen {kind} tags; confirm classification before delivery")
|
||||
return list(tags)
|
||||
|
||||
|
||||
def _v4_original_sources(manifest, capture_id, part_id, capture_prefix):
|
||||
source = manifest.get("originalSource")
|
||||
if not isinstance(source, dict) or source.get("provider") != "BOS" or not str(source.get("bucket") or "").strip():
|
||||
raise RuntimeError("v4 requires frozen original BOS source selection; workspace paths cannot identify original data")
|
||||
prefix = str(source.get("prefix") or "")
|
||||
part_prefix = str(source.get("partPrefix") or "")
|
||||
if prefix != capture_prefix or part_prefix != prefix + "/" + part_id or source.get("captureUnit") != capture_id + "/" + part_id:
|
||||
raise RuntimeError("v4 original source identity disagrees with accepted capture/part")
|
||||
if not prefix or str(pathlib.PurePosixPath(prefix)) != prefix or pathlib.PurePosixPath(prefix).is_absolute() or ".." in pathlib.PurePosixPath(prefix).parts or any(c in prefix for c in ("\\", "\x00")):
|
||||
raise RuntimeError("unsafe v4 original source prefix")
|
||||
keys = source.get("objectKeys")
|
||||
if not isinstance(keys, list) or not keys or any(not isinstance(key, str) for key in keys) or len(set(keys)) != len(keys):
|
||||
raise RuntimeError("v4 requires an unambiguous original object selection")
|
||||
files = {}
|
||||
cap, part = re.escape(capture_id), re.escape(part_id)
|
||||
patterns = {
|
||||
"leftVideo": rf"{part}/{cap}_camera_left_{part}(?:_[a-z0-9_]+)?\.(?:mp4|mov|mkv)",
|
||||
"rightVideo": rf"{part}/{cap}_camera_right_{part}(?:_[a-z0-9_]+)?\.(?:mp4|mov|mkv)",
|
||||
"leftPts": rf"{part}/{cap}_camera_left_{part}(?:_[a-z0-9_]+)?_pts\.csv",
|
||||
"rightPts": rf"{part}/{cap}_camera_right_{part}(?:_[a-z0-9_]+)?_pts\.csv",
|
||||
"imu": rf"{part}/{cap}_imu_{part}\.csv",
|
||||
"cameraCalibration": rf"{cap}_calibration_camera\.yaml",
|
||||
"imuCalibration": rf"{cap}_calibration_imu\.yaml",
|
||||
"metadata": rf"meta_{cap}\.json",
|
||||
}
|
||||
for key in keys:
|
||||
if not key.startswith(prefix + "/") or str(pathlib.PurePosixPath(key)) != key or ".." in pathlib.PurePosixPath(key).parts or any(c in key for c in ("\\", "\x00")):
|
||||
raise RuntimeError("unsafe v4 original source object")
|
||||
relative = key[len(prefix) + 1:]
|
||||
if "/" in relative and not relative.startswith(part_id + "/"):
|
||||
raise RuntimeError("v4 original selection contains another part")
|
||||
for role, pattern in patterns.items():
|
||||
if re.fullmatch(pattern, relative, re.IGNORECASE):
|
||||
if role in files: raise RuntimeError(f"ambiguous v4 original {role} selection")
|
||||
files[role] = {"path": relative}
|
||||
missing = sorted(set(patterns) - files.keys())
|
||||
if missing: raise RuntimeError("v4 missing original files: " + ", ".join(missing))
|
||||
return {"provider": "BOS", "bucket": source["bucket"], "prefix": prefix, "partPrefix": part_prefix,
|
||||
"snapshotFingerprint": str(source.get("snapshotFingerprint") or ""), "files": files}
|
||||
|
||||
|
||||
def _v4_number(value, label):
|
||||
if isinstance(value, bool) or not isinstance(value, (int, float)) or not math.isfinite(value):
|
||||
raise RuntimeError(f"v4 missing or invalid {label}")
|
||||
return float(value)
|
||||
|
||||
|
||||
def _v4_timestamp(value, label):
|
||||
if type(value) is not int or value <= 0: raise RuntimeError(f"v4 missing or invalid {label}")
|
||||
return value
|
||||
|
||||
|
||||
def _v4_consumer_payload(payload, manifest, source_root):
|
||||
"""Project immutable accepted facts into a self-contained consumer contract.
|
||||
|
||||
No dictionary lookup, source media reads, transcoding or BOS writes here.
|
||||
Hardware PTS are authoritative; media seconds are explicitly named and never
|
||||
used to manufacture missing hardware timestamps.
|
||||
"""
|
||||
if not isinstance(manifest, dict): raise RuntimeError("v4 requires accepted source manifest")
|
||||
original = _v4_original_sources(manifest, payload["capture"]["captureId"], payload["partId"], payload["capture"]["prefix"])
|
||||
payload["originalSource"] = original
|
||||
payload["consumerContract"] = "droboticflow.classification-consumer/v1"
|
||||
payload["timeBases"] = {"taskSplitSeconds": "original_left_video", "segmentSeconds": "slice_left_video",
|
||||
"segmentPartSeconds": "original_left_video", "timestampUs": "original_hardware_pts",
|
||||
"interval": "half-open", "frameRanges": "zero-based-half-open"}
|
||||
payload["pathBases"] = {"sources": "original_capture", "sourceMetadata": "original_capture", "calibration": "original_capture"}
|
||||
# Workspace sources are private transport references, not the original files.
|
||||
payload["sources"] = {kind: original["files"][kind] for kind in ("leftVideo", "rightVideo", "leftPts", "rightPts", "imu")}
|
||||
payload["sourceMetadata"]["path"] = original["files"]["metadata"]["path"]
|
||||
for item in payload["calibration"]:
|
||||
# Bind by actual calibration kind, not input ordering.
|
||||
kind = "imuCalibration" if "imu" in item["name"].lower() else "cameraCalibration" if "camera" in item["name"].lower() else ""
|
||||
if not kind: raise RuntimeError("v4 unknown calibration kind")
|
||||
item["path"] = original["files"][kind]["path"]
|
||||
rows = {str(row["sliceId"]): row for row in manifest["items"]}
|
||||
if len(rows) != len(manifest["items"]): raise RuntimeError("v4 duplicate slice identities")
|
||||
for item in payload["slices"] + payload["discardedSlices"]:
|
||||
split = item["taskSplit"]
|
||||
start, end = (_v4_number(split[k], k) for k in ("startSecond", "endSecond"))
|
||||
first, last = (_v4_timestamp(split[k], k) for k in ("startTimestampUs", "endTimestampUs"))
|
||||
if start < 0 or end <= start or last <= first: raise RuntimeError("v4 invalid accepted slice range")
|
||||
row = rows[item["sliceId"]]
|
||||
sync = json.loads((source_root / row["directory"] / "synchronized-slice.json").read_text())
|
||||
seconds, stamps = sync.get("boundarySeconds"), sync.get("boundaryTimestampUs")
|
||||
# A continuous annotation is not proof of its relation to media seconds.
|
||||
# Require the accepted revision's mapping for kept and discarded ranges;
|
||||
# never infer hardware PTS from duration, cadence, or action endpoints.
|
||||
if not isinstance(seconds, list) or not isinstance(stamps, list) or len(seconds) < 2 or len(seconds) != len(stamps):
|
||||
raise RuntimeError("v4 missing or invalid hardware boundary mapping")
|
||||
seconds = [_v4_number(value, "boundary") for value in seconds]
|
||||
stamps = [_v4_timestamp(value, "boundary timestamp") for value in stamps]
|
||||
if (abs(seconds[0]) > 1e-7 or abs(seconds[-1] - (end-start)) > 1e-7 or
|
||||
stamps[0] != first or stamps[-1] != last or
|
||||
any(a >= b for a, b in zip(seconds, seconds[1:])) or
|
||||
any(a >= b for a, b in zip(stamps, stamps[1:]))):
|
||||
raise RuntimeError("v4 invalid hardware boundary mapping")
|
||||
window = sync.get("window")
|
||||
if (not isinstance(window, dict) or window.get("semantics") != "half-open" or
|
||||
_v4_timestamp(window.get("startTimestampUs"), "synchronization window start") != first or
|
||||
_v4_timestamp(window.get("endTimestampUs"), "synchronization window end") != last):
|
||||
raise RuntimeError("v4 boundary mapping disagrees with frozen synchronization window")
|
||||
if item["classification"]["deliveryDisposition"] == "discard":
|
||||
item["sliceName"] = ""
|
||||
evidence = item["classification"]["discardEvidence"]
|
||||
selected = evidence.get("dictionary")
|
||||
if selected is not None:
|
||||
if (not isinstance(selected, dict) or selected.get("kind") != "discard_reason" or
|
||||
not selected.get("id") or not selected.get("name") or
|
||||
type(selected.get("version")) is not int or selected["version"] < 1):
|
||||
raise RuntimeError("v4 invalid frozen discard dictionary")
|
||||
for alias, field in (("reasonLabelId", "id"), ("reasonName", "name"), ("reasonVersion", "version")):
|
||||
if evidence.get(alias) not in (None, "", 0, selected[field]):
|
||||
raise RuntimeError("v4 discard reason disagrees with frozen dictionary")
|
||||
evidence[alias] = selected[field]
|
||||
continue
|
||||
parent_tags = _v4_tags(item["classification"].get("dictionary"), "slice")
|
||||
item["classification"]["tags"] = parent_tags
|
||||
def timestamp(second):
|
||||
hits = [stamps[i] for i, value in enumerate(seconds) if abs(value - second) < 1e-7]
|
||||
if len(hits) != 1: raise RuntimeError("v4 action boundary has no original PTS mapping")
|
||||
return hits[0]
|
||||
actions = []
|
||||
for action in item["segments"]:
|
||||
a = _v4_number(action.get("clipStartMs"), "action clipStartMs") / 1000
|
||||
b = _v4_number(action.get("clipEndMs"), "action clipEndMs") / 1000
|
||||
if a < -1e-7 or b <= a or b > end-start+1e-7: raise RuntimeError("v4 action escapes its parent slice")
|
||||
ta, tb = (_v4_timestamp(action.get(k), k) for k in ("startTimestampUs", "endTimestampUs"))
|
||||
if not first <= ta < tb <= last: raise RuntimeError("v4 action timestamps escape its parent slice")
|
||||
if timestamp(a) != ta or timestamp(b) != tb: raise RuntimeError("v4 action seconds disagree with original PTS")
|
||||
action.update(startSecond=a, endSecond=b, partStartSecond=start+a, partEndSecond=start+b)
|
||||
own = action.get("dictionary")
|
||||
action["tags"] = _v4_tags(own, "action") if own is not None else list(parent_tags)
|
||||
action["tagSource"] = "action" if own is not None else "slice"
|
||||
actions.append(action)
|
||||
actions.sort(key=lambda a: a["startSecond"])
|
||||
complete, previous = [], 0.0
|
||||
def gap(a,b):
|
||||
ta,tb=timestamp(a),timestamp(b)
|
||||
return {"id":f"{item['sliceId']}:gap:{ta}:{tb}", "description":"", "isInvalid":False,
|
||||
"contentKind":"gap_placeholder", "startSecond":a,"endSecond":b,
|
||||
"clipStartMs":a*1000,"clipEndMs":b*1000,"partStartSecond":start+a,"partEndSecond":start+b,
|
||||
"startTimestampUs":ta,"endTimestampUs":tb,"tags":list(parent_tags),"tagSource":"slice"}
|
||||
for action in actions:
|
||||
if action["startSecond"] < previous-1e-7: raise RuntimeError("v4 overlapping actions")
|
||||
if action["startSecond"] > previous+1e-7: complete.append(gap(previous,action["startSecond"]))
|
||||
complete.append(action);previous=action["endSecond"]
|
||||
if previous < end-start-1e-7: complete.append(gap(previous,end-start))
|
||||
if not complete: raise RuntimeError("v4 kept slice has no classified action coverage")
|
||||
previous_stamp = first
|
||||
for action in complete:
|
||||
if action["startTimestampUs"] != previous_stamp or action["endTimestampUs"] <= previous_stamp:
|
||||
raise RuntimeError("v4 action PTS coverage is discontinuous")
|
||||
previous_stamp = action["endTimestampUs"]
|
||||
if previous_stamp != last: raise RuntimeError("v4 action PTS coverage is incomplete")
|
||||
item["segments"] = complete
|
||||
counts = {kind:sum(a["contentKind"]==kind for a in complete) for kind in ("annotated","gap_placeholder","invalid_marked")}
|
||||
item["classification"]["contentCounts"] = counts
|
||||
item["classification"]["descriptionStatus"] = _description_status(complete)
|
||||
if not counts["annotated"] and counts["invalid_marked"] and counts["gap_placeholder"]: item["classification"]["descriptionStatus"]="invalid_and_blank"
|
||||
item["synchronization"]["rightBoundarySeconds"] = sync.get("rightBoundarySeconds", [])
|
||||
|
||||
|
||||
def _emit_part_index_directory(run_id, node_id, output, node_data, helpers, payload, internal_audit=None, revision_manifest=None, source_root=None):
|
||||
"""Use the established immutable publisher for versioned customer JSON.
|
||||
|
||||
V3 retains its historical sibling review file; v4 stores that audit in a
|
||||
separate internal artifact before publishing the customer directory.
|
||||
|
||||
Legacy single-file publishers deliberately accept only v1/v2. A directory
|
||||
artifact preserves their ownership/conditional-publication protocol without
|
||||
teaching an old worker to misinterpret a new single-file schema.
|
||||
"""
|
||||
v4 = internal_audit is not None
|
||||
capture = dict(payload["capture"])
|
||||
prefix = pathlib.PurePosixPath(str(capture.get("prefix") or ""))
|
||||
part_id = prefix.name
|
||||
@ -860,7 +1052,7 @@ def _emit_part_index_v3(run_id, node_id, output, node_data, helpers, payload):
|
||||
if prefix.is_absolute() or ".." in prefix.parts or len(prefix.parts) < 3:
|
||||
raise RuntimeError("unsafe v3 capture identity prefix")
|
||||
capture.update(captureId=capture_id, prefix=str(prefix.parent))
|
||||
payload.update(schemaVersion="droboticflow.delivery.part-index/v3", capture=capture, partId=part_id)
|
||||
payload.update(schemaVersion="droboticflow.delivery.part-index/v4" if v4 else "droboticflow.delivery.part-index/v3", capture=capture, partId=part_id)
|
||||
payload["pathBases"] = {"sourceMetadata": "original_capture", "calibration": "original_capture", "sources": "workspace"}
|
||||
payload["sourceMetadata"] = {"path": f"meta_{capture_id}.json"}
|
||||
history = {
|
||||
@ -869,7 +1061,8 @@ def _emit_part_index_v3(run_id, node_id, output, node_data, helpers, payload):
|
||||
"qualityReviews": payload["acceptance"].pop("qualityReviews", []),
|
||||
}
|
||||
payload["reviewHistory"] = {"path": "review-history.json", "pathBase": "part_package"}
|
||||
payload["acceptance"]["finalAcceptance"].pop("confirmedByUserId", None)
|
||||
if not v4:
|
||||
payload["acceptance"]["finalAcceptance"].pop("confirmedByUserId", None)
|
||||
for item in payload["calibration"]:
|
||||
if pathlib.PurePosixPath(item["name"]).name != item["name"] or "\\" in item["name"]:
|
||||
raise RuntimeError("unsafe calibration filename")
|
||||
@ -889,6 +1082,54 @@ def _emit_part_index_v3(run_id, node_id, output, node_data, helpers, payload):
|
||||
classification["contentCounts"] = counts
|
||||
if not counts["described"] and counts["invalid_marked"] and counts["gap_placeholder"]:
|
||||
classification["descriptionStatus"] = "invalid_and_blank"
|
||||
if v4:
|
||||
if not isinstance(internal_audit.get("trace"), list):
|
||||
raise RuntimeError("DELIVERY_JSON_V4 requires complete internal trace input")
|
||||
if _output(node_data, helpers, "deliveryAudit") is None:
|
||||
raise RuntimeError("DELIVERY_JSON_V4 requires an internal deliveryAudit output")
|
||||
audit = {
|
||||
"schemaVersion": "droboticflow.delivery.review-history/v2",
|
||||
"captureId": capture_id, "partId": part_id, "revision": payload["revision"],
|
||||
"acceptance": payload.pop("acceptance"), "lineage": payload.pop("lineage"),
|
||||
"qualityReviews": internal_audit.get("qualityReviews", []),
|
||||
"trace": internal_audit.get("trace", []),
|
||||
"acceptedMaterializations": internal_audit.get("acceptedMaterializations", []),
|
||||
}
|
||||
audit["acceptance"]["finalAcceptance"] = internal_audit.get("finalAcceptance", {})
|
||||
payload.pop("reviewHistory", None)
|
||||
payload["capture"] = {"captureId": capture_id, "prefix": str(prefix.parent)}
|
||||
for item in payload["slices"] + payload["discardedSlices"]:
|
||||
classification = item["classification"]
|
||||
# Blank descriptions retain the independently selected base class.
|
||||
if classification.get("dictionary") is None:
|
||||
classification.pop("dictionary", None)
|
||||
evidence = classification.get("discardEvidence", {})
|
||||
evidence.pop("discardedAt", None)
|
||||
if evidence.get("dictionary") is None:
|
||||
evidence.pop("dictionary", None)
|
||||
counts = classification.get("contentCounts")
|
||||
if counts is not None:
|
||||
counts["annotated"] = counts.pop("described")
|
||||
for action in item["segments"]:
|
||||
if action["contentKind"] == "described": action["contentKind"] = "annotated"
|
||||
for key in ("source", "confidence", "phrases", "labelId"):
|
||||
action.pop(key, None)
|
||||
if action.get("dictionary") is None: action.pop("dictionary", None)
|
||||
audit["materializedSources"] = payload.get("sources", {})
|
||||
_v4_consumer_payload(payload, revision_manifest, source_root)
|
||||
body = (json.dumps(payload, ensure_ascii=False, sort_keys=True, indent=2) + "\n").encode("utf8")
|
||||
audit["partSha256"] = hashlib.sha256(body).hexdigest()
|
||||
if len(json.dumps(audit, ensure_ascii=False, indent=2).encode("utf8")) > 8 * 1024 * 1024:
|
||||
raise RuntimeError("internal delivery audit exceeds 8 MiB; refusing incomplete export")
|
||||
staging = pathlib.Path(tempfile.mkdtemp(prefix="part-index-v4-", dir=output))
|
||||
(staging / "part.json").write_bytes(body)
|
||||
# A sibling artifact stays in the internal run, never in the customer tree.
|
||||
audit_artifact = helpers["write_json_artifact"](run_id, node_id, output, "review-history.json", audit, output=_output(node_data, helpers, "deliveryAudit"))
|
||||
directory = helpers["build_virtual_artifact"](
|
||||
run_id, node_id, "delivery.directory.index", str(staging), "file", 0,
|
||||
data={"schemaVersion": "droboticflow.directory-index/v1", "presentation": "collection", "datasetType": "directory", "dataSource": "FILESYSTEM", "rootPath": str(staging), "sliceCount": len(payload["slices"]), "classificationOnly": True},
|
||||
output=_output(node_data, helpers, "deliveryDirectory"))
|
||||
return [directory, audit_artifact]
|
||||
staging = pathlib.Path(tempfile.mkdtemp(prefix="part-index-v3-", dir=output))
|
||||
for name, document in (("part.json", payload), ("review-history.json", history)):
|
||||
(staging / name).write_text(json.dumps(document, ensure_ascii=False, sort_keys=True, indent=2) + "\n", encoding="utf8")
|
||||
@ -905,6 +1146,8 @@ def _part_index_slice(
|
||||
source_slice: pathlib.Path,
|
||||
calibration: list[dict[str, Any]],
|
||||
pose_policy: dict[str, Any],
|
||||
*,
|
||||
classification_v4: bool = False,
|
||||
) -> dict[str, Any]:
|
||||
declared = str(row.get("deliveryDisposition") or "")
|
||||
slice_id = str(row.get("sliceId") or f"slice-{index + 1:06d}")
|
||||
@ -944,6 +1187,7 @@ def _part_index_slice(
|
||||
"clipStartMs": _optional_float(action.get("clipStartMs")),
|
||||
"clipEndMs": _optional_float(action.get("clipEndMs")),
|
||||
"labelId": str(action.get("descriptionTemplateId") or ""),
|
||||
**({"dictionary": action.get("dictionary")} if classification_v4 else {}),
|
||||
"phrases": [str(item) for item in action.get("phrases", [])] if isinstance(action.get("phrases"), list) else [],
|
||||
"source": str(action.get("source") or ""),
|
||||
"confidence": _optional_float(action.get("confidence")),
|
||||
@ -976,6 +1220,7 @@ def _part_index_slice(
|
||||
"deliveryDisposition": declared,
|
||||
"taskLabel": str(synchronization.get("taskLabel") or ""),
|
||||
"taskLabelId": str(synchronization.get("taskLabelId") or ""),
|
||||
**({"dictionary": synchronization.get("dictionary")} if classification_v4 else {}),
|
||||
"descriptionStatus": _description_status(actions),
|
||||
},
|
||||
"segments": actions,
|
||||
@ -995,14 +1240,7 @@ def _part_index_slice(
|
||||
raise RuntimeError(f"discarded slice {slice_id} has no reason evidence")
|
||||
# Discard classification is exported deliberately: downstream packaging
|
||||
# must know why an interval is excluded.
|
||||
entry["classification"]["discardEvidence"] = {
|
||||
"reason": str(evidence.get("reason") or ""),
|
||||
"reasonLabelId": str(evidence.get("reasonLabelId") or ""),
|
||||
"reasonName": str(evidence.get("reasonName") or ""),
|
||||
"note": str(evidence.get("note") or ""),
|
||||
"discardedByUserId": str(evidence.get("discardedByUserId") or ""),
|
||||
"discardedAt": str(evidence.get("discardedAt") or ""),
|
||||
}
|
||||
entry["classification"]["discardEvidence"] = _part_index_discard_evidence(evidence, classification_v4=classification_v4)
|
||||
# Pose frames deliberately stay out of the index: the customer contract for
|
||||
# this mode is the split information, and embedded per-frame pose would
|
||||
# make a multi-megabyte part.json out of a kilobyte index. The per-slice
|
||||
@ -1027,6 +1265,8 @@ def _build_part_index(
|
||||
capture_record: dict[str, Any],
|
||||
lineage: dict[str, Any],
|
||||
discarded_slices: list[dict[str, Any]],
|
||||
*,
|
||||
classification_v4: bool = False,
|
||||
) -> tuple[dict[str, Any], bytes]:
|
||||
slices: list[dict[str, Any]] = []
|
||||
for index, row in enumerate(kept_slices):
|
||||
@ -1038,7 +1278,7 @@ def _build_part_index(
|
||||
source_slice = source_root / pathlib.Path(*relative.parts)
|
||||
if not source_slice.is_dir():
|
||||
raise RuntimeError("accepted slice manifest contains an unavailable slice directory")
|
||||
slices.append(_part_index_slice(row, index, source_slice, calibration, pose_policy))
|
||||
slices.append(_part_index_slice(row, index, source_slice, calibration, pose_policy, classification_v4=classification_v4))
|
||||
quality_reviews = summary_payload.get("qualityReviews") if isinstance(summary_payload.get("qualityReviews"), list) else []
|
||||
exported_reviews = [
|
||||
{key: review[key] for key in _QUALITY_REVIEW_EXPORT_FIELDS if key in review}
|
||||
@ -1061,7 +1301,7 @@ def _build_part_index(
|
||||
"coverage": coverage,
|
||||
"slices": slices,
|
||||
"discardedSlices": [
|
||||
_part_index_discarded_slice(row, source_root)
|
||||
_part_index_discarded_slice(row, source_root, classification_v4=classification_v4)
|
||||
for row in discarded_slices
|
||||
if isinstance(row, dict)
|
||||
],
|
||||
@ -1651,6 +1891,12 @@ def _run_accepted_slice_directory(
|
||||
raise RuntimeError("acceptedSliceDirectory does not prove gap-free full-video coverage")
|
||||
summary_artifact = next((item for item in inputs if _port(item) == "acceptanceSummary"), None)
|
||||
summary_payload = summary_artifact.get("data") if isinstance((summary_artifact or {}).get("data"), dict) else {}
|
||||
if summary_artifact is not None and not isinstance(summary_payload.get("finalAcceptance"), dict):
|
||||
summary_path = _materialize_input_file(summary_artifact, output / "_acceptance", helpers)
|
||||
if summary_path.stat().st_size > 8 * 1024 * 1024:
|
||||
raise RuntimeError("acceptance summary exceeds 8 MiB")
|
||||
summary_payload = json.loads(summary_path.read_text(encoding="utf8"))
|
||||
if not isinstance(summary_payload, dict): raise RuntimeError("invalid acceptance summary reference")
|
||||
final_acceptance = summary_payload.get("finalAcceptance") if isinstance(summary_payload.get("finalAcceptance"), dict) else {}
|
||||
capture_record = _part_index_capture_record(summary_payload, revision_manifest)
|
||||
all_slices = revision_manifest.get("items", [])
|
||||
@ -1669,7 +1915,11 @@ def _run_accepted_slice_directory(
|
||||
discarded_slices.append(row)
|
||||
else:
|
||||
kept_slices.append(row)
|
||||
if disposition_contract:
|
||||
params = helpers["hyperparams"](node_data) if callable(helpers.get("hyperparams")) else {}
|
||||
classification_v4 = _bool(params, "DELIVERY_JSON_V4", False)
|
||||
if classification_v4 and not coverage_required:
|
||||
raise RuntimeError("DELIVERY_JSON_V4 requires verified full-video coverage")
|
||||
if disposition_contract or classification_v4:
|
||||
pins = summary_payload.get("acceptedMaterializations", [])
|
||||
expected_sha = _sha256_file(revision_manifest_path)
|
||||
if summary_payload.get("decision") != "approved" or final_acceptance.get("confirmed") is not True or not any(
|
||||
@ -1679,7 +1929,7 @@ def _run_accepted_slice_directory(
|
||||
raise RuntimeError("slice dispositions are not pinned to the accepted manifest revision")
|
||||
if int(coverage.get("sliceCount", -1)) != len(all_slices):
|
||||
raise RuntimeError("review coverage slice count mismatch")
|
||||
if disposition_contract and not kept_slices:
|
||||
if disposition_contract and not kept_slices and not _bool(params, "DELIVERY_JSON_V4", False):
|
||||
if any(p.get("key") == "PROCESSING_PROFILE" and p.get("value") == "raw_human" for p in node_data.get("hyperparams", [])) and (summary_payload.get("processingProfile") != "raw_human" or final_acceptance.get("processingProfile") != "raw_human"):
|
||||
raise RuntimeError("raw-human package requires matching accepted task profile")
|
||||
# Internal evidence only: deliberately no deliveryDirectory output and
|
||||
@ -1697,13 +1947,12 @@ def _run_accepted_slice_directory(
|
||||
payloads = _payload_tree(_payloads_with_full_pose_manifests(inputs, output, helpers))
|
||||
headpose = _first_payload(payloads, "droboticflow.headpose/v1")
|
||||
handpose = _first_payload(payloads, "droboticflow.wilor.hand_pose_result/v1")
|
||||
params = helpers["hyperparams"](node_data) if callable(helpers.get("hyperparams")) else {}
|
||||
if _bool(params, "PART_INDEX_DELIVERY", False):
|
||||
if source_index and not _bool(params, "SOURCE_INDEX_DELIVERY", False):
|
||||
raise RuntimeError("source-index JSON delivery requires explicit SOURCE_INDEX_DELIVERY approval; use directory delivery to preserve physical discard exclusion")
|
||||
calibration_refs = _part_index_calibration_refs(inputs)
|
||||
lineage = {"acceptedSliceDirectoryArtifactId": directory_artifact.get("id"), "humanItemId": revision_manifest.get("humanItemId"), "taskId": revision_manifest.get("taskId"), "sourceRunId": revision_manifest.get("runId")}
|
||||
payload, body = _build_part_index(revision_manifest, coverage, kept_slices, source_root, calibration_refs, pose_policy, summary_payload, final_acceptance, capture_record, lineage, discarded_slices)
|
||||
payload, body = _build_part_index(revision_manifest, coverage, kept_slices, source_root, calibration_refs, pose_policy, summary_payload, final_acceptance, capture_record, lineage, discarded_slices, classification_v4=classification_v4)
|
||||
if source_index:
|
||||
_source_index_files(source_root, revision_manifest, False)
|
||||
payload["schemaVersion"] = _SOURCE_PART_INDEX_SCHEMA
|
||||
@ -1715,8 +1964,10 @@ def _run_accepted_slice_directory(
|
||||
for item in payload["slices"] + payload["discardedSlices"]:
|
||||
item["sourceFrames"] = frames[item["sliceId"]]
|
||||
body = (json.dumps(payload, ensure_ascii=False, sort_keys=True, separators=(",", ":")) + "\n").encode("utf8")
|
||||
if _bool(params, "DELIVERY_JSON_V4", False):
|
||||
return _emit_part_index_directory(run_id, node_id, output, node_data, helpers, payload, summary_payload, revision_manifest, source_root)
|
||||
if _bool(params, "DELIVERY_JSON_V3", False):
|
||||
return _emit_part_index_v3(run_id, node_id, output, node_data, helpers, payload)
|
||||
return _emit_part_index_directory(run_id, node_id, output, node_data, helpers, payload)
|
||||
return _emit_part_index(run_id, node_id, output, node_data, helpers, body)
|
||||
if source_index:
|
||||
source_root = _source_index_physical_export(source_root, revision_manifest, kept_slices, output)
|
||||
@ -1953,6 +2204,8 @@ def _run_multiport(
|
||||
|
||||
def run(run_id: str, node_id: str, output_dir: Any, node_data: dict[str, Any], inputs: list[dict[str, Any]], helpers: HelperMap) -> list[dict[str, Any]]:
|
||||
params = helpers["hyperparams"](node_data) if callable(helpers.get("hyperparams")) else {}
|
||||
if _bool(params, "DELIVERY_JSON_V4", False) and (not _bool(params, "PART_INDEX_DELIVERY", False) or _bool(params, "DELIVERY_JSON_V3", False)):
|
||||
raise RuntimeError("DELIVERY_JSON_V4 requires PART_INDEX_DELIVERY and cannot combine with DELIVERY_JSON_V3")
|
||||
if _bool(params, "DELIVERY_JSON_V3", False) and not _bool(params, "PART_INDEX_DELIVERY", False):
|
||||
raise RuntimeError("DELIVERY_JSON_V3 requires PART_INDEX_DELIVERY")
|
||||
# A part-index delivery intentionally has no directory port; it must still
|
||||
|
||||
@ -16,8 +16,8 @@
|
||||
],
|
||||
"containerEntrypoint": "backend/operator-runner/main.py",
|
||||
"entrypoint": "operator.py",
|
||||
"image": "ccr-29eug8s3-pub.cnc.bj.baidubce.com/dataflow-poc/droboticflow-operator-package:feaaf80-poc-handpose-auto-20260825052001",
|
||||
"imageId": "ccr-29eug8s3-pub.cnc.bj.baidubce.com/dataflow-poc/droboticflow-operator-package@sha256:fa084bbd0e3b6fedff9582d09c965b460f054ad9e0f5edaf9fc4b9aebcc375cc",
|
||||
"image": "ccr-29eug8s3-pub.cnc.bj.baidubce.com/fanyu/droboticflow-operator-package:delivery-v4-20261022-8f6b531f",
|
||||
"imageId": "ccr-29eug8s3-pub.cnc.bj.baidubce.com/fanyu/droboticflow-operator-package@sha256:dc22ee3b77f00a8e27aa4d4cf11b1b225e8b8d476b8dd3429d43c4d73396ca1d",
|
||||
"metadata": "operator.json",
|
||||
"name": "成品打包",
|
||||
"operatorId": "operator-builtin-package",
|
||||
|
||||
72
cmd/account-phone-index/main.go
Normal file
72
cmd/account-phone-index/main.go
Normal file
@ -0,0 +1,72 @@
|
||||
// account-phone-index previews (default) or explicitly migrates user phone uniqueness.
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"droboticflow/internal/store"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := run(os.Args[1:], os.Stdout); err != nil {
|
||||
fmt.Fprintln(os.Stderr, "phone index maintenance failed:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func run(args []string, stdout io.Writer) error {
|
||||
flags := flag.NewFlagSet("account-phone-index", flag.ContinueOnError)
|
||||
database := flags.String("database", "", "exact database name (required)")
|
||||
apply := flags.Bool("apply", false, "create live-account unique index, then remove legacy phone_unique")
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return err
|
||||
}
|
||||
if flags.NArg() != 0 {
|
||||
return fmt.Errorf("unexpected positional arguments")
|
||||
}
|
||||
uri := os.Getenv("MONGO_URI")
|
||||
if uri == "" || *database == "" {
|
||||
return fmt.Errorf("MONGO_URI and --database are required")
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
|
||||
defer cancel()
|
||||
client, err := mongo.Connect(ctx, options.Client().ApplyURI(uri))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer client.Disconnect(context.Background())
|
||||
db := client.Database(*database)
|
||||
col := db.Collection("users")
|
||||
cur, err := col.Indexes().List(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var indexes []bson.M
|
||||
if err = cur.All(ctx, &indexes); err != nil {
|
||||
return err
|
||||
}
|
||||
deleted, err := col.CountDocuments(ctx, bson.M{"deletedAt": bson.M{"$type": "string", "$ne": ""}})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
preview := map[string]any{"database": *database, "apply": *apply, "existingIndexes": indexes, "deletedAccountsPreserved": deleted, "createIndex": "phone_live_unique", "dropIndex": "phone_unique", "businessRecordUpdates": 0}
|
||||
if err = json.NewEncoder(stdout).Encode(preview); err != nil {
|
||||
return err
|
||||
}
|
||||
if !*apply {
|
||||
return nil
|
||||
}
|
||||
if err = store.NewMongoStore(db).MigrateUserPhoneIndex(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return json.NewEncoder(stdout).Encode(map[string]any{"completed": true, "database": *database})
|
||||
}
|
||||
76
cmd/account-phone-index/main_test.go
Normal file
76
cmd/account-phone-index/main_test.go
Normal file
@ -0,0 +1,76 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
func TestPreviewAndApplyPhoneIndexLocalMongo(t *testing.T) {
|
||||
if os.Getenv("ACCOUNT_PHONE_REUSE_LOCAL_MONGO") != "1" {
|
||||
t.Skip("isolated local Mongo only")
|
||||
}
|
||||
t.Setenv("MONGO_URI", "mongodb://127.0.0.1:27018/?directConnection=true")
|
||||
ctx, cancel := context.WithTimeout(t.Context(), time.Minute)
|
||||
defer cancel()
|
||||
client, err := mongo.Connect(ctx, options.Client().ApplyURI(os.Getenv("MONGO_URI")))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer client.Disconnect(context.Background())
|
||||
db := client.Database(fmt.Sprintf("phone_reuse_cli_test_%d", time.Now().UnixNano()))
|
||||
defer db.Drop(context.Background())
|
||||
col := db.Collection("users")
|
||||
if _, err = col.Indexes().CreateOne(ctx, mongo.IndexModel{Keys: bson.D{{Key: "phone", Value: 1}}, Options: options.Index().SetName("phone_unique").SetUnique(true)}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err = col.InsertOne(ctx, bson.M{"id": "audit", "phone": "13900000001", "deletedAt": "2026-10-21"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var before []bson.M
|
||||
cur, err := col.Indexes().List(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err = cur.All(ctx, &before); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var out bytes.Buffer
|
||||
if err = run([]string{"--database", db.Name()}, &out); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var after []bson.M
|
||||
cur, err = col.Indexes().List(ctx)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err = cur.All(ctx, &after); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(before) != len(after) || !strings.Contains(out.String(), `"apply":false`) {
|
||||
t.Fatal("preview mutated indexes or did not identify read-only mode")
|
||||
}
|
||||
if err = run([]string{"--database", db.Name(), "--apply"}, &out); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err = run([]string{"--database", db.Name(), "--apply"}, &out); err != nil {
|
||||
t.Fatalf("retry: %v", err)
|
||||
}
|
||||
if _, err = col.InsertOne(ctx, bson.M{"id": "replacement", "phone": "13900000001"}); err != nil {
|
||||
t.Fatalf("migration ineffective: %v", err)
|
||||
}
|
||||
if count, err := col.CountDocuments(ctx, bson.M{"id": "audit", "phone": "13900000001", "deletedAt": "2026-10-21"}); err != nil || count != 1 {
|
||||
t.Fatal("historical business record changed")
|
||||
}
|
||||
if _, err = col.InsertOne(ctx, bson.M{"id": "duplicate", "phone": "13900000001"}); !mongo.IsDuplicateKeyError(err) {
|
||||
t.Fatalf("unique protection removed: %v", err)
|
||||
}
|
||||
}
|
||||
@ -26,7 +26,7 @@ import (
|
||||
|
||||
func connectMongo(ctx context.Context, mongoURI string, attempts int, delay time.Duration) (*mongo.Client, error) {
|
||||
return retry.Do(ctx, attempts, delay, "mongodb connection", func(ctx context.Context, _ int) (*mongo.Client, error) {
|
||||
client, err := mongo.Connect(ctx, options.Client().ApplyURI(mongoURI))
|
||||
client, err := mongo.Connect(ctx, options.Client().ApplyURI(mongoURI).SetMonitor(store.ReadCommandMonitor()))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -83,19 +83,38 @@ func spaHandler(apiHandler http.Handler, distDir string) http.Handler {
|
||||
}
|
||||
|
||||
var precompressedContentTypes = map[string]string{
|
||||
".js": "text/javascript; charset=utf-8",
|
||||
".css": "text/css; charset=utf-8",
|
||||
".js": "text/javascript; charset=utf-8",
|
||||
".css": "text/css; charset=utf-8",
|
||||
".wasm": "application/wasm",
|
||||
}
|
||||
|
||||
func requestAcceptsGzip(request *http.Request) bool {
|
||||
wildcard := false
|
||||
for _, encoding := range request.Header.Values("Accept-Encoding") {
|
||||
for _, part := range strings.Split(encoding, ",") {
|
||||
if strings.TrimSpace(strings.SplitN(part, ";", 2)[0]) == "gzip" {
|
||||
return true
|
||||
fields := strings.Split(part, ";")
|
||||
name := strings.ToLower(strings.TrimSpace(fields[0]))
|
||||
quality := 1.0
|
||||
for _, parameter := range fields[1:] {
|
||||
pair := strings.SplitN(strings.TrimSpace(parameter), "=", 2)
|
||||
if len(pair) == 2 && strings.EqualFold(pair[0], "q") {
|
||||
value, err := strconv.ParseFloat(pair[1], 64)
|
||||
if err != nil || value < 0 || value > 1 {
|
||||
quality = 0
|
||||
} else {
|
||||
quality = value
|
||||
}
|
||||
}
|
||||
}
|
||||
if name == "gzip" {
|
||||
return quality > 0
|
||||
}
|
||||
if name == "*" {
|
||||
wildcard = quality > 0
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
return wildcard
|
||||
}
|
||||
|
||||
// servePrecompressedAsset streams the build-time .gz sibling for compressible
|
||||
@ -154,6 +173,21 @@ func main() {
|
||||
}()
|
||||
|
||||
dataStore := store.NewMongoStore(client.Database(cfg.MongoDB))
|
||||
dataStore.EnableQuerySourceTracking(os.Getenv("QUERY_SOURCE_TRACKING") == "1")
|
||||
if os.Getenv("ANNOTATION_PROCESSOR_MODE") != "processor" {
|
||||
closeReplica, replicaErr := dataStore.ConfigureQueryReplicaFromEnvironment(ctx)
|
||||
if replicaErr != nil {
|
||||
fmt.Println("[api] independent reporting unavailable; existing work remains enabled")
|
||||
} else {
|
||||
defer closeReplica()
|
||||
}
|
||||
closeServing, servingErr := dataStore.ConfigureQueryServingFromEnvironment()
|
||||
if servingErr != nil {
|
||||
fmt.Println("[api] query accelerator configuration unavailable; using existing reads")
|
||||
} else {
|
||||
defer closeServing()
|
||||
}
|
||||
}
|
||||
if os.Getenv("ANNOTATION_PROCESSOR_MODE") == "processor" {
|
||||
checkIndexes := dataStore.EnsureIndexes
|
||||
mode := os.Getenv("DROBOTICFLOW_DATABASE_BOOTSTRAP")
|
||||
@ -201,6 +235,8 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
go api.RunAcceptanceStatisticsSchedule(ctx, dataStore)
|
||||
|
||||
aiService := ai.NewService(cfg.AIAPIBaseURL, cfg.AIAPIKey, cfg.AIModel)
|
||||
handler := spaHandler(api.NewHandlerWithConfig(dataStore, aiService, cfg), cfg.DistDir)
|
||||
server := &http.Server{
|
||||
|
||||
79
cmd/api/static_compression_test.go
Normal file
79
cmd/api/static_compression_test.go
Normal file
@ -0,0 +1,79 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestVendorPrecompressionNegotiation(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
for _, name := range []string{"element.slim.js", "movi.wasm"} {
|
||||
path := filepath.Join(root, "vendor", "player", name)
|
||||
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
raw := []byte("frozen runtime bytes")
|
||||
var compressed bytes.Buffer
|
||||
z := gzip.NewWriter(&compressed)
|
||||
_, _ = z.Write(raw)
|
||||
_ = z.Close()
|
||||
if err := os.WriteFile(path, raw, 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(path+".gz", compressed.Bytes(), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
handler := spaHandler(http.NotFoundHandler(), root)
|
||||
for _, tc := range []struct {
|
||||
encoding, method, rangeHeader string
|
||||
gzip bool
|
||||
status int
|
||||
}{
|
||||
{"gzip", "GET", "", true, 200}, {"br, gzip;q=0.8", "GET", "", true, 200},
|
||||
{"gzip;q=0, *;q=1", "GET", "", false, 200}, {"br", "GET", "", false, 200},
|
||||
{"gzip", "HEAD", "", true, 200}, {"gzip", "GET", "bytes=0-3", false, 206},
|
||||
} {
|
||||
request := httptest.NewRequest(tc.method, "/vendor/player/"+name, nil)
|
||||
request.Header.Set("Accept-Encoding", tc.encoding)
|
||||
if tc.rangeHeader != "" {
|
||||
request.Header.Set("Range", tc.rangeHeader)
|
||||
}
|
||||
response := httptest.NewRecorder()
|
||||
handler.ServeHTTP(response, request)
|
||||
if response.Code != tc.status || (response.Header().Get("Content-Encoding") == "gzip") != tc.gzip {
|
||||
t.Fatalf("%s %+v: status=%d headers=%v", name, tc, response.Code, response.Header())
|
||||
}
|
||||
if tc.method == "HEAD" {
|
||||
if response.Body.Len() != 0 {
|
||||
t.Fatal("HEAD returned a body")
|
||||
}
|
||||
continue
|
||||
}
|
||||
body := response.Body.Bytes()
|
||||
if tc.gzip {
|
||||
reader, err := gzip.NewReader(bytes.NewReader(body))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
body, err = io.ReadAll(reader)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_ = reader.Close()
|
||||
}
|
||||
expected := raw
|
||||
if tc.status == 206 {
|
||||
expected = raw[:4]
|
||||
}
|
||||
if !bytes.Equal(body, expected) {
|
||||
t.Fatalf("mismatched delivered bytes for %+v", tc)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
cmd/diagnostic-gateway/Dockerfile
Normal file
11
cmd/diagnostic-gateway/Dockerfile
Normal file
@ -0,0 +1,11 @@
|
||||
FROM golang:1.24 AS build
|
||||
WORKDIR /build
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
COPY cmd/diagnostic-gateway ./cmd/diagnostic-gateway
|
||||
RUN CGO_ENABLED=0 go build -trimpath -o /gateway ./cmd/diagnostic-gateway
|
||||
FROM scratch
|
||||
COPY --from=build /gateway /gateway
|
||||
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
||||
USER 65532:65532
|
||||
ENTRYPOINT ["/gateway"]
|
||||
55
cmd/diagnostic-gateway/configure.go
Normal file
55
cmd/diagnostic-gateway/configure.go
Normal file
@ -0,0 +1,55 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func configureDiagnostics(g *gateway, client *http.Client, ns, tokenFile string) {
|
||||
d := newDiagnostics()
|
||||
g.diagnostics = d
|
||||
if os.Getenv("DIAGNOSTIC_LOGS_ENABLED") == "true" {
|
||||
d.logs = logLoader(client, "https://kubernetes.default.svc", ns, func() (string, error) { b, e := os.ReadFile(tokenFile); return strings.TrimSpace(string(b)), e })
|
||||
}
|
||||
if file := os.Getenv("DIAGNOSTIC_MONGO_URI_FILE"); file != "" {
|
||||
raw, e := os.ReadFile(file)
|
||||
if e != nil {
|
||||
log.Fatal("diagnostic Mongo credential unavailable")
|
||||
}
|
||||
org := os.Getenv("DIAGNOSTIC_ORGANIZATION")
|
||||
if org == "" {
|
||||
log.Fatal("diagnostic organization required")
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
||||
defer cancel()
|
||||
c, e := mongo.Connect(ctx, options.Client().ApplyURI(strings.TrimSpace(string(raw))).SetMaxPoolSize(2).SetRetryReads(false).SetRetryWrites(false).SetServerSelectionTimeout(2*time.Second))
|
||||
if e != nil {
|
||||
log.Fatal("diagnostic Mongo connection failed")
|
||||
}
|
||||
if checkPrivileges(ctx, c, "drobodata-fanyu") != nil {
|
||||
log.Fatal("diagnostic Mongo identity must have find-only access to the four views")
|
||||
}
|
||||
d.task = mongoTaskLoader(c, "drobodata-fanyu", org)
|
||||
}
|
||||
if file := os.Getenv("DIAGNOSTIC_BCM_CONFIG_FILE"); file != "" {
|
||||
collect, e := newBCMCollector(file)
|
||||
if e != nil {
|
||||
log.Fatal("invalid BCM configuration")
|
||||
}
|
||||
go func() {
|
||||
for {
|
||||
v := collect()
|
||||
d.mu.Lock()
|
||||
d.egress = v
|
||||
d.mu.Unlock()
|
||||
time.Sleep(time.Minute)
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
206
cmd/diagnostic-gateway/diagnostics.go
Normal file
206
cmd/diagnostic-gateway/diagnostics.go
Normal file
@ -0,0 +1,206 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
type diagnosticResult struct {
|
||||
Available bool `json:"available"`
|
||||
ObservedAt string `json:"observedAt"`
|
||||
Evidence any `json:"evidence,omitempty"`
|
||||
Limitations []string `json:"limitations,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
type diagnosticLoader func(context.Context, string) (diagnosticResult, error)
|
||||
type cachedDiagnostic struct {
|
||||
at time.Time
|
||||
result diagnosticResult
|
||||
}
|
||||
type diagnostics struct {
|
||||
task, logs diagnosticLoader
|
||||
mu sync.Mutex
|
||||
cache map[string]cachedDiagnostic
|
||||
busy chan struct{}
|
||||
egress diagnosticResult
|
||||
}
|
||||
|
||||
var taskIDPattern = regexp.MustCompile(`^annotation-task-[A-Za-z0-9_-]{1,100}$`)
|
||||
var requestIDPattern = regexp.MustCompile(`^[a-f0-9]{32}$`)
|
||||
|
||||
func newDiagnostics() *diagnostics {
|
||||
return &diagnostics{cache: map[string]cachedDiagnostic{}, busy: make(chan struct{}, 2), egress: diagnosticResult{Error: "bcm_not_configured"}}
|
||||
}
|
||||
func (d *diagnostics) serve(w http.ResponseWriter, r *http.Request) bool {
|
||||
path := strings.TrimPrefix(r.URL.Path, "/diagnostics/v1/")
|
||||
var loader diagnosticLoader
|
||||
arg := ""
|
||||
switch {
|
||||
case path == "egress":
|
||||
d.mu.Lock()
|
||||
v := d.egress
|
||||
d.mu.Unlock()
|
||||
if stamp, err := time.Parse(time.RFC3339, v.ObservedAt); v.Available && (err != nil || time.Since(stamp) > 2*time.Minute) {
|
||||
v = diagnosticResult{Error: "bcm_snapshot_stale"}
|
||||
}
|
||||
writeDiagnostic(w, v)
|
||||
return true
|
||||
case strings.HasPrefix(path, "tasks/"):
|
||||
arg = strings.TrimPrefix(path, "tasks/")
|
||||
if !taskIDPattern.MatchString(arg) {
|
||||
http.Error(w, `{"error":"invalid_task_id"}`, 400)
|
||||
return true
|
||||
}
|
||||
loader = d.task
|
||||
case strings.HasPrefix(path, "logs/api/"):
|
||||
arg = strings.TrimPrefix(path, "logs/api/")
|
||||
if !requestIDPattern.MatchString(arg) {
|
||||
http.Error(w, `{"error":"invalid_request_id"}`, 400)
|
||||
return true
|
||||
}
|
||||
loader = d.logs
|
||||
default:
|
||||
return false
|
||||
}
|
||||
if loader == nil {
|
||||
writeDiagnostic(w, diagnosticResult{Error: "adapter_not_configured"})
|
||||
return true
|
||||
}
|
||||
d.mu.Lock()
|
||||
cached, ok := d.cache[path]
|
||||
d.mu.Unlock()
|
||||
if ok && time.Since(cached.at) < 15*time.Second {
|
||||
writeDiagnostic(w, cached.result)
|
||||
return true
|
||||
}
|
||||
select {
|
||||
case d.busy <- struct{}{}:
|
||||
defer func() { <-d.busy }()
|
||||
default:
|
||||
http.Error(w, `{"error":"diagnostic_busy"}`, 429)
|
||||
return true
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(r.Context(), 3*time.Second)
|
||||
defer cancel()
|
||||
v, e := loader(ctx, arg)
|
||||
if e != nil {
|
||||
v = diagnosticResult{Error: "upstream_unavailable_or_timed_out"}
|
||||
}
|
||||
v.ObservedAt = time.Now().UTC().Format(time.RFC3339)
|
||||
d.mu.Lock()
|
||||
if len(d.cache) >= 128 {
|
||||
d.cache = map[string]cachedDiagnostic{}
|
||||
}
|
||||
d.cache[path] = cachedDiagnostic{time.Now(), v}
|
||||
d.mu.Unlock()
|
||||
writeDiagnostic(w, v)
|
||||
return true
|
||||
}
|
||||
func writeDiagnostic(w http.ResponseWriter, v diagnosticResult) {
|
||||
if !v.Available {
|
||||
w.WriteHeader(503)
|
||||
}
|
||||
json.NewEncoder(w).Encode(v)
|
||||
}
|
||||
|
||||
// Only already structured request traces are eligible. Unknown text never leaves the gateway.
|
||||
var tracePattern = regexp.MustCompile(`request_trace id=([a-f0-9]{32}) kind=(login|diagnostic|slow)(?: method=(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS) path=\S+)? status=([0-9]{3}) elapsed_ms=([0-9]{1,9})(?:\s|$)`)
|
||||
|
||||
func parseTraces(raw, requestID string) []map[string]string {
|
||||
out := []map[string]string{}
|
||||
for _, line := range strings.Split(raw, "\n") {
|
||||
m := tracePattern.FindStringSubmatch(line)
|
||||
if len(m) == 0 || m[1] != requestID {
|
||||
continue
|
||||
}
|
||||
stamp := strings.Fields(line)[0]
|
||||
if _, e := time.Parse(time.RFC3339Nano, stamp); e != nil {
|
||||
continue
|
||||
}
|
||||
out = append(out, map[string]string{"timestamp": stamp, "requestId": m[1], "kind": m[2], "method": m[3], "status": m[4], "elapsedMs": m[5]})
|
||||
}
|
||||
return out
|
||||
}
|
||||
func getBounded(ctx context.Context, client *http.Client, base, path, token string, limit int) ([]byte, error) {
|
||||
req, e := http.NewRequestWithContext(ctx, "GET", base+path, nil)
|
||||
if e != nil {
|
||||
return nil, e
|
||||
}
|
||||
req.Header.Set("Authorization", "Bearer "+token)
|
||||
resp, e := client.Do(req)
|
||||
if e != nil {
|
||||
return nil, e
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != 200 {
|
||||
return nil, errors.New("upstream unavailable")
|
||||
}
|
||||
b, e := io.ReadAll(io.LimitReader(resp.Body, int64(limit+1)))
|
||||
if e != nil || len(b) > limit {
|
||||
return nil, errors.New("response limit")
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
func logLoader(client *http.Client, base, ns string, token func() (string, error)) diagnosticLoader {
|
||||
return func(ctx context.Context, id string) (diagnosticResult, error) {
|
||||
t, e := token()
|
||||
if e != nil {
|
||||
return diagnosticResult{}, e
|
||||
}
|
||||
b, e := getBounded(ctx, client, base, "/api/v1/namespaces/"+url.PathEscape(ns)+"/pods?labelSelector=app%3Ddroboticflow-api&limit=10", t, 256*1024)
|
||||
if e != nil {
|
||||
return diagnosticResult{}, e
|
||||
}
|
||||
var list struct {
|
||||
Items []struct {
|
||||
Metadata struct {
|
||||
Name string `json:"name"`
|
||||
} `json:"metadata"`
|
||||
Spec struct {
|
||||
Containers []struct {
|
||||
Name string `json:"name"`
|
||||
} `json:"containers"`
|
||||
} `json:"spec"`
|
||||
} `json:"items"`
|
||||
Metadata struct {
|
||||
Continue string `json:"continue"`
|
||||
} `json:"metadata"`
|
||||
}
|
||||
if json.Unmarshal(b, &list) != nil {
|
||||
return diagnosticResult{}, errors.New("invalid pods")
|
||||
}
|
||||
evidence := []map[string]string{}
|
||||
n := 0
|
||||
for _, pod := range list.Items {
|
||||
if n == 2 {
|
||||
break
|
||||
}
|
||||
if len(pod.Spec.Containers) == 0 {
|
||||
continue
|
||||
}
|
||||
n++
|
||||
path := "/api/v1/namespaces/" + url.PathEscape(ns) + "/pods/" + url.PathEscape(pod.Metadata.Name) + "/log?timestamps=true&sinceSeconds=900&tailLines=200&limitBytes=65536&container=" + url.QueryEscape(pod.Spec.Containers[0].Name)
|
||||
raw, e := getBounded(ctx, client, base, path, t, 65536)
|
||||
if e != nil {
|
||||
return diagnosticResult{}, e
|
||||
}
|
||||
for _, line := range parseTraces(string(raw), id) {
|
||||
line["pod"] = pod.Metadata.Name
|
||||
evidence = append(evidence, line)
|
||||
}
|
||||
}
|
||||
limitations := []string{"Only structured request_trace records; raw logs and route parameters omitted", "Last 15 minutes, at most 200 lines/64KiB per pod; logs may be rotated", "No matching trace is insufficient evidence, not proof of success"}
|
||||
if len(list.Items) > 2 || list.Metadata.Continue != "" {
|
||||
limitations = append(limitations, "Partial pod coverage: only first two API pods inspected")
|
||||
}
|
||||
return diagnosticResult{Available: true, Evidence: evidence, Limitations: limitations}, nil
|
||||
}
|
||||
}
|
||||
132
cmd/diagnostic-gateway/diagnostics_test.go
Normal file
132
cmd/diagnostic-gateway/diagnostics_test.go
Normal file
@ -0,0 +1,132 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func testGateway(d *diagnostics) *gateway {
|
||||
return &gateway{diagnostics: d, keys: [][32]byte{sha256.Sum256([]byte("test-key"))}, snapshots: map[string]snapshot{}}
|
||||
}
|
||||
func request(g *gateway, path string) *httptest.ResponseRecorder {
|
||||
r := httptest.NewRequest("GET", path, nil)
|
||||
r.Header.Set("Authorization", "Bearer test-key")
|
||||
w := httptest.NewRecorder()
|
||||
g.ServeHTTP(w, r)
|
||||
return w
|
||||
}
|
||||
func TestDiagnosticHTTPContracts(t *testing.T) {
|
||||
d := newDiagnostics()
|
||||
g := testGateway(d)
|
||||
if w := request(g, "/diagnostics/v1/egress"); w.Code != 503 {
|
||||
t.Fatal(w.Code)
|
||||
}
|
||||
if w := request(g, "/diagnostics/v1/tasks/annotation-task-test"); w.Code != 503 {
|
||||
t.Fatal(w.Code)
|
||||
}
|
||||
for _, path := range []string{"tasks/$where", "tasks/annotation-task-x?filter=bad", "logs/api/../../../secrets", "logs/api/not-a-request-id"} {
|
||||
if w := request(g, "/diagnostics/v1/"+path); w.Code != 400 && w.Code != 404 {
|
||||
t.Fatalf("%s %d", path, w.Code)
|
||||
}
|
||||
}
|
||||
var calls atomic.Int32
|
||||
d.task = func(context.Context, string) (diagnosticResult, error) {
|
||||
calls.Add(1)
|
||||
return diagnosticResult{Available: true, Evidence: map[string]string{"finding": "task_currently_cancelled"}}, nil
|
||||
}
|
||||
for i := 0; i < 5; i++ {
|
||||
if w := request(g, "/diagnostics/v1/tasks/annotation-task-test"); w.Code != 200 {
|
||||
t.Fatal(w.Code)
|
||||
}
|
||||
}
|
||||
if calls.Load() != 1 {
|
||||
t.Fatal("polling repeated source reads")
|
||||
}
|
||||
d.task = func(context.Context, string) (diagnosticResult, error) {
|
||||
return diagnosticResult{}, errors.New("mongodb://user:secret@host customer payload")
|
||||
}
|
||||
w := request(g, "/diagnostics/v1/tasks/annotation-task-other")
|
||||
if w.Code != 503 || strings.Contains(w.Body.String(), "secret") {
|
||||
t.Fatal("upstream details leaked")
|
||||
}
|
||||
}
|
||||
func TestTraceFiltering(t *testing.T) {
|
||||
id := strings.Repeat("a", 32)
|
||||
raw := "2026-11-10T01:00:00Z request_trace id=" + id + " kind=slow method=GET path=/api/private/customer-secret status=504 elapsed_ms=12000 token=secret\npassword=secret\n"
|
||||
out := parseTraces(raw, id)
|
||||
b, _ := json.Marshal(out)
|
||||
if len(out) != 1 || strings.Contains(string(b), "secret") || strings.Contains(string(b), "private") {
|
||||
t.Fatal(string(b))
|
||||
}
|
||||
if len(parseTraces(raw, strings.Repeat("b", 32))) != 0 {
|
||||
t.Fatal("cross-request trace")
|
||||
}
|
||||
}
|
||||
func TestDiagnosticConcurrencyAndCancellation(t *testing.T) {
|
||||
d := newDiagnostics()
|
||||
g := testGateway(d)
|
||||
entered := make(chan struct{}, 2)
|
||||
release := make(chan struct{})
|
||||
d.task = func(ctx context.Context, id string) (diagnosticResult, error) {
|
||||
entered <- struct{}{}
|
||||
select {
|
||||
case <-release:
|
||||
return diagnosticResult{Available: true}, nil
|
||||
case <-ctx.Done():
|
||||
return diagnosticResult{}, ctx.Err()
|
||||
}
|
||||
}
|
||||
done := make(chan struct{}, 2)
|
||||
for _, id := range []string{"a", "b"} {
|
||||
go func(id string) { request(g, "/diagnostics/v1/tasks/annotation-task-"+id); done <- struct{}{} }(id)
|
||||
}
|
||||
for i := 0; i < 2; i++ {
|
||||
select {
|
||||
case <-entered:
|
||||
case <-time.After(time.Second):
|
||||
t.Fatal("not started")
|
||||
}
|
||||
}
|
||||
if w := request(g, "/diagnostics/v1/tasks/annotation-task-c"); w.Code != 429 {
|
||||
t.Fatal(w.Code)
|
||||
}
|
||||
close(release)
|
||||
<-done
|
||||
<-done
|
||||
}
|
||||
func TestLogLoaderBoundedAndNoRawOutput(t *testing.T) {
|
||||
id := strings.Repeat("c", 32)
|
||||
var calls atomic.Int32
|
||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
calls.Add(1)
|
||||
if strings.HasSuffix(r.URL.Path, "/pods") {
|
||||
if r.URL.Query().Get("labelSelector") != "app=droboticflow-api" {
|
||||
t.Error("arbitrary selector")
|
||||
}
|
||||
w.Write([]byte(`{"items":[{"metadata":{"name":"api-1"},"spec":{"containers":[{"name":"api"}]}},{"metadata":{"name":"api-2"},"spec":{"containers":[{"name":"api"}]}},{"metadata":{"name":"api-3"}}]}`))
|
||||
return
|
||||
}
|
||||
if r.URL.Query().Get("follow") != "" || r.URL.Query().Get("limitBytes") != "65536" {
|
||||
t.Error("unbounded log query")
|
||||
}
|
||||
w.Write([]byte("2026-11-10T01:00:00Z request_trace id=" + id + " kind=diagnostic status=500 elapsed_ms=3000\nSECRET raw payload"))
|
||||
}))
|
||||
defer s.Close()
|
||||
loader := logLoader(s.Client(), s.URL, "test", func() (string, error) { return "token", nil })
|
||||
v, e := loader(context.Background(), id)
|
||||
if e != nil || !v.Available || calls.Load() != 3 {
|
||||
t.Fatalf("%v %v", v, e)
|
||||
}
|
||||
b, _ := json.Marshal(v)
|
||||
if strings.Contains(string(b), "SECRET") || !strings.Contains(string(b), "Partial pod coverage") {
|
||||
t.Fatal(string(b))
|
||||
}
|
||||
}
|
||||
69
cmd/diagnostic-gateway/egress.go
Normal file
69
cmd/diagnostic-gateway/egress.go
Normal file
@ -0,0 +1,69 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/baidubce/bce-sdk-go/bce"
|
||||
"github.com/baidubce/bce-sdk-go/services/bcm"
|
||||
"github.com/baidubce/bce-sdk-go/services/bcm/model"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
type bcmConfiguration struct{ AK, SK, UserID, InstanceID, Scope string }
|
||||
|
||||
func newBCMCollector(file string) (func() diagnosticResult, error) {
|
||||
raw, e := os.ReadFile(file)
|
||||
if e != nil {
|
||||
return nil, e
|
||||
}
|
||||
var cfg bcmConfiguration
|
||||
if json.Unmarshal(raw, &cfg) != nil || cfg.AK == "" || cfg.SK == "" || cfg.UserID == "" || cfg.InstanceID == "" || cfg.Scope != "BCE_EIP" {
|
||||
return nil, errors.New("invalid fixed EIP configuration")
|
||||
}
|
||||
c, e := bcm.NewClient(cfg.AK, cfg.SK, "https://bcm.bj.baidubce.com")
|
||||
if e != nil {
|
||||
return nil, e
|
||||
}
|
||||
c.Config.ConnectionTimeoutInMillis = 3000
|
||||
c.Config.Retry = bce.NewNoRetryPolicy()
|
||||
return func() diagnosticResult { return collectEgress(c, cfg, time.Now().UTC()) }, nil
|
||||
}
|
||||
|
||||
type metricReader interface {
|
||||
GetMetricData(*model.GetMetricDataRequest) (*model.GetMetricDataResponse, error)
|
||||
}
|
||||
|
||||
func collectEgress(c metricReader, cfg bcmConfiguration, now time.Time) diagnosticResult {
|
||||
evidence := map[string]any{"instanceId": cfg.InstanceID, "periodSeconds": 60, "configuredLimitMbps": 50, "windowStart": now.Add(-time.Hour).Format(time.RFC3339), "windowEnd": now.Format(time.RFC3339)}
|
||||
for _, metric := range []string{"WebOutBitsPerSecond", "WebInBitsPerSecond"} {
|
||||
r, e := c.GetMetricData(&model.GetMetricDataRequest{UserId: cfg.UserID, Scope: cfg.Scope, MetricName: metric, Dimensions: map[string]string{"InstanceId": cfg.InstanceID}, Statistics: []string{"average", "maximum"}, PeriodInSecond: 60, StartTime: now.Add(-time.Hour).Format(time.RFC3339), EndTime: now.Format(time.RFC3339)})
|
||||
if e != nil || r == nil || r.Code != "OK" {
|
||||
return diagnosticResult{Error: "bcm_unavailable", ObservedAt: now.Format(time.RFC3339)}
|
||||
}
|
||||
if len(r.DataPoints) == 0 || len(r.DataPoints) > 61 {
|
||||
return diagnosticResult{Error: "bcm_missing_or_excessive_points", ObservedAt: now.Format(time.RFC3339)}
|
||||
}
|
||||
latest := time.Time{}
|
||||
for _, point := range r.DataPoints {
|
||||
if point == nil {
|
||||
return diagnosticResult{Error: "bcm_invalid_points"}
|
||||
}
|
||||
stamp, e := time.Parse(time.RFC3339, point.Timestamp)
|
||||
if e != nil || stamp.After(now.Add(time.Minute)) || stamp.Before(now.Add(-time.Hour-time.Minute)) {
|
||||
return diagnosticResult{Error: "bcm_invalid_timestamp"}
|
||||
}
|
||||
if point.Average == nil || point.Maximum == nil || *point.Average < 0 || *point.Maximum < 0 {
|
||||
return diagnosticResult{Error: "bcm_invalid_value"}
|
||||
}
|
||||
if stamp.After(latest) {
|
||||
latest = stamp
|
||||
}
|
||||
}
|
||||
if now.Sub(latest) > 5*time.Minute {
|
||||
return diagnosticResult{Error: "bcm_stale_data", ObservedAt: now.Format(time.RFC3339)}
|
||||
}
|
||||
evidence[metric] = r.DataPoints
|
||||
}
|
||||
return diagnosticResult{Available: true, ObservedAt: now.Format(time.RFC3339), Evidence: evidence, Limitations: []string{"bps, one-minute averages/maxima; inspect source timestamps for delayed samples", "Bandwidth configuration is not measured utilization; no packet-drop metrics connected yet"}}
|
||||
}
|
||||
55
cmd/diagnostic-gateway/egress_test.go
Normal file
55
cmd/diagnostic-gateway/egress_test.go
Normal file
@ -0,0 +1,55 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/baidubce/bce-sdk-go/services/bcm/model"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
type fakeMetrics struct {
|
||||
response *model.GetMetricDataResponse
|
||||
calls []*model.GetMetricDataRequest
|
||||
}
|
||||
|
||||
func (f *fakeMetrics) GetMetricData(r *model.GetMetricDataRequest) (*model.GetMetricDataResponse, error) {
|
||||
f.calls = append(f.calls, r)
|
||||
return f.response, nil
|
||||
}
|
||||
func TestEgressEvidenceAndMissingStaleData(t *testing.T) {
|
||||
now := time.Date(2026, 11, 10, 10, 0, 0, 0, time.UTC)
|
||||
v := 12000000.0
|
||||
f := &fakeMetrics{response: &model.GetMetricDataResponse{Code: "OK", DataPoints: []*model.DataPoints{{Timestamp: now.Add(-time.Minute).Format(time.RFC3339), Average: &v, Maximum: &v}}}}
|
||||
cfg := bcmConfiguration{InstanceID: "fixed-instance", Scope: "BCE_EIP", UserID: "account"}
|
||||
got := collectEgress(f, cfg, now)
|
||||
if !got.Available || len(f.calls) != 2 {
|
||||
t.Fatalf("%+v", got)
|
||||
}
|
||||
for _, r := range f.calls {
|
||||
if r.Dimensions["InstanceId"] != "fixed-instance" || r.PeriodInSecond != 60 {
|
||||
t.Fatal("metric scope escaped")
|
||||
}
|
||||
}
|
||||
f.response.DataPoints[0].Timestamp = now.Add(-10 * time.Minute).Format(time.RFC3339)
|
||||
if got = collectEgress(f, cfg, now); got.Available || got.Error != "bcm_stale_data" {
|
||||
t.Fatal(got)
|
||||
}
|
||||
f.response.DataPoints = nil
|
||||
if got = collectEgress(f, cfg, now); got.Available {
|
||||
t.Fatal("missing data treated as zero")
|
||||
}
|
||||
}
|
||||
|
||||
func TestEgressHTTPRejectsStaleSnapshot(t *testing.T) {
|
||||
d := newDiagnostics()
|
||||
for _, sample := range []struct {
|
||||
age time.Duration
|
||||
status int
|
||||
}{{time.Second, 200}, {3 * time.Minute, 503}} {
|
||||
d.egress = diagnosticResult{Available: true, ObservedAt: time.Now().Add(-sample.age).UTC().Format(time.RFC3339), Evidence: map[string]int{"bps": 12000000}}
|
||||
w := httptest.NewRecorder()
|
||||
if !d.serve(w, httptest.NewRequest("GET", "/diagnostics/v1/egress", nil)) || w.Code != sample.status {
|
||||
t.Fatalf("status=%d body=%s", w.Code, w.Body.String())
|
||||
}
|
||||
}
|
||||
}
|
||||
235
cmd/diagnostic-gateway/main.go
Normal file
235
cmd/diagnostic-gateway/main.go
Normal file
@ -0,0 +1,235 @@
|
||||
// diagnostic-gateway exposes bounded, projected Kubernetes snapshots.
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"crypto/subtle"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
type snapshot struct {
|
||||
Data any `json:"data,omitempty"`
|
||||
ObservedAt string `json:"observedAt,omitempty"`
|
||||
Available bool `json:"available"`
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
type gateway struct {
|
||||
diagnostics *diagnostics
|
||||
mu sync.RWMutex
|
||||
snapshots map[string]snapshot
|
||||
keys [][32]byte
|
||||
rateMu sync.Mutex
|
||||
windows map[[32]byte]time.Time
|
||||
hits map[[32]byte]int
|
||||
}
|
||||
type resource struct {
|
||||
Metadata struct {
|
||||
Name string `json:"name"`
|
||||
Namespace string `json:"namespace"`
|
||||
} `json:"metadata"`
|
||||
Spec struct {
|
||||
NodeName string `json:"nodeName"`
|
||||
Containers []struct {
|
||||
Name string `json:"name"`
|
||||
Image string `json:"image"`
|
||||
Resources map[string]map[string]string `json:"resources"`
|
||||
} `json:"containers"`
|
||||
} `json:"spec"`
|
||||
Status struct {
|
||||
Phase string `json:"phase"`
|
||||
Capacity map[string]string `json:"capacity"`
|
||||
Allocatable map[string]string `json:"allocatable"`
|
||||
Conditions []struct {
|
||||
Type string `json:"type"`
|
||||
Status string `json:"status"`
|
||||
Reason string `json:"reason"`
|
||||
} `json:"conditions"`
|
||||
ContainerStatuses []struct {
|
||||
Name string `json:"name"`
|
||||
Ready bool `json:"ready"`
|
||||
RestartCount int `json:"restartCount"`
|
||||
} `json:"containerStatuses"`
|
||||
} `json:"status"`
|
||||
Timestamp string `json:"timestamp"`
|
||||
Window string `json:"window"`
|
||||
Usage map[string]string `json:"usage"`
|
||||
Containers []struct {
|
||||
Name string `json:"name"`
|
||||
Usage map[string]string `json:"usage"`
|
||||
} `json:"containers"`
|
||||
}
|
||||
|
||||
func project(r resource) map[string]any {
|
||||
return map[string]any{"name": r.Metadata.Name, "namespace": r.Metadata.Namespace, "node": r.Spec.NodeName, "containers": r.Spec.Containers, "status": r.Status, "timestamp": r.Timestamp, "window": r.Window, "usage": r.Usage, "containerUsage": r.Containers}
|
||||
}
|
||||
func collect(ctx context.Context, client *http.Client, base, path, tokenFile string) snapshot {
|
||||
token, e := os.ReadFile(tokenFile)
|
||||
if e != nil {
|
||||
return snapshot{Error: "upstream_credentials_unavailable"}
|
||||
}
|
||||
req, e := http.NewRequestWithContext(ctx, "GET", base+path, nil)
|
||||
if e != nil {
|
||||
return snapshot{Error: "upstream_configuration_invalid"}
|
||||
}
|
||||
req.Header.Set("Authorization", "Bearer "+strings.TrimSpace(string(token)))
|
||||
resp, e := client.Do(req)
|
||||
if e != nil {
|
||||
return snapshot{Error: "upstream_unavailable"}
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != 200 {
|
||||
return snapshot{Error: fmt.Sprintf("upstream_status_%d", resp.StatusCode)}
|
||||
}
|
||||
raw, e := io.ReadAll(io.LimitReader(resp.Body, 4*1024*1024+1))
|
||||
if e != nil || len(raw) > 4*1024*1024 {
|
||||
return snapshot{Error: "upstream_response_limit"}
|
||||
}
|
||||
var list struct {
|
||||
Items []resource `json:"items"`
|
||||
Metadata struct {
|
||||
Continue string `json:"continue"`
|
||||
} `json:"metadata"`
|
||||
}
|
||||
if json.Unmarshal(raw, &list) != nil {
|
||||
return snapshot{Error: "upstream_invalid_json"}
|
||||
}
|
||||
if list.Metadata.Continue != "" || len(list.Items) > 500 {
|
||||
return snapshot{Error: "upstream_result_truncated"}
|
||||
}
|
||||
out := make([]map[string]any, 0, len(list.Items))
|
||||
for _, r := range list.Items {
|
||||
out = append(out, project(r))
|
||||
}
|
||||
return snapshot{Available: true, ObservedAt: time.Now().UTC().Format(time.RFC3339), Data: out}
|
||||
}
|
||||
func (g *gateway) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Header().Set("Cache-Control", "no-store")
|
||||
if r.URL.Path == "/healthz" && r.Method == "GET" {
|
||||
io.WriteString(w, `{"status":"ok"}`)
|
||||
return
|
||||
}
|
||||
candidate := sha256.Sum256([]byte(strings.TrimPrefix(r.Header.Get("Authorization"), "Bearer ")))
|
||||
allowed := 0
|
||||
for _, key := range g.keys {
|
||||
allowed |= subtle.ConstantTimeCompare(candidate[:], key[:])
|
||||
}
|
||||
if allowed != 1 || !strings.HasPrefix(r.Header.Get("Authorization"), "Bearer ") {
|
||||
http.Error(w, `{"error":"unauthorized"}`, 401)
|
||||
return
|
||||
}
|
||||
g.rateMu.Lock()
|
||||
if g.windows == nil {
|
||||
g.windows = map[[32]byte]time.Time{}
|
||||
g.hits = map[[32]byte]int{}
|
||||
}
|
||||
if time.Since(g.windows[candidate]) >= time.Minute {
|
||||
g.windows[candidate] = time.Now()
|
||||
g.hits[candidate] = 0
|
||||
}
|
||||
g.hits[candidate]++
|
||||
limited := g.hits[candidate] > 60
|
||||
g.rateMu.Unlock()
|
||||
if limited {
|
||||
w.Header().Set("Retry-After", "60")
|
||||
http.Error(w, `{"error":"rate_limit"}`, 429)
|
||||
return
|
||||
}
|
||||
log.Printf("diagnostic_read key_id=%x method=%q path=%q", candidate[:6], r.Method, r.URL.Path)
|
||||
if r.Method != "GET" {
|
||||
http.Error(w, `{"error":"read_only"}`, 405)
|
||||
return
|
||||
}
|
||||
if r.URL.RawQuery != "" {
|
||||
http.Error(w, `{"error":"query_parameters_not_supported"}`, 400)
|
||||
return
|
||||
}
|
||||
if g.diagnostics != nil && g.diagnostics.serve(w, r) {
|
||||
return
|
||||
}
|
||||
if r.URL.Path == "/diagnostics/v1/capabilities" {
|
||||
json.NewEncoder(w).Encode(map[string]any{"version": 2, "transport": "http-json", "tools": []string{"nodes", "pods", "node-usage", "pod-usage"}, "diagnosticRoutes": []string{"tasks/{taskId}", "logs/api/{requestId}", "egress"}, "configured": map[string]bool{"tasks": g.diagnostics != nil && g.diagnostics.task != nil, "logs": g.diagnostics != nil && g.diagnostics.logs != nil}, "refreshSeconds": 30, "unavailable": []string{"source-code", "mcp"}, "mutations": false})
|
||||
return
|
||||
}
|
||||
key := strings.TrimPrefix(r.URL.Path, "/diagnostics/v1/")
|
||||
if key == r.URL.Path {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
g.mu.RLock()
|
||||
s, ok := g.snapshots[key]
|
||||
g.mu.RUnlock()
|
||||
if !ok {
|
||||
http.NotFound(w, r)
|
||||
return
|
||||
}
|
||||
if !s.Available {
|
||||
w.WriteHeader(503)
|
||||
}
|
||||
json.NewEncoder(w).Encode(s)
|
||||
}
|
||||
func main() {
|
||||
keyFile := os.Getenv("DIAGNOSTIC_KEYS_FILE")
|
||||
raw, e := os.ReadFile(keyFile)
|
||||
if e != nil {
|
||||
log.Fatal("DIAGNOSTIC_KEYS_FILE must reference a readable private key file")
|
||||
}
|
||||
g := &gateway{snapshots: map[string]snapshot{}}
|
||||
for _, k := range strings.Fields(string(raw)) {
|
||||
if len(k) < 32 {
|
||||
log.Fatal("keys must be at least 32 characters")
|
||||
}
|
||||
g.keys = append(g.keys, sha256.Sum256([]byte(k)))
|
||||
}
|
||||
if len(g.keys) == 0 {
|
||||
log.Fatal("keys required")
|
||||
}
|
||||
ns := os.Getenv("DIAGNOSTIC_NAMESPACE")
|
||||
if ns == "" {
|
||||
ns = "droboticflow-fanyu"
|
||||
}
|
||||
for _, c := range ns {
|
||||
if !(c >= 'a' && c <= 'z' || c >= '0' && c <= '9' || c == '-') {
|
||||
log.Fatal("invalid namespace")
|
||||
}
|
||||
}
|
||||
const sa = "/var/run/secrets/kubernetes.io/serviceaccount/"
|
||||
ca, e := os.ReadFile(sa + "ca.crt")
|
||||
if e != nil {
|
||||
log.Fatal("in-cluster CA required")
|
||||
}
|
||||
pool := x509.NewCertPool()
|
||||
if !pool.AppendCertsFromPEM(ca) {
|
||||
log.Fatal("invalid cluster CA")
|
||||
}
|
||||
client := &http.Client{Timeout: 5 * time.Second, Transport: &http.Transport{TLSClientConfig: &tls.Config{RootCAs: pool, MinVersion: tls.VersionTLS12}, MaxConnsPerHost: 1}, CheckRedirect: func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse }}
|
||||
configureDiagnostics(g, client, ns, sa+"token")
|
||||
paths := map[string]string{"nodes": "/api/v1/nodes?limit=500", "pods": "/api/v1/namespaces/" + ns + "/pods?limit=500", "node-usage": "/apis/metrics.k8s.io/v1beta1/nodes", "pod-usage": "/apis/metrics.k8s.io/v1beta1/namespaces/" + ns + "/pods"}
|
||||
for k := range paths {
|
||||
g.snapshots[k] = snapshot{Error: "warming_up"}
|
||||
}
|
||||
go func() {
|
||||
for {
|
||||
for k, p := range paths {
|
||||
s := collect(context.Background(), client, "https://kubernetes.default.svc", p, sa+"token")
|
||||
g.mu.Lock()
|
||||
g.snapshots[k] = s
|
||||
g.mu.Unlock()
|
||||
}
|
||||
time.Sleep(30 * time.Second)
|
||||
}
|
||||
}()
|
||||
server := &http.Server{Addr: ":8080", Handler: g, ReadHeaderTimeout: 3 * time.Second, ReadTimeout: 5 * time.Second, WriteTimeout: 5 * time.Second, IdleTimeout: 15 * time.Second, MaxHeaderBytes: 8192}
|
||||
log.Fatal(server.ListenAndServe())
|
||||
}
|
||||
56
cmd/diagnostic-gateway/main_test.go
Normal file
56
cmd/diagnostic-gateway/main_test.go
Normal file
@ -0,0 +1,56 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAuthorizationAndAllowlist(t *testing.T) {
|
||||
g := &gateway{keys: [][32]byte{sha256.Sum256([]byte("test-key"))}, snapshots: map[string]snapshot{"pods": {Available: true, Data: []string{}}}}
|
||||
for _, tc := range []struct {
|
||||
method, path, key string
|
||||
code int
|
||||
}{{"GET", "/diagnostics/v1/pods", "", 401}, {"POST", "/diagnostics/v1/pods", "test-key", 405}, {"GET", "/diagnostics/v1/pods?url=http://internal", "test-key", 400}, {"GET", "/diagnostics/v1/secrets", "test-key", 404}, {"GET", "/diagnostics/v1/pods", "test-key", 200}} {
|
||||
r := httptest.NewRequest(tc.method, tc.path, nil)
|
||||
if tc.key != "" {
|
||||
r.Header.Set("Authorization", "Bearer "+tc.key)
|
||||
}
|
||||
w := httptest.NewRecorder()
|
||||
g.ServeHTTP(w, r)
|
||||
if w.Code != tc.code {
|
||||
t.Fatalf("%s %s: %d", tc.method, tc.path, w.Code)
|
||||
}
|
||||
}
|
||||
}
|
||||
func TestProjectionOmitsSensitiveFields(t *testing.T) {
|
||||
var r resource
|
||||
if e := json.Unmarshal([]byte(`{"metadata":{"name":"pod","annotations":{"secret":"do-not-expose"}},"spec":{"containers":[{"name":"api","env":[{"name":"TOKEN","value":"do-not-expose"}]}]}}`), &r); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
b, _ := json.Marshal(project(r))
|
||||
if strings.Contains(string(b), "do-not-expose") {
|
||||
t.Fatal("sensitive field leaked")
|
||||
}
|
||||
}
|
||||
func TestCollectorRejectsPartialAndUpstreamErrors(t *testing.T) {
|
||||
p := t.TempDir() + "/token"
|
||||
os.WriteFile(p, []byte("private"), 0600)
|
||||
for _, body := range []string{`{"items":[],"metadata":{"continue":"next"}}`, `invalid`} {
|
||||
s := httptest.NewServer(httpHandler(body))
|
||||
got := collect(context.Background(), s.Client(), s.URL, "/", p)
|
||||
s.Close()
|
||||
if got.Available {
|
||||
t.Fatal("invalid snapshot accepted")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func httpHandler(body string) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Write([]byte(body)) })
|
||||
}
|
||||
85
cmd/diagnostic-gateway/mongo_isolated_test.go
Normal file
85
cmd/diagnostic-gateway/mongo_isolated_test.go
Normal file
@ -0,0 +1,85 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestIsolatedMongoViewOnlyDiagnosis(t *testing.T) {
|
||||
uri := os.Getenv("DIAGNOSTIC_TEST_MONGO_URI")
|
||||
if uri == "" {
|
||||
t.Skip("run deploy/diagnostic-gateway/test-isolated.py for authenticated fixture")
|
||||
}
|
||||
u, e := url.Parse(uri)
|
||||
if e != nil || u.Hostname() != "127.0.0.1" || !strings.HasPrefix(u.Path, "/diagnostic_test_") {
|
||||
t.Fatal("isolated localhost database required")
|
||||
}
|
||||
database := strings.TrimPrefix(u.Path, "/")
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
|
||||
defer cancel()
|
||||
c, e := mongo.Connect(ctx, options.Client().ApplyURI(uri).SetMaxPoolSize(2))
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
defer c.Disconnect(ctx)
|
||||
if e = checkPrivileges(ctx, c, database); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
db := c.Database(database)
|
||||
if e = db.Collection("annotationTasks").FindOne(ctx, bson.M{}).Err(); e == nil {
|
||||
t.Fatal("reader can access source collection")
|
||||
}
|
||||
if _, e = db.Collection("diagnostic_tasks_v1").InsertOne(ctx, bson.M{"id": "illegal"}); e == nil {
|
||||
t.Fatal("reader can write")
|
||||
}
|
||||
var view bson.M
|
||||
if e = db.Collection("diagnostic_tasks_v1").FindOne(ctx, bson.M{"id": "annotation-task-failed"}).Decode(&view); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
raw, _ := json.Marshal(view)
|
||||
if strings.Contains(string(raw), "CUSTOMER_SECRET") {
|
||||
t.Fatal("view leaked payload")
|
||||
}
|
||||
if n, e := db.Collection("diagnostic_tasks_v1").CountDocuments(ctx, bson.M{"organizationId": "other-org"}); e != nil || n != 0 {
|
||||
t.Fatal("organization leakage", e, n)
|
||||
}
|
||||
d := newDiagnostics()
|
||||
d.task = mongoTaskLoader(c, database, "test-org")
|
||||
g := testGateway(d)
|
||||
cases := []struct{ id, needle string }{{"failed", "task_validation_record_failed"}, {"cancelled", "task_currently_cancelled"}, {"processing", "processing_job_failed"}, {"recovered", "current state cannot prove historical failure cause"}, {"foreign", "taskFound\":false"}}
|
||||
for _, tc := range cases {
|
||||
w := request(g, "/diagnostics/v1/tasks/annotation-task-"+tc.id)
|
||||
if w.Code != 200 || !strings.Contains(w.Body.String(), tc.needle) || strings.Contains(w.Body.String(), "CUSTOMER_SECRET") {
|
||||
t.Fatalf("%s: %d %s", tc.id, w.Code, w.Body.String())
|
||||
}
|
||||
}
|
||||
start := time.Now()
|
||||
for i := 0; i < 40; i++ {
|
||||
w := request(g, "/diagnostics/v1/tasks/annotation-task-failed")
|
||||
if w.Code != 200 {
|
||||
t.Fatal(w.Code)
|
||||
}
|
||||
}
|
||||
t.Logf("40 warm HTTP diagnostics: %s (bounded cache)", time.Since(start))
|
||||
// Revocation invalidates source access after cached evidence expires; clear cache to test the next source read.
|
||||
adminURI := os.Getenv("DIAGNOSTIC_TEST_ADMIN_URI")
|
||||
a, e := mongo.Connect(ctx, options.Client().ApplyURI(adminURI))
|
||||
if e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
defer a.Disconnect(ctx)
|
||||
if e = a.Database(database).RunCommand(ctx, bson.D{{Key: "grantPrivilegesToRole", Value: "diagnostic_gateway_views_v1"}, {Key: "privileges", Value: bson.A{bson.M{"resource": bson.M{"db": database, "collection": "annotationTasks"}, "actions": bson.A{"find"}}}}}).Err(); e != nil {
|
||||
t.Fatal(e)
|
||||
}
|
||||
if e = checkPrivileges(ctx, c, database); e == nil {
|
||||
t.Fatal("expanded privileges accepted")
|
||||
}
|
||||
}
|
||||
107
cmd/diagnostic-gateway/task_diagnostics.go
Normal file
107
cmd/diagnostic-gateway/task_diagnostics.go
Normal file
@ -0,0 +1,107 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
"time"
|
||||
)
|
||||
|
||||
var diagnosticViews = []string{"diagnostic_tasks_v1", "diagnostic_items_v1", "diagnostic_validation_v1", "diagnostic_events_v1"}
|
||||
|
||||
func checkPrivileges(ctx context.Context, client *mongo.Client, dbName string) error {
|
||||
var out struct {
|
||||
AuthInfo struct {
|
||||
Users []bson.M `bson:"authenticatedUsers"`
|
||||
Privileges []struct {
|
||||
Resource struct {
|
||||
DB string `bson:"db"`
|
||||
Collection string `bson:"collection"`
|
||||
} `bson:"resource"`
|
||||
Actions []string `bson:"actions"`
|
||||
} `bson:"authenticatedUserPrivileges"`
|
||||
} `bson:"authInfo"`
|
||||
}
|
||||
if e := client.Database("admin").RunCommand(ctx, bson.D{{Key: "connectionStatus", Value: 1}, {Key: "showPrivileges", Value: true}}).Decode(&out); e != nil {
|
||||
return e
|
||||
}
|
||||
if len(out.AuthInfo.Users) != 1 || len(out.AuthInfo.Privileges) == 0 {
|
||||
return errors.New("dedicated authenticated identity required")
|
||||
}
|
||||
for _, p := range out.AuthInfo.Privileges {
|
||||
allowed := false
|
||||
for _, v := range diagnosticViews {
|
||||
if p.Resource.DB == dbName && p.Resource.Collection == v {
|
||||
allowed = true
|
||||
}
|
||||
}
|
||||
if !allowed {
|
||||
return errors.New("privilege outside diagnostic views")
|
||||
}
|
||||
for _, a := range p.Actions {
|
||||
if a != "find" {
|
||||
return errors.New("non-find privilege")
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func mongoTaskLoader(client *mongo.Client, dbName, org string) diagnosticLoader {
|
||||
return func(ctx context.Context, id string) (diagnosticResult, error) {
|
||||
if !taskIDPattern.MatchString(id) || org == "" {
|
||||
return diagnosticResult{}, errors.New("scope required")
|
||||
}
|
||||
// Recheck effective grants so a later privilege expansion fails closed.
|
||||
if e := checkPrivileges(ctx, client, dbName); e != nil {
|
||||
return diagnosticResult{}, e
|
||||
}
|
||||
db := client.Database(dbName)
|
||||
one := func(collection string, filter bson.M) (bson.M, error) {
|
||||
var result bson.M
|
||||
e := db.Collection(collection).FindOne(ctx, filter, options.FindOne().SetMaxTime(time.Second)).Decode(&result)
|
||||
if e == mongo.ErrNoDocuments {
|
||||
return nil, nil
|
||||
}
|
||||
return result, e
|
||||
}
|
||||
task, e := one("diagnostic_tasks_v1", bson.M{"id": id, "organizationId": org})
|
||||
if e != nil {
|
||||
return diagnosticResult{}, e
|
||||
}
|
||||
if task == nil {
|
||||
return diagnosticResult{Available: true, Evidence: bson.M{"taskFound": false}, Limitations: []string{"Not found in authorized scope; no conclusion about other organizations"}}, nil
|
||||
}
|
||||
item, e := one("diagnostic_items_v1", bson.M{"legacyTaskId": id, "organizationId": org})
|
||||
if e != nil {
|
||||
return diagnosticResult{}, e
|
||||
}
|
||||
validation, e := one("diagnostic_validation_v1", bson.M{"id": id, "organizationId": org})
|
||||
if e != nil {
|
||||
return diagnosticResult{}, e
|
||||
}
|
||||
events := []bson.M{}
|
||||
if item != nil {
|
||||
cur, e := db.Collection("diagnostic_events_v1").Find(ctx, bson.M{"itemId": item["id"], "organizationId": org}, options.Find().SetSort(bson.D{{Key: "createdAt", Value: -1}}).SetLimit(20).SetMaxTime(time.Second))
|
||||
if e != nil {
|
||||
return diagnosticResult{}, e
|
||||
}
|
||||
defer cur.Close(ctx)
|
||||
if e = cur.All(ctx, &events); e != nil {
|
||||
return diagnosticResult{}, e
|
||||
}
|
||||
}
|
||||
findings := []string{}
|
||||
if item != nil && item["status"] == "cancelled" {
|
||||
findings = append(findings, "task_currently_cancelled")
|
||||
}
|
||||
if validation != nil && validation["status"] == "failed" {
|
||||
findings = append(findings, "task_validation_record_failed")
|
||||
}
|
||||
if job, ok := item["processingJob"].(bson.M); ok && job["status"] == "failed" {
|
||||
findings = append(findings, "processing_job_failed")
|
||||
}
|
||||
return diagnosticResult{Available: true, Evidence: bson.M{"task": task, "item": item, "taskValidation": validation, "recentEvents": events, "findings": findings, "actorEligibility": "unknown"}, Limitations: []string{"State evidence only; no independent canClaim calculation", "Task-ID validation only; source-v1 certificate supersession is not fully diagnosed", "At most 20 recent events; current state cannot prove historical failure cause", "Deleted history cannot be reconstructed"}}, nil
|
||||
}
|
||||
}
|
||||
@ -49,6 +49,7 @@ func main() {
|
||||
}
|
||||
defer client.Disconnect(context.Background())
|
||||
dataStore := store.NewMongoStore(client.Database(cfg.MongoDB))
|
||||
dataStore.EnableQuerySourceTracking(os.Getenv("QUERY_SOURCE_TRACKING") == "1")
|
||||
if err := bootstrapCoordinator(ctx, dataStore, os.Getenv("DROBOTICFLOW_DATABASE_BOOTSTRAP")); err != nil {
|
||||
fmt.Printf("[drosync-coordinator] database bootstrap: %v\n", err)
|
||||
os.Exit(1)
|
||||
|
||||
54
cmd/pool-search-backfill/main.go
Normal file
54
cmd/pool-search-backfill/main.go
Normal file
@ -0,0 +1,54 @@
|
||||
// Explicit derived-field maintenance. Production execution requires the
|
||||
// project's separate customer-data write authorization; default is read-only.
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"droboticflow/internal/store"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
database := flag.String("database", "", "database name")
|
||||
org := flag.String("organization", "", "one organization ID")
|
||||
uriEnv := flag.String("uri-env", "POOL_BACKFILL_MONGO_URI", "environment variable containing Mongo URI")
|
||||
collection := flag.String("collection", "", "optional humanItems-only maintenance scope")
|
||||
apply := flag.Bool("apply", false, "write derived search fields; requires prior authorization for production")
|
||||
timeout := flag.Duration("timeout", 30*time.Minute, "total operation deadline")
|
||||
flag.Parse()
|
||||
if (*collection != "" && *collection != "humanItems") || *database == "" || *org == "" || os.Getenv(*uriEnv) == "" || *timeout <= 0 {
|
||||
fmt.Fprintln(os.Stderr, "database, organization, URI environment variable and positive timeout are required; collection must be empty or humanItems")
|
||||
os.Exit(2)
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), *timeout)
|
||||
defer cancel()
|
||||
client, err := mongo.Connect(ctx, options.Client().ApplyURI(os.Getenv(*uriEnv)))
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "Mongo initialization failed")
|
||||
os.Exit(1)
|
||||
}
|
||||
defer client.Disconnect(context.Background())
|
||||
ds := store.NewMongoStore(client.Database(*database))
|
||||
ds.EnableQuerySourceTracking(os.Getenv("QUERY_SOURCE_TRACKING") == "1")
|
||||
var result store.PoolSearchBackfillResult
|
||||
if *collection == "humanItems" {
|
||||
result, err = ds.BackfillHumanPoolSearchMetadata(ctx, *org, *apply)
|
||||
} else {
|
||||
result, err = ds.BackfillPoolSearchMetadata(ctx, *org, *apply)
|
||||
}
|
||||
// Diagnostics contain counters only, never records or credential-bearing errors.
|
||||
_ = json.NewEncoder(os.Stdout).Encode(map[string]any{"apply": *apply, "counts": result, "complete": err == nil && result.Conflicts == 0 && result.Unsupported == 0 && (*apply || result.Scanned == 0)})
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "backfill failed; rerun after resolving the connection or timeout")
|
||||
os.Exit(1)
|
||||
}
|
||||
if result.Conflicts > 0 || result.Unsupported > 0 {
|
||||
os.Exit(2)
|
||||
}
|
||||
}
|
||||
148
cmd/query-cdc-probe/main.go
Normal file
148
cmd/query-cdc-probe/main.go
Normal file
@ -0,0 +1,148 @@
|
||||
// query-cdc-probe performs bounded metadata-only CDC capability checks.
|
||||
// It never writes records or returns customer fields, addresses or resume tokens.
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"flag"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
)
|
||||
|
||||
type result struct {
|
||||
At time.Time `json:"at"`
|
||||
ReplicaSet bool `json:"replicaSet"`
|
||||
Router bool `json:"router"`
|
||||
MaxWireVersion int `json:"maxWireVersion"`
|
||||
Sessions bool `json:"sessions"`
|
||||
Open bool `json:"streamOpen"`
|
||||
GetMore bool `json:"streamGetMore"`
|
||||
Resume bool `json:"streamResume"`
|
||||
Token bool `json:"resumeTokenObserved"`
|
||||
Failure string `json:"failure,omitempty"`
|
||||
}
|
||||
|
||||
func classification(err error) string {
|
||||
if err == nil {
|
||||
return ""
|
||||
}
|
||||
if errors.Is(err, context.DeadlineExceeded) {
|
||||
return "deadline"
|
||||
}
|
||||
var command mongo.CommandError
|
||||
if errors.As(err, &command) {
|
||||
switch command.Code {
|
||||
case 13, 18:
|
||||
return "authorization"
|
||||
case 40573:
|
||||
return "unsupported-topology"
|
||||
case 286, 280:
|
||||
return "resume-unavailable"
|
||||
}
|
||||
return "mongo-command"
|
||||
}
|
||||
return "connection-or-driver"
|
||||
}
|
||||
func closeStream(stream *mongo.ChangeStream) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
defer cancel()
|
||||
_ = stream.Close(ctx)
|
||||
}
|
||||
|
||||
func probe(ctx context.Context, db *mongo.Database) result {
|
||||
out := result{At: time.Now().UTC()}
|
||||
var hello struct {
|
||||
SetName string `bson:"setName"`
|
||||
Msg string `bson:"msg"`
|
||||
MaxWire int `bson:"maxWireVersion"`
|
||||
Session *int `bson:"logicalSessionTimeoutMinutes"`
|
||||
}
|
||||
if err := db.Client().Database("admin").RunCommand(ctx, bson.D{{Key: "hello", Value: 1}}).Decode(&hello); err != nil {
|
||||
out.Failure = classification(err)
|
||||
return out
|
||||
}
|
||||
out.ReplicaSet = hello.SetName != ""
|
||||
out.Router = hello.Msg == "isdbgrid"
|
||||
out.MaxWireVersion = hello.MaxWire
|
||||
out.Sessions = hello.Session != nil
|
||||
// Impossible operation type: capability check without exporting events.
|
||||
pipeline := mongo.Pipeline{{{Key: "$match", Value: bson.M{"operationType": "__metadata_only_cdc_probe__"}}}, {{Key: "$project", Value: bson.M{"_id": 1}}}}
|
||||
stream, err := db.Watch(ctx, pipeline, options.ChangeStream().SetMaxAwaitTime(250*time.Millisecond).SetBatchSize(1))
|
||||
if err != nil {
|
||||
out.Failure = classification(err)
|
||||
return out
|
||||
}
|
||||
out.Open = true
|
||||
stream.TryNext(ctx)
|
||||
if err = stream.Err(); err != nil {
|
||||
closeStream(stream)
|
||||
out.Failure = classification(err)
|
||||
return out
|
||||
}
|
||||
out.GetMore = true
|
||||
token := append(bson.Raw(nil), stream.ResumeToken()...)
|
||||
out.Token = len(token) > 0
|
||||
closeCtx, cancel := context.WithTimeout(context.Background(), time.Second)
|
||||
_ = stream.Close(closeCtx)
|
||||
cancel()
|
||||
if !out.Token {
|
||||
out.Failure = "resume-token-unavailable"
|
||||
return out
|
||||
}
|
||||
resumed, err := db.Watch(ctx, pipeline, options.ChangeStream().SetResumeAfter(token).SetMaxAwaitTime(250*time.Millisecond).SetBatchSize(1))
|
||||
if err != nil {
|
||||
out.Failure = classification(err)
|
||||
return out
|
||||
}
|
||||
resumed.TryNext(ctx)
|
||||
err = resumed.Err()
|
||||
closeCtx, cancel = context.WithTimeout(context.Background(), time.Second)
|
||||
_ = resumed.Close(closeCtx)
|
||||
cancel()
|
||||
if err != nil {
|
||||
out.Failure = classification(err)
|
||||
return out
|
||||
}
|
||||
out.Resume = true
|
||||
return out
|
||||
}
|
||||
func main() {
|
||||
allow := flag.Bool("production-readonly", false, "allow metadata-only checks using explicitly supplied company credentials")
|
||||
flag.Parse()
|
||||
uri, name := os.Getenv("MONGO_URI"), os.Getenv("MONGO_DB")
|
||||
out := result{At: time.Now().UTC()}
|
||||
if !*allow || uri == "" || name == "" {
|
||||
out.Failure = "explicit-readonly-configuration-required"
|
||||
_ = json.NewEncoder(os.Stdout).Encode(out)
|
||||
os.Exit(2)
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 12*time.Second)
|
||||
defer cancel()
|
||||
opts := options.Client().ApplyURI(uri).SetDirect(true).SetServerSelectionTimeout(5 * time.Second).SetConnectTimeout(4 * time.Second).SetMaxPoolSize(2)
|
||||
if host := os.Getenv("MONGO_TLS_SERVER_NAME"); host != "" {
|
||||
if opts.TLSConfig == nil {
|
||||
opts.TLSConfig = &tls.Config{MinVersion: tls.VersionTLS12}
|
||||
}
|
||||
opts.TLSConfig.ServerName = host
|
||||
}
|
||||
client, err := mongo.Connect(ctx, opts)
|
||||
if err != nil {
|
||||
out.Failure = classification(err)
|
||||
} else {
|
||||
out = probe(ctx, client.Database(name))
|
||||
closeCtx, stop := context.WithTimeout(context.Background(), time.Second)
|
||||
_ = client.Disconnect(closeCtx)
|
||||
stop()
|
||||
}
|
||||
_ = json.NewEncoder(os.Stdout).Encode(out)
|
||||
if !out.Resume {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
19
cmd/query-cdc-probe/main_test.go
Normal file
19
cmd/query-cdc-probe/main_test.go
Normal file
@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestClassificationNeverExportsConnectionOrCustomerText(t *testing.T) {
|
||||
for _, c := range []struct {
|
||||
e error
|
||||
want string
|
||||
}{{context.DeadlineExceeded, "deadline"}, {mongo.CommandError{Code: 40573, Message: "private-address secret"}, "unsupported-topology"}, {mongo.CommandError{Code: 13, Message: "secret"}, "authorization"}, {errors.New("mongodb://private-password@private-address/customer-body"), "connection-or-driver"}} {
|
||||
if got := classification(c.e); got != c.want {
|
||||
t.Fatal(got, c.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user