Skip to content

Commit 2541ecc

Browse files
authored
Merge pull request #290 from Fr-e-d/contrib/sync-1777600001
sync: update 6 file(s) in core/
2 parents dd597f2 + 74c748c commit 2541ecc

6 files changed

Lines changed: 1166 additions & 18 deletions

File tree

.gaai/core/adapters/claude-code/runtime-routing-logger.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ export function logPhase(params) {
100100
};
101101

102102
// Append optional secondary-mode telemetry fields when present (integers/boolean, DEC-65)
103-
const TELEMETRY_FIELDS = ['context_size_at_spawn', 'compact_events_count', 'retry_429_count', 'nested_session_completed', 'pipeline', 'pr_url', 'auto_merge_applied'];
103+
const TELEMETRY_FIELDS = [
104+
'context_size_at_spawn', 'compact_events_count', 'retry_429_count',
105+
'nested_session_completed', 'pipeline', 'pr_url', 'auto_merge_applied',
106+
'cutover_from', 'cutover_to', 'forced', 'operator_id', 'pre_flip_in_progress_count',
107+
];
104108
for (const f of TELEMETRY_FIELDS) {
105109
if (f in params) entry[f] = params[f];
106110
}
@@ -138,6 +142,11 @@ if (import.meta.url === pathToFileURL(process.argv[1]).href) {
138142
const logPathArg = argValue('--log-path');
139143
const prUrlArg = argValue('--pr-url');
140144
const autoMergeApplied = argValue('--auto-merge-applied');
145+
const cutoverFromArg = argValue('--cutover-from');
146+
const cutoverToArg = argValue('--cutover-to');
147+
const forcedArg = argValue('--forced');
148+
const operatorIdArg = argValue('--operator-id');
149+
const preFlipCountArg = argValue('--pre-flip-in-progress-count');
141150

142151
// --log-path overrides default log path (useful for testing without internal _setLogPath)
143152
if (logPathArg) _setLogPath(logPathArg);
@@ -159,6 +168,11 @@ if (import.meta.url === pathToFileURL(process.argv[1]).href) {
159168
if (pipelineArg !== undefined) phaseParams.pipeline = pipelineArg;
160169
if (prUrlArg !== undefined && prUrlArg !== '') phaseParams.pr_url = prUrlArg;
161170
if (autoMergeApplied !== undefined) phaseParams.auto_merge_applied = autoMergeApplied === 'true';
171+
if (cutoverFromArg !== undefined) phaseParams.cutover_from = cutoverFromArg;
172+
if (cutoverToArg !== undefined) phaseParams.cutover_to = cutoverToArg;
173+
if (forcedArg !== undefined) phaseParams.forced = forcedArg === 'true';
174+
if (operatorIdArg !== undefined) phaseParams.operator_id = operatorIdArg;
175+
if (preFlipCountArg !== undefined) phaseParams.pre_flip_in_progress_count = Number(preFlipCountArg);
162176
logPhase(phaseParams);
163177
process.stdout.write(formatPhaseStdout(phase, provider, model, fallbackReason));
164178
} catch (err) {

.gaai/core/scripts/daemon-dispatch.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,59 @@ _emit_commit_routing_record() {
224224
2>/dev/null || true
225225
}
226226

227+
# ── Cutover default pipeline reader (AC4) ────────────────────────────────
228+
# Reads cutover_state.default_pipeline from the top-level section in BACKLOG_FILE.
229+
# Returns "legacy" if the section is absent (safe default — no-op for existing deploys).
230+
# Re-reads the file on every call (no caching — AC4 E134S09).
231+
get_cutover_default_pipeline() {
232+
local val
233+
val=$(awk '
234+
/^cutover_state:[[:space:]]*$/ { in_section=1; next }
235+
in_section && /^[^[:space:]]/ { exit }
236+
in_section && /^[[:space:]]+default_pipeline:/ {
237+
gsub(/^[[:space:]]+default_pipeline:[[:space:]]*/, "")
238+
gsub(/[[:space:]]*$/, "")
239+
gsub(/^"|"$/, "")
240+
print
241+
exit
242+
}
243+
' "$BACKLOG_FILE" 2>/dev/null || true)
244+
echo "${val:-legacy}"
245+
}
246+
247+
# ── Cutover routing record (AC3) ─────────────────────────────────────────
248+
# Emits one JSONL record with phase: cutover + cutover-specific telemetry.
249+
# Arguments: trace_id cutover_from cutover_to forced operator_id pre_flip_count
250+
# Best-effort: audit emit failure warns but does NOT abort the flip.
251+
# Cohort exclusion contract: WHERE phase != 'cutover' in E134S10 statistics.
252+
_emit_cutover_routing_record() {
253+
local trace_id="$1" cutover_from="$2" cutover_to="$3" forced="$4"
254+
local operator_id="$5" pre_flip_count="$6"
255+
256+
local log_path_args=()
257+
if [[ -n "${ROUTING_LOG_PATH:-}" ]]; then
258+
log_path_args=(--log-path "$ROUTING_LOG_PATH")
259+
fi
260+
261+
node "$PROJECT_DIR/.gaai/core/adapters/claude-code/runtime-routing-logger.js" \
262+
--trace-id "$trace_id" \
263+
--story-id "cutover" \
264+
--phase "cutover" \
265+
--provider "daemon-bash" \
266+
--model "n/a" \
267+
--duration-ms 0 \
268+
--fallback-reason "null" \
269+
--impl-model-tag "n/a" \
270+
--pipeline "cutover" \
271+
--cutover-from "$cutover_from" \
272+
--cutover-to "$cutover_to" \
273+
--forced "$forced" \
274+
--operator-id "$operator_id" \
275+
--pre-flip-in-progress-count "$pre_flip_count" \
276+
"${log_path_args[@]}" \
277+
2>/dev/null || true
278+
}
279+
227280
# ── Phase handlers ────────────────────────────────────────────────────────
228281

229282
handle_plan_phase() {

.gaai/core/scripts/delivery-daemon.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2383,8 +2383,13 @@ while true; do
23832383

23842384
increment_retry "$story_id"
23852385

2386-
# ── Route: 3phase dispatch OR legacy wrapper (E134S02) ────────────────
2386+
# ── Route: 3phase dispatch OR legacy wrapper (E134S02 + E134S09) ───────
2387+
# Per-story delivery_pipeline takes precedence over cutover default.
2388+
# Cutover default is re-read at every poll (no caching — AC4 E134S09).
23872389
_dp=$(get_delivery_pipeline "$story_id")
2390+
if [[ -z "$_dp" ]]; then
2391+
_dp=$(get_cutover_default_pipeline)
2392+
fi
23882393
if [[ "$_dp" == "3phase" ]]; then
23892394
_trace_id=$(node -e "import('node:crypto').then(m=>process.stdout.write(m.randomUUID()))" 2>/dev/null \
23902395
|| python3 -c "import uuid; print(str(uuid.uuid4()),end='')" 2>/dev/null \

0 commit comments

Comments
 (0)