feat: add offline agent policy report RPCs#233
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 17595f7a43
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "Codex (@codex) review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "Codex (@codex) address that feedback".
| if (!profile || profile === "observe_and_keep_safe" || profile === "safe_patrol") { | ||
| return "safe"; | ||
| } | ||
| throw new Error("offline agent policy profile is not allowed"); |
There was a problem hiding this comment.
Accept legacy policy modes when normalizing stored policy
The new normalizeOfflineAgentPolicyProfile throws for any profile string outside safe|balanced|risky (plus two aliases), but normalizePolicy now derives policy_profile from existing policy.mode. Before this commit, normalizePolicy accepted arbitrary mode values, so older user records can legitimately contain other mode strings (for example written through historical secondspawn_soul_update calls). After this change, loading those records will fail with offline agent policy profile is not allowed, which can break context hydration and make multiple RPCs unusable for affected accounts unless a backward-compatible fallback or migration path is added.
Useful? React with 👍 / 👎.
| var activities = boundAgentReturnActivities(context.body.agent_activity || [], request.limit || 8); | ||
| var entries = boundGameplayLedgerEntries(ledger.entries || [], request.limit || 8, userId); | ||
| var summary = summarizeAgentReturnReport(context, activities, entries); |
There was a problem hiding this comment.
Build return report from server-validated activity sources
secondspawn_agent_return_report is presented as server-owned reporting, but it reads directly from context.body.agent_activity and gameplay ledger rows that can be written from the client RPC secondspawn_agent_activity_add (which accepts client-provided summary and metrics). This lets a client fabricate offline outcomes in the returned report (attempt counts, fallback/model mix, reward deltas) without any authoritative validation path, violating the stated “not client-generated fiction” boundary for this feature.
Useful? React with 👍 / 👎.
Summary
Verification
npm.cmd run buildinbackend/nakamanpm.cmd testinbackend/nakamaafter buildnpx.cmd markdownlint-cli2 "CHANGELOG.md" "docs/adr/0012-nakama-rpc-boundaries.md" "docs/design/45-alpha-backlog-execution-packets.md"git diff --checkLocal review fallback
Covers the backend slice of #149. Unity UI wiring remains for the player-facing policy panel and report screen.