{"record":{"id":"86acff7f9bd52bbb","repo":"HKUDS/Vibe-Trading","slug":"goal-is-not-available-for-this-session","errorCode":null,"errorMessage":"goal is not available for this session","messagePattern":"goal is not available for this session","errorType":"validation","errorClass":"StaleGoalError","httpStatus":null,"severity":"error","filePath":"agent/src/goal/store.py","lineNumber":837,"sourceCode":"\n        updated = self.get_goal(goal_id)\n        if updated is None:\n            raise RuntimeError(\"usage-updated goal could not be reloaded\")\n        return updated\n\n    def _require_mutable_goal(\n        self,\n        session_id: str,\n        goal_id: str,\n        expected_goal_id: str,\n    ) -> GoalRecord:\n        if expected_goal_id != goal_id:\n            raise StaleGoalError(\"expected_goal_id does not match target goal\")\n        session_id = normalize_required_text(session_id, \"session_id\")\n        goal_id = normalize_required_text(goal_id, \"goal_id\")\n        goal = self.get_goal(goal_id)\n        if goal is None or goal.session_id != session_id:\n            raise StaleGoalError(\"goal is not available for this session\")\n        if goal.status not in _CURRENT_STATUSES:\n            raise StaleGoalError(f\"goal status {goal.status.value!r} is not mutable\")\n        current = self.get_current_goal(session_id)\n        if current is None or current.goal_id != goal_id:\n            raise StaleGoalError(\"goal is not current for this session\")\n        return goal\n\n    @staticmethod\n    def _verification_status(evidence: EvidenceInput) -> str:\n        \"\"\"Return whether evidence has a traceable local artifact/run source.\"\"\"\n        if evidence.artifact_path:\n            try:\n                artifact = safe_document_path(evidence.artifact_path)\n            except ValueError:\n                artifact = None\n            if artifact and artifact.is_file():\n                if GoalStore._artifact_hash_matches(artifact, evidence.artifact_hash):\n                    return \"verified\"","sourceCodeStart":819,"sourceCodeEnd":855,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/goal/store.py#L819-L855","documentation":"The goal id does not exist, or it belongs to a different session than the session_id supplied. _require_mutable_goal looks up the goal and verifies goal.session_id == session_id before allowing mutation.","triggerScenarios":"Passing a goal_id from another session to update_goal/append_evidence/update_status/account_usage, or a goal_id that was deleted or never created.","commonSituations":"Session id regenerated mid-run; ids swapped in logs or fixtures; test using mismatched seeded session/goal pairs.","solutions":["Verify the pair with get_goal(goal_id) and compare .session_id before mutating","Regenerate/lookup the correct session_id for the goal (e.g. from the session record)","If the goal is gone, create a new goal instead of mutating the dead id"],"exampleFix":"// before\nstore.append_evidence(session_id=\"sess-a\", goal_id=\"goal-from-b\", ...)\n// after\ngoal = store.get_goal(goal_id)\nif goal is None or goal.session_id != session_id:\n    goal = store.create_goal(session_id=session_id, ...)\nstore.append_evidence(session_id, goal.goal_id, ...)","handlingStrategy":"validation","validationCode":"goal = store.get_goal(goal_id)\nif goal is None or goal.session_id != session_id:\n    raise LookupError(\"goal/session mismatch before mutation\")","typeGuard":"def goal_belongs_to_session(goal, session_id: str) -> bool:\n    return goal is not None and goal.session_id == session_id","tryCatchPattern":"except StaleGoalError as e: if 'not available' in str(e): re-resolve session/goal pair or create a new goal","preventionTips":["Never mix ids across sessions; source both from the same session context","Log goal.session_id alongside goal_id in traces","Seed tests with matched session/goal fixtures"],"tags":["goal-store","wrong-session","entity-not-found","python"],"backgroundTag":"entity-ownership-mismatch","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}