docs+rig(flow-debugger): step logs v1.4 specs, register rows, FlowLogDemo seed + verification step J

This commit is contained in:
Joseph Doherty
2026-09-09 12:56:39 -04:00
parent f174725557
commit 82739ec912
12 changed files with 221 additions and 12 deletions
+70
View File
@@ -41,6 +41,11 @@ set -euo pipefail
# DB write Submitted or — DB reachable, immediate-completion path — already Delivered, the
# notification Submitted; replay is retried <= 90 s until the write is Delivered and the
# notification has a terminal NotifyDeliver row). Skipped with a note when the demo is not seeded.
# J Flow Debugger STEP LOGS (2026-09-09) -> YES (FlowLogDemo — seed-flow-log-demo.sh — logs
# info/debug/warn, writes a static attribute, then throws: the ScriptRun step comes back Failed with
# errorDetail naming InvalidOperationException, and >= 3 ScriptTrace/ScriptLog rows carry levels
# {info,debug,warn}. Replay asserts the same from the central audit store. Skipped with a note when
# the demo is not seeded.)
: "${DELMIA_API_KEY:?export DELMIA_API_KEY=sbk_... first}"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
@@ -232,4 +237,69 @@ sys.exit(0 if ok else 1)' "$1"
echo " replay: $I_REPLAY"
echo "I outbound live+replay -> YES"
fi
# J — Flow Debugger step logs + exception detail (design 2026-09-09). FlowLogDemo logs at three
# levels, writes a static attribute, then throws. Live: the site returns its ScriptRun row (Failed,
# errorDetail = the exception's ToString()) and the ScriptLog rows inline on the same reply. Replay:
# the same rows are read back from the central AuditLog once the 5 s telemetry push has landed.
echo "== J Flow Debugger step logs (live + replay)"
J_INSTANCE_ID=$("$CLI" instance list "${H_ARGS[@]}" | python3 -c 'import json,sys; xs=json.load(sys.stdin); print(next((i["id"] for i in xs if i.get("uniqueName")==sys.argv[1]), ""))' "$MACHINE")
if [ -z "$J_INSTANCE_ID" ]; then
echo "J step logs live+replay -> SKIPPED ($MACHINE not seeded — run docker/seed-delmia-sim.sh)"
else
j_check() { # $1 = live|replay; stdin = FlowDebugRunResult JSON
python3 -c '
import json, sys
mode = sys.argv[1]
r = json.load(sys.stdin)
rows = []
for e in r.get("events", []):
d = json.loads(e["detailsJson"])
d["_extra"] = json.loads(d["extra"]) if d.get("extra") else {}
rows.append(d)
runs = [d for d in rows if d.get("kind") == "ScriptRun"]
logs = [d for d in rows if d.get("kind") == "ScriptLog"]
levels = sorted({(d["_extra"].get("logLevel") or "?") for d in logs})
problems = []
if not runs:
problems.append("no ScriptRun row")
else:
failed = [d for d in runs if d.get("status") == "Failed"]
if not failed:
problems.append("ScriptRun not Failed (" + ",".join(str(d.get("status")) for d in runs) + ")")
elif not any("InvalidOperationException" in (d.get("errorDetail") or "") for d in failed):
problems.append("no InvalidOperationException in errorDetail")
if len(logs) < 3:
problems.append("only " + str(len(logs)) + " ScriptLog row(s)")
missing = [lv for lv in ("info", "debug", "warn") if lv not in levels]
if missing:
problems.append("levels missing " + ",".join(missing))
ok = not problems
print(("YES" if ok else "NO") + " root=" + str(r.get("rootExecutionId")) + " logs=" + str(len(logs))
+ " levels=" + ",".join(levels) + " scriptRun=" + ",".join(str(d.get("status")) for d in runs)
+ (" problems=" + ";".join(problems) if problems else "") + (" error=" + str(r.get("errorCode")) if r.get("errorCode") else ""))
sys.exit(0 if ok else 1)' "$1"
}
# The script throws by design, so the run reports Completed=false with CALL_FAILED — that is the
# expected outcome here, and the CLI still prints the full result. Do not gate on the exit code.
set +e; J_RUN=$("$CLI" flow-debug run-script --instance-id "$J_INSTANCE_ID" --script FlowLogDemo "${H_ARGS[@]}"); set -e
case "$J_RUN" in
*rootExecutionId*) ;;
*) echo "J step logs live+replay -> SKIPPED (FlowLogDemo not seeded — run docker/seed-flow-log-demo.sh): $(echo "$J_RUN" | head -2)"; J_RUN=""; ;;
esac
if [ -n "$J_RUN" ]; then
J_LIVE=$(echo "$J_RUN" | j_check live) || { echo "FAIL: live run: $J_LIVE"; exit 1; }
echo " live: $J_LIVE"
J_ROOT=$(echo "$J_RUN" | python3 -c 'import json,sys; print(json.load(sys.stdin)["rootExecutionId"])')
J_REPLAY=""
for i in $(seq 1 20); do
set +e; J_REPLAY=$("$CLI" flow-debug replay --execution-id "$J_ROOT" "${H_ARGS[@]}" | j_check replay); J_RRC=$?; set -e
[ "$J_RRC" -eq 0 ] && break
sleep 2
done
[ "${J_RRC:-1}" -eq 0 ] || { echo "FAIL: replay never showed the logs + exception after 40 s: $J_REPLAY"; exit 1; }
echo " replay: $J_REPLAY"
echo " root: $J_ROOT (open /deployment/flow-debugger?executionId=$J_ROOT)"
echo "J step logs live+replay -> YES"
fi
fi
echo "== done. Notifier log: $RUN_DIR/delmia-notifier.log"