Skip to content

perf: add S07 capacity harness with cache and telemetry fixes - #343

Merged
voidvec merged 4 commits into
masterfrom
perf/capacity-evidence-s07
Nov 18, 2026
Merged

voidvec merged 4 commits into
masterfrom
perf/capacity-evidence-s07

Conversation

@voidvec

@voidvec voidvec commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

The capacity driver needs isolated OAuth sessions, recoverable setup, owned cleanup and verifiable evidence before any formal campaign can be admitted. This change adds the S07 harness and fixes the cache/telemetry prerequisites exposed by real functional runs.

Changes

  • Add isolated PKCE/consent and single-use refresh workloads, pilot-bound resource admission, the 108-row protocol, soak/fault controls and complete failure/tail retention.
  • Reap owned workers before releasing fixture leases, recover committed ownership transfers without replaying writes, retain every server exit, and reject corrupt, incomplete, mismatched or reused artifacts while retaining every CSV row.
  • Rebuild idle driver keep-alive connections before sending; do not replay credential/grant requests to manufacture success.
  • When the Redis cache-fill guard skips a future-nbf token, return the fresh authoritative introspection result instead of incorrectly returning inactive.
  • Export IMetrics counters/gauges through PromExporter so fulla_cache_total can prove the cache path. Histograms retain their existing log-only behavior.

The final diff includes the two product fixes above; earlier descriptions of a tooling-only change are superseded. Schema, dependency lock, generated clients and OpenAPI are unchanged.

Validation

Reviewed head: c893593c52071330dbaae4d53f38c84413d6561d, based directly on master ba76f64b (including #339).

  • Capacity Harness Checks: 61 tests passed, no skips.
  • Main CI, Optional Feature Matrix, Sanitizers, Coverage, Security and Website workflows all completed successfully on this head.
  • Both product fixes include red/green regressions. The recorded fresh 18-row functional smoke passed with collected telemetry, valid artifact seals and proven tuned cache paths; it is not a formal capacity result.
  • SDK generator inputs/committed outputs match the previously verified b661019 tree; the path-filtered client workflow is separate from SDK consumer smoke.

Remaining limits and review follow-up

No accepted current-product capacity baseline, formal matrix, long soak or fault sign-off is published. A new matching pilot/budget and sufficient persistent storage remain required. Historical raw evidence stays private and unchanged. Abnormal shutdown outcomes remain separately recorded under the #300 exclusion.

The nonblocking P2 request-counter review is tracked in #355: legacy oauth2_requests_total callers pass HTTP status as the increment and omit its status label, so request-rate queries are inaccurate after export. That follow-up must increment once per request with consistent status labels. The S07 harness does not consume this counter; its request statistics come from retained events and its cache proof uses fulla_cache_total. The review thread remains visible; this is not claimed fixed here.

Approved for the user-requested rebase merge after current-head checks and external approval. No deployment or capacity acceptance is implied.

@voidvec

voidvec commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner Author

必须处理项

评审基于 9481d4d89326312e140a62e81a6ca83cfb9453f3。以下问题针对工具自身的隔离和证据可信度,不要求本 PR 完成正式容量验收、修复 #300 或提前合入 #344/#345。

1. [P1] 父进程中断时应先终止并回收负载子进程,再释放 fixture

位置:session.py:299–310、外层清理:467–496。

内层只处理 TimeoutExpired,但 finally 无条件清空 current_child。如果仅父进程收到 SIGINT,wait() 抛出 KeyboardInterrupt,负载子进程不会被通知或回收,外层却继续停止服务并释放 fixture 锁。残留负载可能继续访问同一端口,干扰下一次实验。

验证: 从实际源码提取该 try/finally,用 Mock 子进程令 wait() 抛出 KeyboardInterrupt;确认句柄已清空,send_signal 和 kill 均未调用。没有启动实际子进程或负载。

修复/验收: 在包括中断在内的退出路径中,先通知自有子进程退出、限时等待,必要时 kill 并 reap,确认结束后再清空句柄和释放租约;补充“只中断父进程”的回归测试。

2. [P2] 应用转移提交后确认丢失,初始化重试会永久卡在重复转移

位置:fixture.py:469–489。

org_client 在转移前已保存,org_ready 只在成功响应后保存。如果服务端已提交转移但响应丢失,或随后保存失败,下次初始化会再次无条件 POST transfer。现有 ApplicationService.cc:1629–1633 拒绝已属于组织的应用,导致同一 fixture 无法继续初始化。

修复/验收: 重入时查询并核实当前应用归属;已经属于目标组织时补存完成状态,否则再转移。模拟“服务端成功提交、客户端未记录成功”后重跑,应恢复成功;不要简单忽略所有转移错误。

3. [P2] 故障流程必须落盘保存各服务器实例的退出事件

位置:faults.py:177、223–230、317–348。

Server.stop() 已记录退出码等 shutdown_events,但 restart 故障直接替换旧 Server 对象,丢掉第一次停止的事件;最终停止也没有把这些事件写入 fault 的结果文件。故障结果仍可能为 passed,结构化证据却无法区分正常退出、崩溃或强制终止。这与“异常停止单独保留”的边界不符。

修复/验收: 替换实例前及最终清理后,将带实例标识的完整退出事件写入结果;为非零退出码和强制终止补充断言。保留 #300 排除说明即可,不要求把异常停止直接认定为容量失败。

除第 1 项的无副作用 Mock 复现外,其余为源码及实际 API 契约核对;未执行压测、故障注入或共享服务操作。

4. [P2] 预算授权和矩阵导出必须验证原始证据,不能只相信摘要或文件大小

位置:budget.py:55–75、report.py:39–52。

forecast() 对 pilot 只汇总现存文件大小,不要求原始请求/遥测文件存在;复制遗漏这些文件时仍可授权,且预测空间反而下降。valid_steady_result() 则只检查 gzip 非空、请求 gzip 大小匹配摘要,遥测 gzip 不解压也不核对样本数;截断或损坏的数据仍可能被认定完整。

验证: 使用源码函数和临时合成文件,18 行 pilot 仅保留摘要 JSON、完全没有原始 gzip,仍返回 status=passed;非 gzip 字节作为请求/遥测文件也可通过当前完整性检查。未运行真实负载。

修复/验收: 授权及导出前检查必需产物,验证 gzip 完整性以及事件/样本数与摘要一致性,或校验生成阶段记录的内容摘要;覆盖缺文件、截断、同尺寸损坏。导出仍应保留失败行,但不能标记完整或允许缺证据 pilot 授权。

5. [P2] 不同轮次必须绑定不同测量,不能复用同一个 result

位置:report.py:30–31、169–176。

结果与 manifest 仅核对 profile/scenario/VU,不检查轮次或测量身份;最终 108 行集合检查只看 manifest。三个不同 round 的行引用同一个 result_path,仍可通过。因此每个组合只做一次、总计 36 份结果,就可能被当成完整的三轮 108 行矩阵。

验证: 用源码 export() 构造上述 36 文件/108 manifest 行结构,确认返回 complete_steady_matrix=true。

修复/验收: 拒绝重复的规范化结果路径和重复 run_id;将 round/测量身份写入结果并与 manifest 校验。增加重复路径、不同路径复制同一测量结果的拒绝测试,同时保留正常 108 次独立测量的通过用例。

@voidvec

voidvec commented Nov 17, 2026

Copy link
Copy Markdown
Owner Author

建议处理项

评审基于 9481d4d89326312e140a62e81a6ca83cfb9453f3。

暂无需要单独列出的非阻断建议;本轮确认的生命周期、初始化恢复和证据完整性问题均已列入另一条“必须处理项”评论,不重复降级为建议。

范围说明:已覆盖新增容量工具、配套行为测试与功能 CI;当前 Driver behavior 及三平台 CI 为成功。该结果不代表完整矩阵、soak 或 fault 的容量验收。PR 已明确声明的 #344/#345 前置依赖、空间不足及 #300 排除范围未作为新增缺陷。验证仅包含源码审查、现有 CI 状态及无副作用的本地 Mock/合成产物复现,没有执行压测或故障注入。

@voidvec
voidvec force-pushed the perf/capacity-evidence-s07 branch from 9481d4d to b661019 Compare November 17, 2026 14:27
wangrh0909
wangrh0909 previously approved these changes Nov 18, 2026
@wangrh0909
wangrh0909 force-pushed the perf/capacity-evidence-s07 branch from b661019 to 77ba5c4 Compare November 18, 2026 04:02
wangrh0909 pushed a commit that referenced this pull request Nov 18, 2026
Register the cache counter in the four official profiles, keep export failures separate from legacy INFO logging, and bound labels and values. Preserve optional exporter behavior and pre-start adapter safety; clarify the log-only legacy metric events and custom collector configuration.

Refs #343
Retain isolated OAuth flows, tails and owned fixture controls without
claiming accepted current-product capacity or running load in shared CI.

Reap owned workers before lease release, recover committed transfers,
and persist each server instance's shutdown evidence. Seal and replay
raw gzip artifacts; bind every row to source/build/fixture provenance
and independent measurement identity before admission or matrix export.
Reject missing, corrupt, aliased or reused evidence while retaining CSV
rows. Cover tool behavior with 56 standard-library regression tests.
…07 driver

The fixture server closes connections idle for 60s (idle_connection_timeout
is never overridden by the harness), but Session reused one connection
forever with no pre-send liveness management. Under production pacing the
observer's 60s cadence and VU quota gaps landed on server-closed sockets,
so a formal soak would accumulate transport failures and abort after the
full two-hour window. Rebuild a connection idle for more than 45s before
sending, and retain idle_reconnects counts in result.json (VU aggregate and
observer sessions). No retry, no sleep, no change to the measured system;
reconnects emit no admission events, keeping the 1:1 accounting intact.

Also clear four review leftovers:
- guard Sampler metrics-thread cleanup so it cannot mask an init failure
- label telemetry_status collected only when the observer actually started,
  and seal artifacts under the same condition
- route the observer discovery control session through the shared pacer
- drop the unreachable fault kind from run.py validation (faults run via
  faults.py, never through run.py argparse)

Regression tests cover idle rebuild vs hot reuse, evidence retention, the
early-failure telemetry label, and paced observer sessions; a timed
simulation of the server idle-close cadence passes 8/8 with 7 reconnects.
Full capacity suite: 61 tests OK.
…skips fill

The guarded-fill path in introspectToken finished inactive() when the
fresh snapshot carried a future nbf, while the authoritative Postgres
introspect enforces only revoked/expired. With the cache enabled, a
valid token could therefore introspect as inactive whenever the
issuance-time clock reading ran ahead of a later reading (observed in
the S07 tuned smoke: cold-start client_credentials + introspect failed
roughly half the trials; warm trials never failed).

Skip the fill and serve the authoritative result instead; the
not-yet-cacheable snapshot is simply not cached. Add an integration
regression test (future-nbf token, warmed access cache) asserting
active verdicts on both calls, impl consulted twice, and no
introspection-key fill. Verified red on the pre-fix line (2 failed
assertions) and green after the fix (27 assertions).
DrogonMetrics was a log-only stopgap: the "[METRIC]" INFO line never
reached drogon::plugin::PromExporter, so /metrics did not expose the
counters documented in docs/domains/token-refresh-and-revocation.md
(fulla_cache_total{repo="token",outcome=...}). The S07 capacity
harness's cache-proof gate scrapes exactly that family; row
013-introspect_reuse reported cache_path_not_proven despite 100% flow
success because the family never existed on the endpoint.

Register Counter/Gauge collectors lazily with the PromExporter plugin
(sorted label order, duplicate-registration safe across adapter
instances, log-only fallback when the plugin is absent). Histograms
stay log-only: drogon's Histogram requires explicit bucket boundaries
and owns an event-loop thread per metric, and no production call site
observes histograms through this port yet. The legacy [METRIC] log
line is retained for log-scraping consumers. Ratify the additive
api-diff baseline drift (private members only).

Add Integration_P2_Plugin_DrogonMetrics_PromExporterExport: counter
values per label set, gauge set semantics, cross-instance collector
reuse, and the /metrics exposition the driver filters on. Verified red
on the log-only implementation (collector absent) and green after the
wiring (12 assertions).
@wangrh0909
wangrh0909 force-pushed the perf/capacity-evidence-s07 branch from a7b022c to c893593 Compare November 18, 2026 09:41
@wangrh0909
wangrh0909 marked this pull request as ready for review November 18, 2026 09:41
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T09:44:15.845556Z c893593 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c893593c52

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

if (auto typed =
std::dynamic_pointer_cast<dm::Collector<dm::Counter>>(collector))
{
typed->metric(labelValues(labels, names))->increment(value);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve request counts when exporting counters

When the PromExporter plugin is enabled, this now exposes oauth2_requests_total with inflated values: existing callers pass the HTTP status as value (for example, TokenEndpointController.cc:1130-1134 passes 200, while AuthorizationEndpointController.cc:139-143 passes 400), so each request increments the counter by 200–500 rather than one. Those callers also provide only the endpoint label, omitting the documented status dimension, which makes production QPS/error-rate queries incorrect. Update these emissions to increment by one and carry the status as a label before exporting them as Prometheus counters.

Useful? React with 👍 / 👎.

@voidvec voidvec changed the title test(benchmarks): add gated capacity evidence harness (S07 tooling) perf: add S07 capacity harness with cache and telemetry fixes Nov 18, 2026
@voidvec
voidvec merged commit 55b9533 into master Nov 18, 2026
19 checks passed
@voidvec
voidvec deleted the perf/capacity-evidence-s07 branch November 18, 2026 12:07
voidvec added a commit that referenced this pull request Nov 19, 2026
Register the cache counter in the four official profiles, keep export failures separate from legacy INFO logging, and bound labels and values. Preserve optional exporter behavior and pre-start adapter safety; clarify the log-only legacy metric events and custom collector configuration.

Refs #343
voidvec added a commit that referenced this pull request Nov 19, 2026
#345)

Register the cache counter in the four official profiles, keep export failures separate from legacy INFO logging, and bound labels and values. Preserve optional exporter behavior and pre-start adapter safety; clarify the log-only legacy metric events and custom collector configuration.

Refs #343
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants