Skip to content

sharing 3/7: Policies (context → policy → policy_result → action) - #8407

Closed
keithharvey wants to merge 1 commit into
sharing/modes-economyfrom
sharing_policy_core
Closed

sharing 3/7: Policies (context → policy → policy_result → action)#8407
keithharvey wants to merge 1 commit into
sharing/modes-economyfrom
sharing_policy_core

Conversation

@keithharvey

@keithharvey keithharvey commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

📚 The sharing stack — review bottom-up

Note

Part of native stack #8411 (feature tracking: #8412). Merges bottom-up through the GitHub stacked-PR UI once the type-migration stack (#8398) is in.

Each PR is file-partitioned: every file appears in exactly one PR in its final sharing_tab form, so each PR's diff is byte-identical to that branch. Regenerated deterministically by just bar::sharing-split.

Summary (LLM-generated, claude-opus-4-6)

Adds the policy evaluation layer: ContextFactory builds a PolicyContext (team resources, alliance, cheating state, extensible via PolicyContextEnricher hooks), which feeds into CalcResourcePolicy / GetPolicy to produce a ResourcePolicyResult or UnitPolicyResult. Transfer actions (ResourceTransfer, UnitTransfer) consume those policy results to execute the actual engine calls. A per-team factor cache (CacheTeamFactor / UpdatePolicyCache) stores O(teams) records that GetCachedPolicyResult reconstructs into any sender-receiver pair on read, keeping the widget side in sync without O(pairs) storage. Unit validation (ValidateUnits) enforces sharing modes, blocks nanoframes of stun-category units, and tallies build-delay and stun counts. Tests cover resource and unit policies, the factor cache, and three concrete modes (enabled, disabled, easy_tax).

@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Integration Test Results

14 tests  ±0   6 ✅ ±0   3s ⏱️ ±0s
 1 suites ±0   8 💤 ±0 
 1 files   ±0   0 ❌ ±0 

Results for commit 854b356. ± Comparison against base commit a86685b.

♻️ This comment has been updated with latest results.

@keithharvey

Copy link
Copy Markdown
Collaborator Author

Superseded by the modules stack: sharing now ships as one de-noised PR — #8463 (modules — multiplayer 2/2: sharing v2), tracked in #8412. Closing this chain; the branch stays for reference.

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