Skip to content

Give hub tax and supply hubs their own law settings - #95

Merged
Drefvelin merged 1 commit into
mainfrom
feat/hub-tax-bracket
Oct 1, 2026
Merged

Drefvelin merged 1 commit into
mainfrom
feat/hub-tax-bracket

Conversation

@Drefvelin

Copy link
Copy Markdown
Contributor

Hub tax borrowed the tariff bracket and the tariff rule. Free Trade and Decentralized switch tariffs off, so they forced hub tax to zero, and a host had no reason to accept foreign hubs. This gives hub tax, and supply hubs, their own settings in the economy laws.

Economy laws

Law Hub tax Supply hubs
Decentralized cannot collect (hub_tax false) guilds cannot build (supply_hubs false)
Free Trade 0-10% allowed
Mercantilism 0-25% allowed
Protectionism 0-40% allowed
Isolationism 0-50% allowed

What changes

  • New bracket hub_tax and new rules "Can Collect Hub Taxes" and "Can Build Supply Hubs", shown in law lore like the existing ones.
  • Hub tax no longer reads the tariff bracket or rule anywhere: limits, permission, the tax menu, proposals and previews all use its own.
  • A guild whose faction cannot build supply hubs is refused at /guild hub build. Hubs it already has are dormant (still costing upkeep and holding their slot), through the same active/dormant decision used by the network, the hub list, the menus and the tax assessment.
  • The rule is about the guild's own faction. Other factions' guilds can still build at a Decentralized nation's installations; that host collects no hub tax.
  • When a law change narrows the bracket or forbids hub tax, a saved rate is pulled down, to zero when forbidden.
  • A law preview uses the proposed law's bracket and rules, and drops a guild's links when the proposed law would make its hubs dormant.
  • supply-hubs.max-tax still caps the rate.

Old laws.yml

A server whose laws.yml has none of the new keys treats both rules as allowed and uses a 0-10% bracket, so nothing breaks. The new lines need adding to that file for Decentralized to be restricted and for the higher brackets.

Testing

mvn verify: 2498 tests, 0 failures. New tests cover each law's settings from the bundled file, the old-file defaults, the cap, rates pulled down or zeroed on a law change, a Decentralized guild refused and its hubs dormant, the preview, and tariffs unchanged.

🤖 Generated with Claude Code

Hub tax borrowed the tariff bracket and rule, so Free Trade and
Decentralized, which switch tariffs off, forced it to zero. It now has
its own bracket, set by each economy law: Free Trade 0-10%, Mercantilism
0-25%, Protectionism 0-40%, Isolationism 0-50%.

Decentralized gets two new rules instead: it cannot collect hub taxes,
and its guilds cannot build supply hubs. Hubs such a guild already has
go dormant.

With a laws.yml that predates this, every faction can build hubs and
charge up to 10%.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 61fce28f-9e36-4857-92e5-85583f4c5c80

📥 Commits

Reviewing files that changed from the base of the PR and between 567b8b9 and 5b634c6.

📒 Files selected for processing (21)
  • src/main/java/net/tfminecraft/simplefactions/enums/Brackets.java
  • src/main/java/net/tfminecraft/simplefactions/enums/Rules.java
  • src/main/java/net/tfminecraft/simplefactions/guild/hub/HubNetwork.java
  • src/main/java/net/tfminecraft/simplefactions/guild/hub/HubTaxService.java
  • src/main/java/net/tfminecraft/simplefactions/guild/hub/SupplyHubCommands.java
  • src/main/java/net/tfminecraft/simplefactions/guild/hub/SupplyHubService.java
  • src/main/java/net/tfminecraft/simplefactions/guild/income/IncomePreviewContext.java
  • src/main/java/net/tfminecraft/simplefactions/guild/income/Ledger.java
  • src/main/java/net/tfminecraft/simplefactions/laws/LawEffect.java
  • src/main/java/net/tfminecraft/simplefactions/managers/inventory/SupplyHubView.java
  • src/main/java/net/tfminecraft/simplefactions/objects/Faction.java
  • src/main/java/net/tfminecraft/simplefactions/objects/handler/TaxHandler.java
  • src/main/java/net/tfminecraft/simplefactions/utils/BracketToTaxTarget.java
  • src/main/resources/laws.yml
  • src/test/java/net/tfminecraft/simplefactions/guild/hub/HubTaxServiceTest.java
  • src/test/java/net/tfminecraft/simplefactions/guild/hub/SupplyHubServiceTest.java
  • src/test/java/net/tfminecraft/simplefactions/guild/income/BranchIncomePreviewTest.java
  • src/test/java/net/tfminecraft/simplefactions/guild/income/LedgerHubTaxTest.java
  • src/test/java/net/tfminecraft/simplefactions/laws/HubLawTest.java
  • src/test/java/net/tfminecraft/simplefactions/managers/ProvinceManagerHubTransportTest.java
  • src/test/java/net/tfminecraft/simplefactions/objects/handler/TaxHandlerHubTaxTest.java

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Summary

Summary by CodeRabbit

  • New Features
    • Added separate rules for collecting hub taxes and building supply hubs. Economy laws can now set hub-tax brackets independently of tariffs.
    • Supply hubs are restricted when the applicable rule is disabled. Hub taxes and supply-hub trade reflect current rules, including during law previews.
    • Hub status now accounts for economy restrictions and guild limits.

Walkthrough

The changes separate hub-tax and supply-hub rules from tariff rules. They add law-aware tax bracket and rule evaluation, apply supply-hub rules to construction, standing and transport, and add tests for these behaviours.

Changes

Hub Economy Rules

Layer / File(s) Summary
Hub-tax rules and brackets
src/main/java/net/tfminecraft/simplefactions/enums/*, src/main/java/net/tfminecraft/simplefactions/objects/handler/TaxHandler.java, src/main/java/net/tfminecraft/simplefactions/utils/BracketToTaxTarget.java, src/main/java/net/tfminecraft/simplefactions/laws/LawEffect.java, src/main/resources/laws.yml, src/test/java/net/tfminecraft/simplefactions/objects/handler/TaxHandlerHubTaxTest.java
Hub tax has its own rule, bracket and default maximum of 10. Tariff brackets no longer set hub-tax rates. Economy laws and tests include the hub-tax settings.
Law application and tax previews
src/main/java/net/tfminecraft/simplefactions/objects/Faction.java, src/main/java/net/tfminecraft/simplefactions/guild/income/*, src/test/java/net/tfminecraft/simplefactions/laws/HubLawTest.java, src/test/java/net/tfminecraft/simplefactions/guild/income/*
Law application refreshes the hub-tax bracket. Preview contexts resolve hub-tax rules and brackets, and the ledger filters payable hub taxes by supply-hub and hub-tax rules.
Supply-hub rule enforcement
src/main/java/net/tfminecraft/simplefactions/guild/hub/*, src/main/java/net/tfminecraft/simplefactions/managers/inventory/SupplyHubView.java, src/test/java/net/tfminecraft/simplefactions/guild/hub/*, src/test/java/net/tfminecraft/simplefactions/managers/ProvinceManagerHubTransportTest.java
Construction is denied when the guild does not allow supply hubs. Hub standing and cached links also evaluate the rule. Tests cover dormant hubs and law-preview effects on transport.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Suggested reviewers: ryanbarlow97

Merge Risk: ⚪ Minimal · up to 5b634

No concrete merge-blocking issue was identified. Valid saved hub-tax rates survive restoration, and dormant hubs are excluded before live payments. The change is mergeable subject to normal checks.

Security Architecture Review

Security architecture risk: 🟡 Moderate · up to 5b634

Normal execution preserves guild-leader and host-permission checks. However, if daily recalculation fails, an older hub-tax assessment can still be paid after a law disables the payer’s hubs. This creates a conditional in-game financial-integrity risk; no attacker-triggered exploit was established.

Retained concerns

  • Medium · security · inferred: If daily link or tax refresh fails after a law disables supply hubs, settlement can consume an older assessment. Refresh publishes results per guild, daily-step failures do not prevent settlement, and the terminal payment decision checks the host’s current tax permission but checks the payer’s supply-hub permission only during a law preview. This leaves the new dormancy policy dependent on successful upstream refresh rather than enforced throughout recovery.
Security review details

Security Blast Radius

  • inferred — The demonstrated sensitive outcome is movement between in-game guild finances. A failure in the shared assessment loop can leave older results for the failing guild and guilds not yet refreshed, so the recovery exposure is not necessarily confined to one guild. No evidence establishes broader credential, infrastructure or external-service compromise.

Security Findings and Attack Paths

  • inferred — The conditional policy-violation path requires a stored positive assessment, a subsequent law that disables the payer’s hubs, and failure of the daily refresh before replacing that assessment. Settlement can then enqueue the old payment because live payable evaluation lacks the payer-policy check. Successful refresh breaks this path. Neither an attacker-controlled failure trigger nor a verified exploit was established.

Trust Boundaries and Controls

  • observed — Player-controlled build requests resolve the player’s guild and check leadership before policy and site validation. Host permission is evaluated separately before mutation. Law-preview rule evaluation substitutes the proposed law for its group while retaining other current laws and the applicable overlord fallback.

Resilience and Maintainability Implications

  • observed — Live network refresh requires the live province manager and the primary server thread; the regular faction timer is synchronous. This limits ordinary concurrent cache mutation. Normal recalculation rebuilds links after re-enabling hubs, so absence of a direct refresh inside applyLaw does not by itself establish a stranded recovery state.

Hardening Proposals

  • proposed — Enforce the payer’s current supply-hub eligibility at the terminal payment decision, and make assessment freshness explicit so a failed refresh cannot silently authorize settlement from an earlier policy state.
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Comment @coderabbitai help to get the list of available commands.

@Drefvelin
Drefvelin merged commit 5b43126 into main Oct 1, 2026
2 checks passed
@Drefvelin
Drefvelin deleted the feat/hub-tax-bracket branch October 1, 2026 14:17
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.

2 participants