sharing 3/7: Policies (context → policy → policy_result → action) - #8407
Closed
keithharvey wants to merge 1 commit into
Closed
sharing 3/7: Policies (context → policy → policy_result → action)#8407keithharvey wants to merge 1 commit into
keithharvey wants to merge 1 commit into
Conversation
Contributor
This was referenced Jul 22, 2026
Closed
Closed
keithharvey
force-pushed
the
sharing_policy_core
branch
from
July 22, 2026 20:59
537d2a8 to
854b356
Compare
This was referenced Jul 22, 2026
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📚 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_tabform, so each PR's diff is byte-identical to that branch. Regenerated deterministically byjust bar::sharing-split.Summary (LLM-generated, claude-opus-4-6)
Adds the policy evaluation layer:
ContextFactorybuilds aPolicyContext(team resources, alliance, cheating state, extensible viaPolicyContextEnricherhooks), which feeds intoCalcResourcePolicy/GetPolicyto produce aResourcePolicyResultorUnitPolicyResult. 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 thatGetCachedPolicyResultreconstructs 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).