{ "pack_id": "jepa-world-state-and-action-simulator", "title": "JEPA world-state and action simulator", "version": "0.1.0", "summary": "A collection of nouns and verbs for action-conditioned latent world-state prediction, representation-space epistemic energy anomaly gating and counterfactual multi-step rollout planning.", "dependencies": [ "configuration-grids-and-bounds", "evaluation-design", "wiring-and-conformance-checks" ], "boundaries": [ "ActionConditionedStatePredictor projects observations into factored latent representations (leases, resource quotas, record digests, capability taints and invariant predicates) and flags invariant breaches before irreversible execution.", "EpistemicEnergyAnomalyGate computes representation-space surprise E(s_hat, s_obs) invariant to surface formatting jitter and triggers rollback or review whenever surprise exceeds grid bounds.", "CounterfactualRolloutPlanner ranks candidate multi-step trajectories strictly inside representation space without executing external side effects.", "Importing the pack writes nothing, enqueues nothing and installs no code." ], "nouns": [ { "slug": "pack", "category": "noun.skill_pack", "role": "pack", "title": "A collection of nouns and verbs for action-conditioned latent world-state prediction, representation-space epistemic energy anomaly gating and counterfactual multi-step rollout planning", "value": { "lets_workers": "Encode environment observations into compact factored latent world states (leases, resource quotas, record digests, capability taints and invariant predicates), predict post-action states s_hat_{t+1} = transition(s_t, a_t) before irreversible execution, gate unexpected execution divergence via representation-space epistemic energy E(s_hat_{t+1}, s_obs_{t+1}) and rank K multi-step counterfactual rollouts by goal distance plus cumulative risk energy.", "flow": [ { "verb": { "$verb": "jepa-world-state-and-action-simulator.plan-counterfactual-rollout-trajectories" }, "when": "Simulate K candidate multi-step action sequences in representation space before irreversible execution and rank feasible trajectories by goal distance plus cumulative risk energy." }, { "verb": { "$verb": "jepa-world-state-and-action-simulator.gate-step-by-epistemic-surprise-energy" }, "when": "Compare predicted post-action world state s_hat_{t+1} against observed world state s_obs_{t+1} in representation space and trigger review or rollback when surprise exceeds grid bounds." }, { "verb": { "$verb": "jepa-world-state-and-action-simulator.verify-world-state-simulator-receipt" }, "when": "Independently verify pre-execution invariant rejection, surface-jitter invariance, anomaly rollback recall and ZeroHardcodedValuesAstGate conformance." } ], "guardrails": [ { "$pin": "guardrail.simulate-invariants-before-irreversible-effects" }, { "$pin": "guardrail.grid-governed-surprise-bounds-and-zero-magic-literals" } ], "tool": { "$pin": "tool.world-state-jepa" }, "worked_example": "Multi-step counterfactual rollout and post-action surprise evaluation bundle recomputed in test_world_state_jepa.py: rejects unfenced/tainted commit plans pre-execution, selects plan-fenced-sanitized-clean (goal_distance_energy 0.0, total_objective_energy 0.3925), assigns 0.0 surprise energy under benign whitespace/timestamp jitter and triggers rollback on 100% (3/3) of injected lease-theft, phantom-CAS and quota-drain anomalies (max energy 9.18778)." }, "relations": [ [ "requires_noun", "guardrail.simulate-invariants-before-irreversible-effects" ], [ "requires_noun", "guardrail.grid-governed-surprise-bounds-and-zero-magic-literals" ], [ "requires_noun", "spec.jepa-world-state-and-energy-grid" ], [ "requires_noun", "rules.latent-transition-and-surprise-energy" ], [ "requires_noun", "tool.world-state-jepa" ], [ "requires_noun", "template.world-state-jepa-receipt" ] ] }, { "slug": "guardrail.simulate-invariants-before-irreversible-effects", "category": "noun.skill_pack", "role": "guardrail", "title": "Guardrail: irreversible or state-mutating actions must pass factored world-state transition simulation before execution", "category_reason": "Blocks unfenced writes, capability taint leaks, compare-and-set version conflicts and quota exhaustion prior to execution.", "value": { "rule": "Reject any candidate trajectory whose predicted post-action state violates lease_fenced, quota_non_negative, taint_isolated or cas_version_monotonic invariants.", "how_it_is_checked": "ActionConditionedStatePredictor.predict_transition and CounterfactualRolloutPlanner.rank_candidates mark invariant-breaking trajectories infeasible before recommending any plan." } }, { "slug": "guardrail.grid-governed-surprise-bounds-and-zero-magic-literals", "category": "noun.skill_pack", "role": "guardrail", "title": "Guardrail: epistemic surprise thresholds and rollout horizons resolve from NodeGrid with zero inline magic scalars", "category_reason": "Keeps rollback thresholds tunable and enforces mechanical AST conformance across simulator modules.", "value": { "rule": "Resolve review_energy_threshold, rollback_energy_threshold, max_rollout_horizon and risk_energy_weight from default_grid_spec.json and enforce ZeroHardcodedValuesAstGate.", "how_it_is_checked": "scan_directory_for_hardcoded_values and NodeGrid constraint tests run during make check." } }, { "slug": "spec.jepa-world-state-and-energy-grid", "category": "noun.benchmark_suite", "role": "spec", "title": "Specification: ActionConditionedStatePredictor, EpistemicEnergyAnomalyGate and CounterfactualRolloutPlanner invariants", "category_reason": "Defines factored representation components, post-action energy decomposition and multi-step rollout objective.", "value": { "components": [ "ActionConditionedStatePredictor", "EpistemicEnergyAnomalyGate", "CounterfactualRolloutPlanner" ], "factored_axes": [ "leases", "resource_quotas", "record_digests", "capability_taints", "invariant_predicates" ], "default_max_rollout_horizon": 6, "default_review_energy_threshold": 0.2, "default_rollback_energy_threshold": 1.0, "default_risk_energy_weight": 1.0 } }, { "slug": "rules.latent-transition-and-surprise-energy", "category": "noun.reflex_procedure", "role": "rules", "title": "Deterministic factored latent transition, epistemic surprise energy and rollout ranking rules", "category_reason": "Zero-model representation-space transition and anomaly energy equations.", "value": { "transition_equation": "s_hat_{t+1} = transition(encode(obs_t), a_t)", "surprise_energy_equation": "E(s_hat, s_obs) = w_q * ||q_hat - q_obs||_2^2 + w_l * d_lease + w_d * d_digest + w_t * |taints_obs \\ taints_hat| + w_inv * broken_invariants + w_lat * ||z_hat - z_obs||_2^2", "rollout_objective": "J(a_{0:H-1}) = E_goal(s_hat_H, g) + lambda_risk * sum_{t=0}^{H-1} R(s_t, a_t, s_hat_{t+1})", "model_calls": 0 } }, { "slug": "tool.world-state-jepa", "category": "noun.code_node", "role": "tool_card", "title": "Tool card: standard-library JEPA world-state predictor, epistemic energy anomaly gate and counterfactual rollout planner", "category_reason": "Tested Python 3.10+ standard-library package pinned by path, file count and SHA-256.", "value": { "name": "JEPA world-state and action simulator", "code": { "$code": "jepa-world-state-and-action-simulator" }, "runtime": "Python 3.10 or later, standard library only.", "commands": [ "python -m world_state_jepa --bundle BUNDLE.json" ], "does": [ "Implements ActionConditionedStatePredictor encoding raw observations into surface-noise-invariant FactoredWorldState embeddings and predicting post-action transitions.", "Implements EpistemicEnergyAnomalyGate computing representation-space surprise E(s_hat_{t+1}, s_obs_{t+1}) and gating execution into continue, require_review or trigger_rollback.", "Implements CounterfactualRolloutPlanner simulating K multi-step trajectories and ranking feasible minimum-energy plans." ], "does_not": [ "Execute external side effects, reconstruct raw pixel/token noise or embed hardcoded numeric scalars in operational functions." ], "code_license": "MIT" }, "relations": [ [ "verifies", "spec.jepa-world-state-and-energy-grid" ] ] }, { "slug": "template.world-state-jepa-receipt", "category": "noun.scene_recipe", "role": "template", "title": "Template: counterfactual rollout ranking and epistemic surprise anomaly gate receipt", "value": { "describes": "a deterministic receipt recording counterfactual trajectory selection, goal/risk energies, benign surface-jitter invariance and post-action anomaly rollback recall", "schema": { "type": "object", "additionalProperties": false, "required": [ "recommended_sequence_id", "feasible_sequence_count", "best_goal_distance_energy", "best_cumulative_risk_energy", "best_total_objective_energy", "clean_observation_energy", "clean_observation_decision", "anomaly_case_count", "anomaly_rollback_recall", "max_anomaly_energy" ], "properties": { "recommended_sequence_id": { "type": [ "string", "null" ] }, "feasible_sequence_count": { "type": "integer", "minimum": 0 }, "best_goal_distance_energy": { "type": "number", "minimum": 0.0 }, "best_cumulative_risk_energy": { "type": "number", "minimum": 0.0 }, "best_total_objective_energy": { "type": "number", "minimum": 0.0 }, "clean_observation_energy": { "type": "number", "minimum": 0.0 }, "clean_observation_decision": { "type": "string", "enum": [ "continue", "require_review", "trigger_rollback" ] }, "anomaly_case_count": { "type": "integer", "minimum": 1 }, "anomaly_rollback_recall": { "type": "number", "minimum": 0.0, "maximum": 1.0 }, "max_anomaly_energy": { "type": "number", "minimum": 0.0 } } }, "example": { "recommended_sequence_id": "plan-fenced-sanitized-clean", "feasible_sequence_count": 2, "best_goal_distance_energy": 0.0, "best_cumulative_risk_energy": 0.3925, "best_total_objective_energy": 0.3925, "clean_observation_energy": 0.0, "clean_observation_decision": "continue", "anomaly_case_count": 3, "anomaly_rollback_recall": 1.0, "max_anomaly_energy": 9.18778 } } }, { "slug": "example.world-state-jepa-bundle", "category": "noun.eval_run", "role": "example", "synthetic": true, "title": "Worked example input: multi-step candidate action sequences, surface-jittered clean observation and injected post-action anomalies", "category_reason": "Synthetic fixture recomputed by test_world_state_jepa.py.", "value": { "initial_observation": { "leases": {}, "resource_quotas": { "compute_units": 0.9, "io_ops": 0.85 }, "record_digests": { "rec-alpha": { "version": 1, "semantic_payload": "alpha_state_v1" } }, "capability_taints": [ "untrusted_input" ], "surface_timestamp_ms": 1730000100 }, "goal": { "target_record_versions": { "rec-alpha": 2 }, "require_all_leases_released": true, "forbid_taints": [ "untrusted_input", "unverified_draft" ], "min_quota_remaining": { "compute_units": 0.4, "io_ops": 0.4 } }, "candidate_sequences": [ { "sequence_id": "plan-reckless-unfenced", "actions": [ { "action_id": "act-unfenced-commit", "op": "commit_cas_write", "actor_id": "worker-01", "target_key": "rec-alpha", "expected_version": 1, "quota_deltas": { "compute_units": -0.05, "io_ops": -0.05 } } ] }, { "sequence_id": "plan-fenced-sanitized-clean", "actions": [ { "action_id": "act-sanitize-01", "op": "sanitize_taints", "actor_id": "worker-01", "clears_taints": [ "untrusted_input" ], "quota_deltas": { "compute_units": -0.05, "io_ops": -0.02 } }, { "action_id": "act-lease-01", "op": "acquire_lease", "actor_id": "worker-01", "target_key": "rec-alpha", "quota_deltas": { "compute_units": -0.02, "io_ops": -0.03 } }, { "action_id": "act-stage-01", "op": "transform_record", "actor_id": "worker-01", "target_key": "rec-alpha", "quota_deltas": { "compute_units": -0.08, "io_ops": -0.05 } }, { "action_id": "act-commit-01", "op": "commit_cas_write", "actor_id": "worker-01", "target_key": "rec-alpha", "expected_version": 1, "irreversible": true, "quota_deltas": { "compute_units": -0.05, "io_ops": -0.05 } }, { "action_id": "act-release-01", "op": "release_lease", "actor_id": "worker-01", "target_key": "rec-alpha", "quota_deltas": { "compute_units": -0.01, "io_ops": -0.01 } } ] }, { "sequence_id": "plan-quota-heavy-dangling-lease", "actions": [ { "action_id": "act-sanitize-02", "op": "sanitize_taints", "actor_id": "worker-01", "clears_taints": [ "untrusted_input" ], "quota_deltas": { "compute_units": -0.25, "io_ops": -0.2 } }, { "action_id": "act-lease-02", "op": "acquire_lease", "actor_id": "worker-01", "target_key": "rec-alpha", "quota_deltas": { "compute_units": -0.1, "io_ops": -0.1 } }, { "action_id": "act-commit-02", "op": "commit_cas_write", "actor_id": "worker-01", "target_key": "rec-alpha", "expected_version": 1, "irreversible": true, "quota_deltas": { "compute_units": -0.2, "io_ops": -0.2 } } ] } ], "executed_step_action": { "action_id": "act-sanitize-01", "op": "sanitize_taints", "actor_id": "worker-01", "clears_taints": [ "untrusted_input" ], "quota_deltas": { "compute_units": -0.05, "io_ops": -0.02 } }, "clean_post_observation": { "leases": {}, "resource_quotas": { "compute_units": 0.85, "io_ops": 0.83 }, "record_digests": { "rec-alpha": { "version": 1, "semantic_payload": " alpha_state_v1 \n" } }, "capability_taints": [], "surface_timestamp_ms": 1730000999, "surface_trace_noise": "benign-formatting-jitter" }, "anomaly_observations": [ { "leases": { "rec-alpha": { "holder": "intruder-worker-99", "epoch": 4 } }, "resource_quotas": { "compute_units": 0.85, "io_ops": 0.83 }, "record_digests": { "rec-alpha": { "version": 1, "semantic_payload": "alpha_state_v1" } }, "capability_taints": [] }, { "leases": {}, "resource_quotas": { "compute_units": 0.85, "io_ops": 0.83 }, "record_digests": { "rec-alpha": { "version": 3, "semantic_payload": "concurrent_mutation_v3" } }, "capability_taints": [] }, { "leases": {}, "resource_quotas": { "compute_units": -0.1, "io_ops": 0.1 }, "record_digests": { "rec-alpha": { "version": 1, "semantic_payload": "alpha_state_v1" } }, "capability_taints": [ "untrusted_input" ] } ], "shows": "Counterfactual world-state rollout ranking, surface-jitter invariance and representation-space anomaly rollback detection.", "source": "Synthetic. Written for this pack." } }, { "slug": "example.world-state-jepa-receipt", "category": "noun.eval_run", "role": "example", "synthetic": true, "title": "Worked example output: recomputed counterfactual rollout and epistemic surprise receipt", "category_reason": "Synthetic receipt verified by test_world_state_jepa.py.", "value": { "conforms_to": { "$pin": "template.world-state-jepa-receipt" }, "instance": { "recommended_sequence_id": "plan-fenced-sanitized-clean", "feasible_sequence_count": 2, "best_goal_distance_energy": 0.0, "best_cumulative_risk_energy": 0.3925, "best_total_objective_energy": 0.3925, "clean_observation_energy": 0.0, "clean_observation_decision": "continue", "anomaly_case_count": 3, "anomaly_rollback_recall": 1.0, "max_anomaly_energy": 9.18778 }, "shows": "Recomputes trajectory ranking (rejecting unfenced tainted commits), 0.0 surprise under benign whitespace/timestamp jitter and 1.0 rollback recall across injected state anomalies.", "source": "Synthetic. Recomputed directly from example.world-state-jepa-bundle." }, "relations": [ [ "derives_from", "example.world-state-jepa-bundle" ], [ "verifies", "template.world-state-jepa-receipt" ] ] } ], "verbs": [ { "slug": "plan-counterfactual-rollout-trajectories", "kind": "verb.probe_source", "title": "Simulate K candidate multi-step action sequences in representation space and rank feasible plans", "claimant": "agent", "model_use": "none", "summary": "Encode initial environment observations into factored world states, predict multi-step transitions for K candidate sequences and rank invariant-preserving plans by goal distance plus cumulative risk energy.", "outcome": "Ranked counterfactual rollout table and minimum-energy feasible sequence recommendation.", "ready_outcome": "rollout_trajectories_ranked", "pinned": [ "spec.jepa-world-state-and-energy-grid", "rules.latent-transition-and-surprise-energy", "guardrail.simulate-invariants-before-irreversible-effects", "tool.world-state-jepa" ], "slots": [ { "name": "rollout_bundle", "category": "noun.eval_run", "description": "Pin of initial observation, target goal state and K candidate action sequences." } ], "produces": [ { "name": "rollout_plan_receipt", "template": "template.world-state-jepa-receipt" } ], "steps": [ "Encode raw environment observations into FactoredWorldState embeddings discarding surface timestamp and formatting noise.", "Simulate each candidate sequence through ActionConditionedStatePredictor and sort feasible plans ahead of invariant-violating plans by goal distance plus risk energy." ], "acceptance": [ { "id": "infeasible-plans-fenced-pre-execution", "check": "Trajectories that violate lease fencing, capability taint isolation, CAS monotonicity or non-negative quotas are marked infeasible and never recommended.", "method": "deterministic" } ] }, { "slug": "gate-step-by-epistemic-surprise-energy", "kind": "verb.generate_seed", "title": "Evaluate post-action representation-space surprise energy and trigger review or rollback on divergence", "claimant": "agent", "model_use": "none", "summary": "Compute factored and latent epistemic energy E(s_hat_{t+1}, s_obs_{t+1}) between predicted and observed post-action world states and gate execution against grid review and rollback thresholds.", "outcome": "Epistemic surprise energy breakdown and continue, require_review or trigger_rollback gate verdict.", "ready_outcome": "epistemic_surprise_gated", "pinned": [ "spec.jepa-world-state-and-energy-grid", "rules.latent-transition-and-surprise-energy", "guardrail.grid-governed-surprise-bounds-and-zero-magic-literals", "tool.world-state-jepa" ], "slots": [ { "name": "step_observation_bundle", "category": "noun.eval_run", "description": "Pin of executed action and observed post-action environment states." } ], "produces": [ { "name": "surprise_gate_receipt", "template": "template.world-state-jepa-receipt" } ], "steps": [ "Predict post-action world state s_hat_{t+1} and encode observed state s_obs_{t+1} into the shared representation space.", "Evaluate weighted quota, lease, digest, taint, invariant and latent L2 surprise energy against grid thresholds." ], "acceptance": [ { "id": "surface-jitter-invariance-and-anomaly-recall", "check": "Benign surface formatting jitter produces zero surprise energy while stolen leases, phantom CAS mutations and unpredicted taints trigger rollback.", "method": "deterministic" } ], "follows": [ "jepa-world-state-and-action-simulator.plan-counterfactual-rollout-trajectories" ] }, { "slug": "verify-world-state-simulator-receipt", "kind": "verb.verify_gate", "title": "Independently verify counterfactual rollout ranking, anomaly rollback recall and AST magic-literal gates", "claimant": "agent", "model_use": "none", "summary": "Recompute the worked rollout and anomaly receipt from input observations, verify schema conformance and run ZeroHardcodedValuesAstGate across world_state_jepa.", "outcome": "Independent deterministic verification receipt.", "ready_outcome": "world_state_simulator_verified", "review": "distinct_reviewer", "pinned": [ "spec.jepa-world-state-and-energy-grid", "guardrail.simulate-invariants-before-irreversible-effects", "guardrail.grid-governed-surprise-bounds-and-zero-magic-literals", "tool.world-state-jepa", "template.world-state-jepa-receipt" ], "slots": [ { "name": "simulator_eval_bundle", "category": "noun.eval_run", "description": "Pin of world-state simulator fixture bundle and candidate receipt." } ], "produces": [ { "name": "verified_simulator_receipt", "template": "template.world-state-jepa-receipt" } ], "steps": [ "Run world_state_jepa on the fixture bundle and compare every output field against template.world-state-jepa-receipt.", "Run scan_directory_for_hardcoded_values across world_state_jepa and confirm zero AST magic-literal violations." ], "acceptance": [ { "id": "ast-conformance-and-receipt-reproduction", "check": "scan_directory_for_hardcoded_values returns an empty list and run_bundle reproduces example.world-state-jepa-receipt identically.", "method": "deterministic" } ], "follows": [ "jepa-world-state-and-action-simulator.gate-step-by-epistemic-surprise-energy" ] } ] }