更新
This commit is contained in:
@@ -62,6 +62,28 @@ timingExpect(!isset($one->event('upstream_done', ['error_code' => 'API_KEY_SECRE
|
||||
|
||||
$startedAt = hrtime(true);
|
||||
timingExpect(AssistantSseTiming::elapsedMs($startedAt) >= 0, 'monotonic elapsed time is non-negative');
|
||||
timingExpect(isset($first['request_elapsed_ms']) && is_int($first['request_elapsed_ms']), 'request timing includes the phase before SSE');
|
||||
timingExpect($one->event('first_delta')['request_elapsed_ms'] >= $first['request_elapsed_ms'], 'full request time remains monotonic across preparation and first text');
|
||||
timingExpect($one->event('prepare', ['compaction_cache_hit' => true])['compaction_cache_hit'] === true, 'cache hit is safe boolean telemetry');
|
||||
|
||||
// Exercise a buffered web-style channel: timing must reach disk before HTTP end/exit.
|
||||
$app = new \think\App(dirname(__DIR__) . '/');
|
||||
$directory = sys_get_temp_dir() . '/zyt-ai-timing-' . bin2hex(random_bytes(8));
|
||||
$app->config->set(['default' => 'timing', 'channels' => ['timing' => [
|
||||
'type' => 'File', 'path' => $directory, 'single' => 'timing', 'realtime_write' => false,
|
||||
]]], 'log');
|
||||
$logger = $app->make('log');
|
||||
$channel = $logger->channel('timing');
|
||||
(new ReflectionProperty(\think\log\Channel::class, 'lazy'))->setValue($channel, true);
|
||||
$logger->info('buffered control');
|
||||
$logFile = $directory . '/timing.log';
|
||||
timingExpect(!is_file($logFile), 'control channel really buffers before the SSE timing write');
|
||||
$one->log('first_delta', ['duration_ms' => 123, 'api_key' => 'must-not-be-logged']);
|
||||
timingExpect(is_file($logFile), 'SSE timing persists immediately without HTTP-end save');
|
||||
$logged = file_get_contents($logFile);
|
||||
timingExpect(str_contains($logged, $one->id()) && !str_contains($logged, 'must-not-be-logged'), 'persisted timing remains patient and credential free');
|
||||
unlink($logFile);
|
||||
rmdir($directory);
|
||||
|
||||
$controller = file_get_contents(dirname(__DIR__) . '/app/adminapi/controller/tcm/DiagnosisController.php');
|
||||
$logic = file_get_contents(dirname(__DIR__) . '/app/adminapi/logic/tcm/DiagnosisAiLogic.php');
|
||||
|
||||
Reference in New Issue
Block a user