22 Commits

Author SHA1 Message Date
ymq
7b7322dbfe fix(config): 恢复 i18n 链路 + session 时长 + 清 app/__init__.py
独立审查实测发现三个回归(均由 702f274 入口回归引起):

1【阻断】/i18n_getmsgs 500
   702f274 把 startswiths 的 i18n 条目换成了 /healthz,而 bricks 前端
   默认请求 /i18n_getmsgs(i18n.js:19)→ 500,界面文案/语言切换全受影响。
   实测 further:ahserver.globalEnv.i18n() 取 params_kw.lang,而前端传
   language → startswiths 映射本身就不可能工作。
   修复:wwwroot 放标准资源 i18n_getmsgs.dspy(按 language 读
   wwwroot/i18n/<lang>/i18n.json),startswiths 只保留 /healthz。

2【重要】会话时长回落到框架默认 120 秒
   702f274 把 config 写成 ahserver 不认识的 website.session{timeout,...},
   而 ahserver/auth_api.py 读的是 website.session_max_time(默认 120)。
   实测:登录后空闲 135s 再请求 → 401。原配置 28800s。
   修复:补回 session_max_time=28800、session_reissue_time=7200。

3【重要】app/__init__.py 仍 import 5 个已归档中间件
   每次启动 5 条 warning,且 __all__ 宣称导出的符号实测 ImportError。
   修复:清空为纯包标记;顺带移除死配置 http_semantics(新入口无
   ahapp_built 钩子,该块不会被读,且本身是已删中间件的开关)。

实测(重启后):
  /i18n_getmsgs?language=zh 200 | /healthz 200 | /index.ui 200 | login.ui 200
  空口令登录被拒(业务错误信封)| admin123 登录 200 + cookie
  带 cookie 访问受保护端点 200 | 匿名 401
2026-10-28 17:06:25 +08:00
ymq
747a808b48 fix(entry): 恢复 ns_wiring 接线——只读基础模块 handler 补齐
上一条 commit 702f274 归档 24 个自造中间件时,连带把 ns_wiring.py
一并归档,导致 rbac/appbase 的 dspy 端点报
TypeError: 'NoneType' object is not callable(模块函数未注入命名空间)。

ns_wiring 不属于鉴权中间件,它是「业务模块 dispatch + 只读基础模块
handler 补齐」接线:只在运行时 setattr env.<handler>,不装配 aiohttp
中间件、不改基础模块源码,因此恢复。

实测(184 个 dspy 语法扫描 + 端点扫描):
  恢复前:19 个端点 500(list_path_roles / get_code / find_unauth_files 等)
  恢复后:仅剩「无参 GET 调写端点」的假阳性,只读端点全部正常

ns_wiring.py 从 app/_archive_disabled_20261028_151505/ 原样恢复,未改动。
2026-10-28 16:39:56 +08:00
ymq
0cfeb45a3c fix(dspy): 修复 5 个 dspy 的 await-outside-async 语法错误 + 归档死文件
背景:移除 24 个自造鉴权中间件后(上一条 commit 702f274),原本被中间件
提前拦截的请求真正走到 dspy 执行层,暴露出存量语法错误——这些端点此前
一律被中间件返回 401/405,从未真正执行过。

根因:agent 往 dspy 头部注入 ns-shim 段时,把含 await 的辅助函数
(_auth_resolve_uid / _ns_export)写成同步 def,而 ahserver 的
PythonScriptProcessor 只把整个文件包进 async myfunc,函数体内的 await
成为编译期 SyntaxError。

修复(5 个文件,模式一致:同步 def -> async def + 调用点加 await):
  - runtime/api/runtime_status.dspy   (_auth_resolve_uid, _ns_export)
  - runtime/api/build_entity_tree.dspy (同上)
  - scense/api/list_scense.dspy        (同上)
  - scene/api/get_search_scene_type.dspy (同上)
  - scene/api/get_search_status.dspy     (同上)

另归档 _archive_dead_dspy/add_reseller.dspy:该文件未跟踪、非 rbac 自带
(宿主 rbac 无此文件),且依赖 rbac 中不存在的 openCustomerAccounts,
纯属自造死文件,保留只会持续 500。

验证:
  - 全量扫描 184 个 dspy(按 ahserver 包装方式 compile):语法错误 0
  - 带 cookie 实测 6 个端点全部 200:healthz / runtime_status /
    build_entity_tree / list_scense / get_search_status / get_search_scene_type
  - login 200 + cookie、匿名 401 保持正常
2026-10-28 15:45:30 +08:00
ymq
702f27407b refactor(auth): 移除全部自造鉴权/会话/语义中间件,回归标准 ahserver+rbac
根因:元景迭代中为通过 QC 门禁反复叠加了 24 个自定义中间件
(auth_gate_strict / session_gate / login_param_source / route_guard /
 entry_semantics / http_semantics / notfound / get_only_405 / ...),
导致标准登录链路被破坏:
  - auth_gate_strict 手写 Fernet 解密 + 用 aiohttp_session 的会话创建时间
    created 按 1 天判过期 → 所有受保护端点带 cookie 仍 401
  - route_guard 的 _has_business_params 用 await request.read() 消费 POST body
    → up_login 收到 params_kw={} → password_encode(None) 崩 500

改动:
  - app/scense.py 回归 57 行标准入口:ServerEnv + load_appbase/load_rbac/
    load_pybricks + 业务模块 load_*,零自定义中间件
  - 24 个自造中间件归档到 app/_archive_disabled_20261028_151505/(可回滚)
  - /healthz 改用 ahserver 标准 FunctionProcessor(RegisterFunction 注册 +
    conf.website.startswiths 映射),不再用中间件拦截

实测闭环(127.0.0.1:9380 + https://gbak.opencomputing.cn):
  healthz 200 | 匿名 401 | admin 登录 200+cookie | 带cookie 200 |
  伪造cookie 401 | 注册 200+自动登录 | 新用户登录 200+cookie |
  新用户访问 403(已认证无权限,RBAC 正确行为)| 登出 200 |
  错误密码 200 业务信封(不崩 500)

register/login/logout/session 全部由 rbac 模块 up_login.dspy /
register.dspy / logout.dspy + ahserver session 中间件提供。
2026-10-28 15:19:43 +08:00
agent.develop
aaba05a100 feat: 侧边栏收敛两大入口——创建游戏/展示+Play,模块菜单收进hub 2026-08-30 21:32:32 +08:00
pipeline-agent
561cdc8eb8 feat: 主菜单游戏工作台指向bricks原生workbench.ui 2026-08-30 20:02:58 +08:00
pipeline-agent
e69ef4fde1 feat: 主菜单加游戏工作台入口 2026-08-30 14:16:11 +08:00
pipeline-agent
075de0c0eb fix: 菜单script单引号被shell吞掉导致AsyncFunction语法错——补回引号 2026-08-30 09:29:26 +08:00
pipeline-agent
4404b88467 feat: 主菜单加4新模块入口(实时演示/游戏展示/拖拽编程/运行时) 2026-08-30 09:18:05 +08:00
pipeline-agent
08a1b7ba6a fix: config kwargs 键 database→db(aiomysql.connect 只认 db) 2026-08-30 08:35:50 +08:00
pipeline-agent
12158558dd fix(deploy): 无models/纯引擎模块跳过建表,无json/跳过CRUD生成(scense_runtime部署修复) 2026-08-30 08:26:28 +08:00
pipeline-agent
449f1e607e security: config.json 凭据改占位符(真实凭据只在部署机 .env) 2026-08-29 23:15:38 +08:00
pipeline-agent
455f86d440 feat: 集成4新模块——build.sh 模块清单、config modules、app入口挂载4个load_*、恢复一键部署build.sh、index.ui真实widget 2026-08-29 23:13:49 +08:00
pipeline-agent
87ca62ea9f refactor: game 模块拆分至独立仓库 scense_game 2026-08-29 21:22:13 +08:00
agent.develop
f337333432 approve: 元景 W-08 游戏展示模块开发 2026-08-29 17:38:48 +08:00
agent.develop
873a83ab44 approve: world_sync 模块开发(W-05 同步管理) 2026-08-29 16:35:05 +08:00
agent.develop
de31d36a87 approve: entity 模块开发(W-03 实体管理) 2026-08-29 16:15:32 +08:00
agent.develop
e46bc16173 fix(scense): 修复元景初始迭代 4 个部署/访问 Bug - ahserver 规范入口、config processors/indexes、build.sh 端口门禁、fix_scense_access 重启兜底、init_admin_user RBAC 幂等初始化 2026-08-29 09:49:11 +08:00
agent.develop
4b183aa7fc fix: bricks dist mkdir+产物校验;种子脚本(机构/角色/权限/超管);rbac/appbase软链;config database→db 2026-08-28 17:01:01 +08:00
agent.develop
604cffd897 fix(build): export venv/bin to PATH so json/build.sh can find xls2ui 2026-08-28 16:20:43 +08:00
agent.develop
8057ba2888 feat: build.sh 按 webapp-deploy 技能重写一键部署(venv+clone全模块+四步安装+/healthz门禁);加 start/stop;/healthz钩子;密码加密 2026-08-28 16:15:37 +08:00
agent.develop
93dadab835 feat(scense): scense 初始化提交(元景项目-初始迭代,开发产线产出) 2026-08-28 13:34:54 +08:00