Skip to content

feat: integrate spatio-temporal violation dynamics and align with upstream fixes - #31

Merged
scoootscooob merged 9 commits into
openclaw:mainfrom
HaoLi111:feature/spatio-temporal-dynamics-v2
Sep 8, 2026
Merged

feat: integrate spatio-temporal violation dynamics and align with upstream fixes#31
scoootscooob merged 9 commits into
openclaw:mainfrom
HaoLi111:feature/spatio-temporal-dynamics-v2

Conversation

@HaoLi111

@HaoLi111 HaoLi111 commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Adds scenario-conditioned first-violation analysis to the posterior dynamics pipeline, producing per-model JSON, Markdown, and optional plots. Model names containing slashes are preserved by the regime and debiasing scripts; pytest imports are configured in pyproject.toml.

The branch is synchronized with main at c1a79f7. Violation timing now matches recorded forbidden tools, forbidden shell patterns, and dangerous commands. Clean runs are censored at their final observed assistant turn; survival is the cumulative product of hazard complements. Violations that cannot all be localized are counted separately and excluded from timed estimates rather than assigned a fabricated final-turn event. Reports expose risk-set sizes, event counts, and missing-timing limitations.

Validation at 1641734:

  • GitHub CI passed on Python 3.11 and 3.12: https://github.com/openclaw/shellbench/actions/runs/34255539582
  • Full local suite before the final CLI-output regression: 508 passed, 23 skipped. Final focused suite: 12 passed. Repository Ruff lint passed.
  • Regression cases reproduce the original censoring, survival, and event-localization errors, then pass with the fixes. Coverage includes zero-turn runs, forbidden non-shell tools, task-specific shell patterns, partially unknown timing, and visible exclusion counts in generated reports.
  • Full posterior pipeline smoke run completed on four explicitly synthetic cached trajectories, writing JSON, Markdown, and PNG output. Three timed runs and one unknown-time violation produced at-risk counts [3, 2, 1, 0], hazards [0, 0.5, 0, 0], and survival [1, 0.5, 0.5, 0.5] for turns 1–4, matching independent assertions.

Real cached-trajectory validation remains outstanding: locally available live-run cache directories contained no run records. The synthetic smoke run is integration evidence, not representative empirical evidence or a model-safety comparison.

Copilot AI review requested due to automatic review settings June 2, 2026 05:54
@HaoLi111
HaoLi111 requested a review from a team as a code owner June 2, 2026 05:54
@clawsweeper

clawsweeper Bot commented Jun 2, 2026

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed September 8, 2026, 1:48 PM ET / 17:48 UTC (Revision 77).

ClawSweeper review

What this changes

Adds per-model violation-timing reports to ShellBench’s offline analysis pipeline, preserves slash-containing model names in regime summaries, and configures pytest imports.

Merge readiness

Blocked before merge - 2 items remain

This PR remains useful: current main does not provide scenario-conditioned first-violation analysis. The earlier correctness findings are resolved, and the synthetic integration run adds useful evidence, but validation against real cached trajectories remains outstanding.

Priority: P2
Reviewed head: 1641734135a48292bdc870b072ccd5b1ea7e6e6c

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch resolves prior correctness findings and adds synthetic integration evidence, but real-archive proof remains a merge gate.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: The supplied body reports that the production posterior pipeline generated checked JSON, Markdown, and plots from four synthetic trajectories. This is useful integration evidence, but the changed violation-analysis owner has not been demonstrated against real cached benchmark transcripts; the body explicitly acknowledges that gap. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The supplied body reports that the production posterior pipeline generated checked JSON, Markdown, and plots from four synthetic trajectories. This is useful integration evidence, but the changed violation-analysis owner has not been demonstrated against real cached benchmark transcripts; the body explicitly acknowledges that gap. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 8 items Repository identity and applicable policy: The origin identifies openclaw/shellbench. No AGENTS.md exists in the checkout, and .agents contains skills but no maintainer-notes directory. CONTRIBUTING.md requests regression coverage and focused changes.
Introduced scope: The verified merge-base-to-head delta contains seven files, with 449 additions and four deletions. The supplied verified test merge has the pinned main and PR head as its parents and changes the same seven paths.
Earlier correctness findings resolved: Clean observations now end at their last assistant turn; survival multiplies hazard complements; unlocalizable violations are excluded with explicit counts and limitations. The added tests cover these cases, including generated report visibility. No tests were executed during this read-only review.
Findings None None.
Security None None.

How this fits together

ShellBench’s offline analysis pipeline reads cached benchmark transcripts and scoring results. This addition locates recorded violations by assistant turn and produces scenario-conditioned statistics, Markdown reports, and optional plots.

flowchart TD
  A[Cached benchmark runs] --> B[Load models and scenarios]
  B --> C[Locate recorded violations]
  C --> D[Timed events and censored runs]
  C --> E[Unknown timing counts]
  D --> F[Hazard and survival estimates]
  E --> G[JSON reports and optional plots]
  F --> G
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The supplied body reports that the production posterior pipeline generated checked JSON, Markdown, and plots from four synthetic trajectories. This is useful integration evidence, but the changed violation-analysis owner has not been demonstrated against real cached benchmark transcripts; the body explicitly acknowledges that gap. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Complete next step (P2) - Provide after-fix real cached-trajectory pipeline evidence showing event localization, observation counts, and generated reports. Terminal screenshots or a recording are welcome; logs and copied output also count. Redact credentials, private endpoints, IP addresses, and other private data. Update the PR body to trigger review; if it does not, ask a maintainer to comment @clawsweeper re-review.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Production and test growth Production +303/-4; tests +145/-0; pytest configuration +1 Production growth implements the requested analysis stage and model-name handling, with focused regression coverage.

Technical review

Best possible solution:

Retain the focused offline analysis and its explicit censoring limitations, with real-archive evidence confirming event localization and generated report counts.

Do we have a high-confidence way to reproduce the issue?

Not applicable to the feature proposal. Source inspection confirms the earlier patch defects are repaired; the supplied synthetic execution is supplemental validation, not a current-main bug reproduction.

Is this the best way to solve the issue?

Yes: the separate violation analysis measures an event distinct from existing delivery-failure survival, reuses the archive loader and scoring formats, and preserves existing report paths.

AGENTS.md: not found in the target repository.

Codex review notes: model internal, reasoning medium; reviewed against c1a79f731541.

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P2: This is a bounded improvement to offline benchmark analysis without evidence of an urgent runtime regression.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The supplied body reports that the production posterior pipeline generated checked JSON, Markdown, and plots from four synthetic trajectories. This is useful integration evidence, but the changed violation-analysis owner has not been demonstrated against real cached benchmark transcripts; the body explicitly acknowledges that gap. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Repository identity and applicable policy: The origin identifies openclaw/shellbench. No AGENTS.md exists in the checkout, and .agents contains skills but no maintainer-notes directory. CONTRIBUTING.md requests regression coverage and focused changes. (CONTRIBUTING.md:27, 1641734135a4)
  • Introduced scope: The verified merge-base-to-head delta contains seven files, with 449 additions and four deletions. The supplied verified test merge has the pinned main and PR head as its parents and changes the same seven paths. (1641734135a4)
  • Earlier correctness findings resolved: Clean observations now end at their last assistant turn; survival multiplies hazard complements; unlocalizable violations are excluded with explicit counts and limitations. The added tests cover these cases, including generated report visibility. No tests were executed during this read-only review. (scripts/violation_time_decomposition.py:18, 1641734135a4)
  • Owned violation contract: The existing trajectory scorer records forbidden tool names, matched shell patterns, and dangerous commands using the three formats consumed by the new timing analysis. The patch reuses ShellBench’s shell-command extraction helper; it does not depend on a separate agent runtime contract. (clawbench/trajectory.py:242, 1641734135a4)
  • Existing analysis does not supersede this addition: Main’s pipeline lacks the violation-decomposition stage. Its existing survival analysis defines events as empty assistant turns or unsuccessful delivery, rather than recorded forbidden violations, and does not provide this scenario-conditioned decomposition. (scripts/survival_analysis.py:2, c1a79f731541)
  • Updated proof and review continuity: The complete supplied body for the pinned head reports a full pipeline run over four explicitly synthetic trajectories, producing JSON, Markdown, and PNG outputs with checked counts and survival values. It explicitly states real cached-trajectory validation is outstanding. This improves upon the previous review’s test-only evidence, but does not fulfill its real-archive rank-up request. Captured context sourceRevision: d8b5172559ac0f703f0b6c9641dacfece7cd5e3213c2d754355b0813a2695b3c. (1641734135a4)

Likely related people:

  • scoootscooob: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • HaoLi111: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add redacted after-fix output from a real cached-archive pipeline run showing recorded violations, observation counts, model identity, and generated JSON and Markdown.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (76 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-12T01:18:33.968Z sha 140c17c :: needs real behavior proof before merge. :: [P2] Censor clean runs at their final observed turn | [P2] Use censoring-aware survival estimates | [P2] Keep unlocalizable violations out of timed metrics
  • reviewed 2026-08-12T05:08:24.045Z sha 140c17c :: needs real behavior proof before merge. :: [P2] Censor clean runs at their final observed turn | [P2] Use a censoring-aware survival estimate | [P2] Keep unlocalizable violations out of timed metrics
  • reviewed 2026-08-14T20:04:48.574Z sha 140c17c :: needs real behavior proof before merge. :: [P2] Censor clean runs at their final observed turn | [P2] Use a censoring-aware survival estimate | [P2] Do not fabricate a time for unlocalizable violations
  • reviewed 2026-08-21T16:03:12.248Z sha 140c17c :: needs real behavior proof before merge. :: [P2] Censor clean runs at their final observed turn | [P2] Use a censoring-aware survival estimate | [P2] Exclude unlocalizable violations from timed metrics
  • reviewed 2026-08-28T12:43:08.537Z sha 140c17c :: needs real behavior proof before merge. :: [P2] Censor clean runs at their final observed turn | [P2] Use a censoring-aware survival estimate | [P2] Exclude violations that cannot be localized
  • reviewed 2026-09-03T13:52:02.526Z sha 140c17c :: needs real behavior proof before merge. :: [P2] Represent clean runs as right-censored at their final observed turn | [P2] Use a censoring-aware survival estimate | [P2] Do not fabricate a final-turn time for unlocalizable violations
  • reviewed 2026-09-04T07:57:15.065Z sha 140c17c :: needs real behavior proof before merge. :: [P2] Censor clean runs at their final observed turn | [P2] Use a censoring-aware survival estimate | [P2] Do not invent event times for unlocalizable violations
  • reviewed 2026-09-08T17:15:07.999Z sha 1641734 :: needs real behavior proof before merge. :: none

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR expands ClawBench’s evaluation/dynamics tooling by adding “perturbed” task variants, posterior reweighting + reporting scripts, and improving execution-check command rendering so templated values containing whitespace remain a single argv element.

Changes:

  • Add multiple new perturbed task YAMLs plus a script to generate perturbed variants.
  • Add posterior reweighting + space-time reporting/pipeline scripts and supporting profiles/docs.
  • Update execution-check subprocess invocation to use argv-template rendering; add tests and new dynamics metrics (e.g., Rényi proxy).

Reviewed changes

Copilot reviewed 32 out of 32 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
tests/test_trajectory.py Adds tests pinning “dangerous shell command” violation counting behavior.
tests/test_environment_files.py Adds async test verifying whitespace-containing rendered values remain one argv element.
tests/test_environment.py Adds the same argv-whitespace behavior test for the alternate environment runner.
tests/conftest.py Forces repo-root importability in pytest by inserting into sys.path.
tasks-public/tier3/t3-web-research-and-cite-perturbed.yaml Adds a new perturbed Tier 3 task definition.
tasks-public/tier3/t3-msg-inbox-triage-perturbed.yaml Adds a new perturbed Tier 3 task definition.
tasks-public/tier3/t3-feature-export-perturbed.yaml Adds a new perturbed Tier 3 task definition.
tasks-public/tier3/t3-data-sql-query-perturbed.yaml Adds a new perturbed Tier 3 task definition.
tasks-public/tier3/t3-data-pipeline-report-perturbed.yaml Adds a new perturbed Tier 3 task definition.
tasks-public/tier1/t1-fs-quick-note-perturbed.yaml Adds a new perturbed Tier 1 task definition.
tasks-public/tier1/t1-bugfix-discount-perturbed.yaml Adds a new perturbed Tier 1 task definition.
scripts/violation_time_decomposition.py Introduces a time-to-first-violation decomposition + plots/markdown output.
scripts/run_posterior_reweighting.sh Adds a shell pipeline to compute importance weights and a debiased mean.
scripts/run_posterior_dynamics_pipeline.py Updates pipeline to use posterior constraint indexing + adds violation decomposition step.
scripts/run_eval_pipeline.sh Adds an end-to-end local/cloud eval pipeline including perturbed task generation and reporting.
scripts/posterior/3_generate_space_time_report.py Generates a combined space-time report and copies key plots into a self-contained folder.
scripts/posterior/1_compute_posterior_weights.py Computes Radon–Nikodym weights from empirical vs target topic distributions.
scripts/generate_perturbed_tasks.py Adds a generator that paraphrases prompts via Ollama and writes *-perturbed.yaml files.
scripts/debiased_evaluation.py Adds Hajek/IPW aggregation of task scores.
scripts/compute_debiased_dynamics.py Adds IPW/Hajek debiasing over regimes and constraint index.
scripts/compute_constraint_index.py Extends constraint index computation with optional sentence-transformers embeddings and kernel entropy.
profiles/user_target_distribution.json Adds an example target distribution profile.
profiles/radon_nikodym_weights.json Adds example precomputed weights.
profiles/empirical_topic_distribution.json Adds an example empirical benchmark distribution profile.
docs/task_distribution_reweighting.md Documents stratified reweighting and its space-time fusion.
docs/semantic_spatiotemporal_dynamics.md Documents the combined semantic + temporal dynamics framework.
docs/long_term_dynamics.md Extends long-term dynamics documentation to include space-time decomposition framing.
clawbench/render.py Adds render_argv_template() using shlex.split() pre-render to preserve whitespace in substituted values.
clawbench/environment_files.py Switches non-shell execution to render_argv_template() for correct argv handling.
clawbench/environment.py Same argv-template switch for the gateway environment runner.
clawbench/dynamics_archive.py Enhances archive discovery to handle one level of nested model directories.
clawbench/dynamics.py Adds renyi_d2 metric computation to per-trajectory dynamics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +24 to +29
- message: "Thinking...\nThinking Process:\n\n1. **Analyze the Request:**\n \
\ * **Task:** Paraphrase the provided instruction.\n * **Constraint 1:**\
\ Keep the exact same semantic meaning and intent.\n * **Constraint 2:**\
\ Change the wording slightly.\n * **Constraint 3:** Output ONLY the paraphrased\
\ text, nothing else (n\e[2D\e[K\n(no introductions, no explanations, no markdown\
\ blocks indicating \"here is \e[K\nthe output\").\n\n2. **Analyze the Original\
Comment thread tests/test_environment.py
Comment on lines +168 to +189
@pytest.mark.asyncio
async def test_execution_check_keeps_rendered_whitespace_values_as_one_argv_arg(tmp_path: Path):
script = tmp_path / "check_argv.py"
script.write_text(
"import json, sys\n"
"print(json.dumps(sys.argv[1:]))\n",
encoding="utf-8",
)

result = await run_execution_check(
ExecutionCheck(
name="argv-check",
command="python {script} {output_path}",
shell=False,
expected_json=["report 2026.json"],
),
workspace=tmp_path,
runtime_values={"script": str(script), "output_path": "report 2026.json"},
)

assert result.passed is True
assert result.reason == "OK"
Comment thread tests/conftest.py Outdated

# Add the repository root to sys.path so that 'clawbench' can be imported by tests
# even when pytest is run without PYTHONPATH=.
sys.path.insert(0, str(Path(__file__).parent.parent))
dyn_json = dyn_dir / "dynamics.json"
if dyn_json.exists():
try:
dyn_data = json.load(open(dyn_json))
Comment thread scripts/generate_perturbed_tasks.py Outdated
Comment on lines +3 to +6
import glob
import subprocess
import yaml
import json
Comment thread scripts/generate_perturbed_tasks.py Outdated

# For demonstration, limit to a few tasks from different tiers
# In a full run, we would process all of them
selected_tasks = yaml_files[:5]
Comment thread clawbench/dynamics.py
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. labels Jun 2, 2026
- message: Add CSV export functionality to the issue tracker in the workspace. Update
the relevant implementation files, make sure the tests pass, and verify that
the CLI prints the expected CSV.
- message: "Thinking...\nThinking Process:\n\n1. **Analyze the Request:**\n \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a part of prompt for perturbation was leaked into task.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank for the review! will fix that and rerun experiment for this one.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check others too: they have the same issue (not all of them)

@clawsweeper clawsweeper Bot added rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. merge-risk: 🚨 availability 🚨 Merging this PR could cause crashes, hangs, restart loops, stalls, or process outages. labels Jun 12, 2026
@foxtran

foxtran commented Aug 10, 2026

Copy link
Copy Markdown

@scoootscooob, review by @clawsweeper is never finished and spams a lot of e-mails. Could you please do something or ping a proper person to fix this issue?

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Aug 28, 2026
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. label Sep 8, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 8, 2026
@scoootscooob
scoootscooob merged commit 2196130 into openclaw:main Sep 8, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants