Skip to content

feat: add offline agent policy report RPCs#233

Merged
JOY (JOY) merged 1 commit into
devfrom
codex/offline-agent-policy-report
May 24, 2026
Merged

feat: add offline agent policy report RPCs#233
JOY (JOY) merged 1 commit into
devfrom
codex/offline-agent-policy-report

Conversation

@JOY
Copy link
Copy Markdown
Contributor

Summary

  • add client-bound Nakama RPCs for offline-agent policy updates and return reports
  • support safe, balanced, and risky policy profiles with low-BodyTime override and dead-body rejection
  • keep high-risk Gate entry disabled server-side until explicit policy support exists
  • build return reports from stored agent activity plus gameplay ledger rows, not client-generated fiction
  • update ADR 0012 and the alpha backlog packet for the new RPC boundary

Verification

  • npm.cmd run build in backend/nakama
  • npm.cmd test in backend/nakama after build
  • npx.cmd markdownlint-cli2 "CHANGELOG.md" "docs/adr/0012-nakama-rpc-boundaries.md" "docs/design/45-alpha-backlog-execution-packets.md"
  • git diff --check

Local review fallback

  • APPROVED: Nakama owns policy persistence and report data; no Unity package/scene changes; high-risk Gate is fail-closed; LLM output remains non-authoritative.

Covers the backend slice of #149. Unity UI wiring remains for the player-facing policy panel and report screen.

@JOY JOY (JOY) merged commit be85e55 into dev May 24, 2026
2 checks passed
@JOY JOY (JOY) deleted the codex/offline-agent-policy-report branch May 24, 2026 20:55
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +10868 to +10871
if (!profile || profile === "observe_and_keep_safe" || profile === "safe_patrol") {
return "safe";
}
throw new Error("offline agent policy profile is not allowed");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment on lines +1231 to +1233
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);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant