feat(followup-audio): review full dialogue and bind roles before extraction

This commit is contained in:
2026-10-10 14:25:03 +08:00
parent f015b26ae1
commit b4acad8510
14 changed files with 360 additions and 43 deletions
@@ -34,6 +34,11 @@ final class FollowupAudioPipelineCheckpoint
$state = ['schema_version' => $version, 'revision' => 0, 'source_sha256' => $task['sha256'], 'fingerprint' => $fingerprint,
'duration_ms' => $duration, 'chunk_ms' => $chunkMs, 'chunks' => $chunks, 'extraction' => ['state' => 'pending']];
if ($version === 2) { $state += ['source_channels' => $sourceChannels, 'channel_policy' => self::CHANNEL_POLICY, 'silence_policy' => FollowupAudioPipelineMedia::SILENCE_POLICY]; }
// Only new role-bound tasks carry this field. Historical checkpoints retain their exact shape.
$ids = json_decode((string) ($task['upstream_ids_json'] ?? '{}'), true);
if ($version === 2 && is_array($ids) && array_key_exists('channel_roles', $ids)) {
$state['extraction_channel_roles'] = FollowupAudioStore::taskChannelRoles($task);
}
return $state;
}
@@ -48,7 +53,7 @@ final class FollowupAudioPipelineCheckpoint
$version = $state['schema_version'] ?? 0;
if (!in_array($version, [1, 2], true) || ($version === 2 && !is_int($state['source_channels'] ?? null))) { self::invalid(); }
$expected = self::plan($task, $state['fingerprint'], $state['chunk_ms'], $version === 2 ? $state['source_channels'] : 1, $version);
foreach (['schema_version', 'source_sha256', 'fingerprint', 'duration_ms', 'chunk_ms', 'source_channels', 'channel_policy', 'silence_policy'] as $field) {
foreach (['schema_version', 'source_sha256', 'fingerprint', 'duration_ms', 'chunk_ms', 'source_channels', 'channel_policy', 'silence_policy', 'extraction_channel_roles'] as $field) {
if (($state[$field] ?? null) !== ($expected[$field] ?? null)) { self::invalid(); }
}
if (array_diff(array_keys($state), array_keys($expected)) || !is_array($state['chunks'] ?? null)
@@ -113,7 +118,7 @@ final class FollowupAudioPipelineCheckpoint
if ($expectedRevision !== $previous['revision'] || $next['revision'] !== $previous['revision'] + 1) {
throw new FollowupAudioException('PIPELINE_CHECKPOINT_CONFLICT');
}
foreach (['schema_version', 'source_sha256', 'fingerprint', 'duration_ms', 'chunk_ms', 'source_channels', 'channel_policy', 'silence_policy'] as $key) {
foreach (['schema_version', 'source_sha256', 'fingerprint', 'duration_ms', 'chunk_ms', 'source_channels', 'channel_policy', 'silence_policy', 'extraction_channel_roles'] as $key) {
if (($next[$key] ?? null) !== ($previous[$key] ?? null)) { self::invalid(); }
}
$changed = 0;