Repository navigation
fix(tests): align browser fixture backend origins - #6456
Conversation
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent; gpt-6.1-sol; OpenAI; runtime_reported; reasoning_effort=xhigh
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
Reviewed head: 321d186229fdfd2daaa82444604c7e0c8d3583f7. 共用作者账号的独立评审只能记为 COMMENTED,不冒充 GitHub 正式自批准。
动机
维护 App 浏览器回归测试的开发者,无法通过原转发方式走到真实配置 owner。 页面和临时后端使用不同端口时,旧转发让 Host 指向后端、Origin 仍指向页面,保存请求先收到 403;新方式同时重定位同源的 Host/Origin,使原场景能进入真实业务校验。 真实打包页面的保存从 403 恢复为一次成功 apply 并读回策略文件;三个配置路径的 HTTP 对照通过,外来 Origin 仍收到真实 403。 本 PR 只修复测试转发边界,不改变生产 CORS 或配置授权,也不声明安装态 App、全部三套 browser scenario 或整体 CI 已由本次独立验证关闭。
改动思路
保留真实生产 Host/Origin guard,仅修正测试运输层。fetchWorkspaceBackend 在既有 scenario-context 内组成目标 URL,保留 pathname 和 query,设置后端 Host;只有原请求 Origin 恰好等于原 URL origin 时才重定位 Origin。外来值不改,仍交给真实 guard 拒绝。route.fetch 只覆盖 URL/headers,原方法和 body 继续由原请求提供。继续放宽生产 CORS 会掩盖缺陷;在三处复制不同头部修正也容易漂移,一个 13 行近邻 helper 更适合。
具体改动
完整 diff 四个 example 路径,增加 28 行、删除 7 行,没有生产文件。automation-cadence、configuration-backup、explore-composition-owner 三个回调统一使用该 helper。backup 原路径丢弃 query 的分支也改为完整保留 query。cadence 在 UI 场景前增加通过同一个 helper 的真实 foreign-Origin POST403 断言,原 duplicate-submit/CAS、backup 损坏恢复和 Explore 不安全 scope/stale preview 的业务断言均未移除。
依据是变更前 docs/development/frontend-delivery.md,固定版本 f43732cd7deaefe574d39b8449e9d5fc2ee41543,Walk the actual product implemented:fixture 不得 mock 掉被声称的 owning backend。本次 probe 真正使用 ChatRequestHandler 与 typed policy 文件,周边工作区目录/Chat 返回仍明确为合成 fixture;公开说明与证据没有把截图当持久化证明。
对主干的风险
我首先挑战“测试只是通过改头绕过 guard”。三个真实 API 的对照覆盖 cadence 带 query 读取、backup JSON POST 导出、Goal configuration 带 query 读取:旧 URL override 的 Host/Origin 效果收到403,当前 helper 均进入 owner并返回200;外来 https Origin 和字面 null 在两侧各被拒绝,共4次403。这里给 GET 人工添加 Origin 是运输层输入覆盖,实际浏览器的回归发生在 POST,不声称普通 GET 会自动携带 Origin。
再用正常构建页面和 Ego 浏览器执行现有 cadence Save:旧转发的真实 POST 在页面显示403;恢复新 helper、刷新后,同一 Save 成功,双 submit 只产生一个 apply,独立 HTTP 与实际 typed-store 文件都读回60分钟/revision1。负数间隔继续显示原校验并禁用保存。生产 CORS 70项通过,四个 JS syntax检查、正常 Chat build/TS、semantic advisory及完整漂移检查通过;native premerge为3direct、6selected/executed,零失败/hold,四路径与公开评审文本扫描通过。
独立评审没有运行作者那三套完整 Playwright脚本,也没有用此局部测试宣称安装态或整体CI通过;改变的边界由真实 helper/HTTP及一条真实打包 UI 保存路径验证,业务断言保留情况从全diff核对。初次自建proxy忘了fixture固定端口及等待过早的错误已修正,属于验证 harness,不归因到产品。未查询、轮询或等待 GitHub CI。
我的整体评价
APPROVE。long_horizon improved:重复资格验证能进入真实owner而不改变信任边界;user_experience improved:开发者的反馈更准确,生产 UI、用户步骤及授权不变。现有coverage和最近60个同账号PR的有界去重没有显示重复 smoke,本次集中原有测试运输并保护真实拒绝,具备持久价值。兼容评估无生产格式迁移,future-facing 整理已落在现有context helper,无需通用新框架。批准不授合并权限。
English verdict: APPROVE - 321d186; real packaged Save recovers from legacy Origin403 with one typed-store write, all three forwarding paths reach their owners, foreign origins remain403;70CORS and3direct+6selected native checks passed. Full original browser scenarios and installed adoption are not claimed.
Browser fixtures forward requests from the UI port to a disposable real backend. The forwarded Host and browser Origin described different origins, so Chat returned 403 before the cadence, backup and Explore assertions could exercise their owners. These failures also reproduced on the base of #6441.
Use the existing scenario context to rebase Host and same-origin Origin together, preserving the API path, query and original request. Foreign origins stay untrusted; the cadence scenario now checks a real 403 through the forwarding helper. The three scenarios retain their existing business and refusal assertions.
Validation: the three complete packaged browser scenarios pass, including duplicate-submit/CAS, damaged-backup recovery and unsafe-scope/stale-preview checks; all 70 existing Chat CORS tests pass. Chat assets build, the four JavaScript syntax checks, diff whitespace check and public-boundary scan pass. Full GitHub CI remains incomplete; the separate pinned-consumer baseline failure is not changed by this PR.
CI follow-through at merge commit
7f0085324fa8e1d63d1c8b5f9596fdb5ccb9021f: the three repaired scenarios completed in their remote shards. The dashboard shards now stop inreplan-cadence,pr-review-agent-order, andattention-user-action. Six fresh packaged runs against exact head321d186and basef43732c, with separately built source bundles and identical locked dependencies, reproduce each of these failures on both versions. The logs and remaining fixture routes expose the same Host/Origin forwarding issue in other scenarios; those assertions are retained for the next scoped repair. Local qualification used macOS, not the Ubuntu CI environment.The TypeScript failure is the existing pinned-consumer expectation missing
control_plane/goals/direction_authority.ts, not a missing source file. All 322 TypeScript source modules and the pinned-set test match the previously qualified failing source across the old base, current base and this head. This PR does not repair or waive that failure, and the full CI run is not reported as passing.