Replay Composition
Interleaved Step Summary
Ordered Owners
An interleaved replay keeps one global order while each event still belongs to one owner. This script summarizes that shape with vectors.
Program
Play the script to choose how many ordered events to include and watch owner totals accumulate.
interleaved_step_summary.R
Replay: real traced execution (multi-file project)
max_step <- 3
owners <- c("main", "worker", "main", "worker")
deltas <- c(1, 2, 3, 4)
main_total <- 0
worker_total <- 0
for (i in seq_len(max_step)) {
if (owners[i] == "main") {
main_total <- main_total + deltas[i]
} else {
worker_total <- worker_total + deltas[i]
}
}
label <- paste(main_total, worker_total, sep = ":")
cat(label, "\n", sep = "")
max_step <- 2
owners <- c("main", "worker", "main", "worker")
deltas <- c(1, 2, 3, 4)
main_total <- 0
worker_total <- 0
for (i in seq_len(max_step)) {
if (owners[i] == "main") {
main_total <- main_total + deltas[i]
} else {
worker_total <- worker_total + deltas[i]
}
}
label <- paste(main_total, worker_total, sep = ":")
cat(label, "\n", sep = "")
max_step <- 4
owners <- c("main", "worker", "main", "worker")
deltas <- c(1, 2, 3, 4)
main_total <- 0
worker_total <- 0
for (i in seq_len(max_step)) {
if (owners[i] == "main") {
main_total <- main_total + deltas[i]
} else {
worker_total <- worker_total + deltas[i]
}
}
label <- paste(main_total, worker_total, sep = ":")
cat(label, "\n", sep = "")
max_step ← 3
1max_step <- 32owners <- c("main", "worker", "main", "worker")values this step3max_stepowners ← main, worker, main, worker
1max_step <- 32owners <- c("main", "worker", "main", "worker")3deltas <- c(1, 2, 3, 4)values this stepmain, worker, main, workerownersdeltas ← 1, 2, 3, 4
2owners <- c("main", "worker", "main", "worker")3deltas <- c(1, 2, 3, 4)4main_total <- 0values this step1, 2, 3, 4deltasmain_total ← 0
3deltas <- c(1, 2, 3, 4)4main_total <- 05worker_total <- 0values this step0main_totalworker_total ← 0
4main_total <- 05worker_total <- 06for (i in seq_len(max_step)) {values this step0worker_totali ← 1
5worker_total <- 06for (i in seq_len(max_step)) {7 if (owners[i] == "main") {values this step1iif (owners[i] == "main")
6for (i in seq_len(max_step)) {7 if (owners[i] == "main") {8 main_total <- main_total + deltas[i]values this stepTRUEowners[1] == "main"main_total ← 1
7if (owners[i] == "main") {8 main_total <- main_total + deltas[i]9} else {values this step0 → 1main_total1deltas[1]i ← 2
5worker_total <- 06for (i in seq_len(max_step)) {7 if (owners[i] == "main") {values this step2iif (owners[i] == "main")
6for (i in seq_len(max_step)) {7 if (owners[i] == "main") {8 main_total <- main_total + deltas[i]values this stepFALSEowners[2] == "main"worker_total ← 2
9} else {10 worker_total <- worker_total + deltas[i]11}values this step0 → 2worker_total2deltas[2]i ← 3
5worker_total <- 06for (i in seq_len(max_step)) {7 if (owners[i] == "main") {values this step3iif (owners[i] == "main")
6for (i in seq_len(max_step)) {7 if (owners[i] == "main") {8 main_total <- main_total + deltas[i]values this stepTRUEowners[3] == "main"main_total ← 4
7if (owners[i] == "main") {8 main_total <- main_total + deltas[i]9} else {values this step1 → 4main_total3deltas[3]label ← 4:2
12}13label <- paste(main_total, worker_total, sep = ":")14cat(label, "\n", sep = "")values this step4:2label4main_total2worker_totalcat(label, " ", sep = "")
13label <- paste(main_total, worker_total, sep = ":")14cat(label, "\n", sep = "")output4:2values this step4:2label
max_step ← 2
1max_step <- 22owners <- c("main", "worker", "main", "worker")values this step2max_stepowners ← main, worker, main, worker
1max_step <- 22owners <- c("main", "worker", "main", "worker")3deltas <- c(1, 2, 3, 4)values this stepmain, worker, main, workerownersdeltas ← 1, 2, 3, 4
2owners <- c("main", "worker", "main", "worker")3deltas <- c(1, 2, 3, 4)4main_total <- 0values this step1, 2, 3, 4deltasmain_total ← 0
3deltas <- c(1, 2, 3, 4)4main_total <- 05worker_total <- 0values this step0main_totalworker_total ← 0
4main_total <- 05worker_total <- 06for (i in seq_len(max_step)) {values this step0worker_totali ← 1
5worker_total <- 06for (i in seq_len(max_step)) {7 if (owners[i] == "main") {values this step1iif (owners[i] == "main")
6for (i in seq_len(max_step)) {7 if (owners[i] == "main") {8 main_total <- main_total + deltas[i]values this stepTRUEowners[1] == "main"main_total ← 1
7if (owners[i] == "main") {8 main_total <- main_total + deltas[i]9} else {values this step0 → 1main_total1deltas[1]i ← 2
5worker_total <- 06for (i in seq_len(max_step)) {7 if (owners[i] == "main") {values this step2iif (owners[i] == "main")
6for (i in seq_len(max_step)) {7 if (owners[i] == "main") {8 main_total <- main_total + deltas[i]values this stepFALSEowners[2] == "main"worker_total ← 2
9} else {10 worker_total <- worker_total + deltas[i]11}values this step0 → 2worker_total2deltas[2]label ← 1:2
12}13label <- paste(main_total, worker_total, sep = ":")14cat(label, "\n", sep = "")values this step1:2label1main_total2worker_totalcat(label, " ", sep = "")
13label <- paste(main_total, worker_total, sep = ":")14cat(label, "\n", sep = "")output1:2values this step1:2label
max_step ← 4
1max_step <- 42owners <- c("main", "worker", "main", "worker")values this step4max_stepowners ← main, worker, main, worker
1max_step <- 42owners <- c("main", "worker", "main", "worker")3deltas <- c(1, 2, 3, 4)values this stepmain, worker, main, workerownersdeltas ← 1, 2, 3, 4
2owners <- c("main", "worker", "main", "worker")3deltas <- c(1, 2, 3, 4)4main_total <- 0values this step1, 2, 3, 4deltasmain_total ← 0
3deltas <- c(1, 2, 3, 4)4main_total <- 05worker_total <- 0values this step0main_totalworker_total ← 0
4main_total <- 05worker_total <- 06for (i in seq_len(max_step)) {values this step0worker_totali ← 1
5worker_total <- 06for (i in seq_len(max_step)) {7 if (owners[i] == "main") {values this step1iif (owners[i] == "main")
6for (i in seq_len(max_step)) {7 if (owners[i] == "main") {8 main_total <- main_total + deltas[i]values this stepTRUEowners[1] == "main"main_total ← 1
7if (owners[i] == "main") {8 main_total <- main_total + deltas[i]9} else {values this step0 → 1main_total1deltas[1]i ← 2
5worker_total <- 06for (i in seq_len(max_step)) {7 if (owners[i] == "main") {values this step2iif (owners[i] == "main")
6for (i in seq_len(max_step)) {7 if (owners[i] == "main") {8 main_total <- main_total + deltas[i]values this stepFALSEowners[2] == "main"worker_total ← 2
9} else {10 worker_total <- worker_total + deltas[i]11}values this step0 → 2worker_total2deltas[2]i ← 3
5worker_total <- 06for (i in seq_len(max_step)) {7 if (owners[i] == "main") {values this step3iif (owners[i] == "main")
6for (i in seq_len(max_step)) {7 if (owners[i] == "main") {8 main_total <- main_total + deltas[i]values this stepTRUEowners[3] == "main"main_total ← 4
7if (owners[i] == "main") {8 main_total <- main_total + deltas[i]9} else {values this step1 → 4main_total3deltas[3]i ← 4
5worker_total <- 06for (i in seq_len(max_step)) {7 if (owners[i] == "main") {values this step4iif (owners[i] == "main")
6for (i in seq_len(max_step)) {7 if (owners[i] == "main") {8 main_total <- main_total + deltas[i]values this stepFALSEowners[4] == "main"worker_total ← 6
9} else {10 worker_total <- worker_total + deltas[i]11}values this step2 → 6worker_total4deltas[4]label ← 4:6
12}13label <- paste(main_total, worker_total, sep = ":")14cat(label, "\n", sep = "")values this step4:6label4main_total6worker_totalcat(label, " ", sep = "")
13label <- paste(main_total, worker_total, sep = ":")14cat(label, "\n", sep = "")output4:6values this step4:6label
global order
`max_step` selects a prefix of the global event order.
owner totals
Each ordered event updates the total for its owner.
interleaving
The loop alternates between owners while preserving one replay order.