Refine school script diagnostics and document-state capture

This commit is contained in:
Codex
2026-10-15 15:15:42 +08:00
parent a4c2df838e
commit 83b0c7e177
16 changed files with 435 additions and 27 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
# Android 首版验证记录
当前浏览器兼容性修复版为0.7.1+19,验证见 [0.7.1记录](tpschedule-0.7.1-validation.md)。本科接入记录见 [0.7.0记录](tpschedule-0.7.0-validation.md)。下文为首版历史记录。
当前浏览器诊断细化版为0.7.2+20,验证见 [0.7.2记录](tpschedule-0.7.2-validation.md)。本科接入记录见 [0.7.0记录](tpschedule-0.7.0-validation.md)。下文为首版历史记录。
日期:2026-10-13。测试环境:Flutter 3.47.7 / Dart 3.13.5 / JDK 17;Android 16 API 36,Pixel 7 模拟器,1080×2400。首版版本 0.1.0+1,包 ID com.example.hepan_everyday,最低 Android 7.0(API 24)。
+3 -1
View File
@@ -1,4 +1,6 @@
# 学校接入状态 · TPSchedule 0.7.1
# 学校接入状态 · TPSchedule 0.7.2
0.7.1真机新日志确认本科认证成功,进入教务页面后有重复脚本错误。0.7.2细化现有日志,记录固定错误类型、已知基础库与样式状态及导出时间;尚未确定实际组件缺失的根因。详见 [0.7.2记录](tpschedule-0.7.2-validation.md)。
0.7.1补充学校浏览器宽视口、第三方Cookie和资源错误诊断,修复本科认证跳转导致读取永久中断的竞态。255项单元测试及Android16原生浏览器测试通过。用户截图中的样式与组件缺失尚需真机复测,不能仅凭测试认定已解决,详见 [0.7.1验证记录](tpschedule-0.7.1-validation.md)。
+48
View File
@@ -0,0 +1,48 @@
# 审查问题处理
Important已修复:两所学校页面完成回调传入代次与生命周期有效性检查,异步URL读取及脚本返回后复核;保持同URL并让代次失效的回归测试观察到RED→GREEN。Minor已修复:beangle=null不再判断为库已加载,现有Node脚本测试覆盖null值。未要求再次审查;完整测试、静态检查与原生验证由主实现者完成并记录。以下为修复前独立审查及当时处理计划。
# Browser diagnostics 0.7.2 review
Reviewed the uncommitted mobile changes against `a4c2df838efe01f39fb27cc6062544a476d86949`, including the new diagnostics implementation, Dart tests, JavaScript guard test, and Android fixture. No original user logs or key files were opened. This is a read-only source review; no full tests were repeated and no application source was changed.
## Strengths
- Console messages become fixed category labels. The snapshot decoder exports only bounded integer counts and explicitly selected booleans, discarding unknown fields.
- The JavaScript reads neither page text nor resource URLs, cookies, storage, forms, or HTML. Password-page and URL guards fail closed; inspection exceptions are swallowed.
- Diagnostic capture is launched independently of the login/import callback and changes no navigation policy, import parser, or school security settings.
- Export headers identify app version/build and the UTC export time. The fixture checks real WebView behavior while asserting private fixture text is absent from exported diagnostics.
## Issues
### Critical
None found.
### Important
1. **URL equality cannot reject a snapshot from a replaced document with the same URL.** `mobile/lib/features/school/school_browser_diagnostics.dart:110-118`; callback sites `mobile/lib/features/school/school_session.dart:112-114` and `mobile/lib/features/school/undergraduate/session.dart:142-144`.
Capture awaits both native URL reads and JavaScript execution. If a portal document reloads at the same URL while one of these operations is pending, all three URL comparisons still pass. In particular, JavaScript may return the old document's counts, `onPageStarted` can advance the session document generation, and the final `currentUrl()` can still equal the original URL. Those old counts are then appended after the new navigation. This violates the requested different-document guard and can make the diagnostic evidence misleading even though it does not change imported data.
Pass a captured document generation plus a current-generation predicate (or equivalent) into diagnostics, and recheck after awaits and immediately before recording. The session already maintains `_pageGeneration` / `_document`. Include lifecycle validity where relevant. Add a focused asynchronous test that holds the JavaScript result, advances the document generation while keeping the URL unchanged, then verifies that no events are recorded. Existing tests exercise a different URL but do not cover this case.
### Minor
1. **A null Beangle global is reported as a loaded library.** `mobile/lib/features/school/school_browser_diagnostics.dart:40`.
JavaScript reports `typeof null === 'object'`, so `window.beangle = null` produces `beangle: true`. Require a non-null value in addition to the object type and cover the null case in the JavaScript test. This is a small diagnostic accuracy issue, not a login failure.
## Declined to judge
- The cause and resolution of the authenticated portal's styling/script failure: real affected-page evidence is absent from this change, and this release only refines diagnostic evidence.
- Whether the queued complete Dart suite or native fixture passes: the coordinator is running them; this review makes no independent runtime success claim.
- Untracked output artifacts: excluded from application-source review and not opened because they could include original user material.
## Assessment
**Ready to merge: With fixes.** Privacy boundaries and isolation from login/import behavior are sound in the inspected code. Address the document-generation gap before claiming that snapshots reject replaced documents; do not describe this diagnostic refinement as a fix for the portal rendering problem.
## Coordinator disposition
The coordinator accepted the Important finding and plans to pass an `isCurrent` predicate from each native page-finished callback: graduate capture will use `_pageGeneration` and route/activity guards, and undergraduate capture will use `_generation`, `_document`, and `_valid`. The predicate will be checked around asynchronous native capture. A focused regression will keep the URL unchanged while invalidating the generation during a pending JavaScript result. This is the planned disposition, not an independently verified fix; no second review was requested.
+35
View File
@@ -0,0 +1,35 @@
# TPSchedule 0.7.2+20:教务页面脚本诊断细化
2026-10-15,工程F:/program/app。继续已获用户确认的学校WebView兼容性诊断,范围为细化现有日志,不切换内核、不改变学校认证及导入流程。
## 新证据与结论边界
本次读取用户Downloads中的0.7.1日志,时间为北京时间12:36–12:37。浏览器配置完成,第二次启动记录Chromium156.0.8078.4。身份认证返回本科系统后,school_evidence.authenticated=true;随后多次school_console_error.code=script_error。身份认证阶段有图片HTTPS404。没有证据把该图片404认定为教务页面整体缺少组件的原因,也没有证据认定手机缺少Chromium内核。
0.7.1把所有未分类控制台错误压成script_error,丢失了下一步定位所需的异常类型。因此本版修复的是诊断过粗,尚未修复已证实的登录后页面资源根因。
公开入口只读请求对Chrome和WebView两类UA都返回202及脚本页面。另用Android16原生WebView正常进入学校身份认证页,观察到样式表和jQuery存在。该临时观察没有使用账号、未登录、未读取课表;不能替代用户手机登录后的验证,也不能据此宣称防护页面导致此次故障。临时测试已移除,原始附件不进入仓库和源码包。
## 改动
- 控制台新增固定错误分类:jQuery、beangle、require未定义,及ReferenceError、SyntaxError、TypeError、SecurityError、EvalError、RangeError。只存固定类别,保留原有混合内容、CSP、跨域及资源拒绝分类;不存原始报错文字。
- 两所学校原生页面加载完成时,异步采集脚本标签数、样式表数量、样式链接数量及具备sheet对象的链接数。本科额外记录已知基础库是否存在;统计性能记录中脚本/链接响应202的数量。202本身不代表故障,计数仅供后续结合其他事件分析。
- 只读页面状态,不改变DOM、发起额外资源请求或注入学校业务功能;跳转或出现密码框时跳过。脚本不读取正文、表单内容、Cookie、存储或资源URL。返回值严格校验类型及上限,诊断失败不影响登录读取。
- 导出头部新增当前应用版本、构建号和UTC导出时间,便于分辨旧附件。最近10分钟及用户自选附带规则不变;服务端协议不变,无需为本版重新更新服务器。
## 验证
- 固定分类及受限返回值回归测试观察到缺能力时失败、实现后通过。完整Flutter套件258项通过,静态检查无问题。
- 新Node脚本测试验证实际脚本计数、基础库状态、重定向与密码框保护,并把Cookie、正文和资源URL设为读取即抛错,仍通过。
- Android16/API36原生测试1项通过,系统Chromium133.0.6943.137。原生控制台固定分类、实际页面状态脚本与解码及敏感夹具文本不外泄均验证;离线data页面不满足生产学校域名要求,脚本/解码在原生夹具验证,域名与文档代次保护由独立回归覆盖。
- 独立审查发现同URL重新加载时旧诊断可能混入,已用两所学校现有页面代次和生命周期回调校验修复,并观察到回归RED→GREEN;beangle=null误判也已修复。最终258项测试及静态检查均通过。审查及处理见tpschedule-0.7.2-review.md。
## 后续复测
本版为诊断细化版。仍需用户覆盖安装、复现登录后缺组件、立即新建反馈附带日志,依据错误细类和页面依赖状态判断下一步修复。不得把本版发布或测试通过表述为真实教务页面已恢复。
## 最终交付核对
发布与调试APK构建成功;应用包名com.tpschedule.app,versionName=0.7.2、versionCode=20。发布包60106575字节,SHA256:24564624C9A1A908BE6A1A19EBB8C47089AE6ADF20D80E03873992D7F885F9DC。提供带版本名的TPSchedule-0.7.2.apk与稳定名称TPSchedule.apk,两者字节一致。
与0.7.1签名证书逐字节相同;证书SHA256为AF5C21B1BA1E48E461D8EA38DF0FE1C3653F64EB7E8E7728BAE6E5D988BA0D0A。原私钥及登记冻结18项校验未变;0.7.1、0.7.0和0.6.2安装包备份保留。源码包由最终Git提交生成,不含私钥、运行缓存或原始学生附件。