No description
  • Go 97.9%
  • Dockerfile 1.5%
  • Makefile 0.6%
Find a file
zemdregon fa9984d304
Some checks are pending
CI / lint (push) Waiting to run
CI / test (push) Waiting to run
CI / build (push) Waiting to run
CI / docker (push) Blocked by required conditions
chore(deps): bump actions/setup-go to v7 (#25)
* chore(deps): bump actions/setup-go to v7

Self-hosted CI workflows.

* ci: setup-go v7 + cache false
2026-08-12 09:47:34 -05:00
.github chore(deps): bump actions/setup-go to v7 (#25) 2026-08-12 09:47:34 -05:00
cmd/module chore: align module with starter template and CI 2026-07-22 19:10:04 -05:00
deploy chore: align module with starter template and CI 2026-07-22 19:10:04 -05:00
internal Advertise settings capability (v0.2.2). 2026-08-10 04:37:17 -05:00
test refactor: align with muxcore-module-starter template 2026-06-12 11:49:55 -05:00
.dockerignore refactor: align with muxcore-module-starter template 2026-06-12 11:49:55 -05:00
.env.example chore: align module with starter template and CI 2026-07-22 19:10:04 -05:00
.gitignore chore: align module with starter template and CI 2026-07-22 19:10:04 -05:00
.golangci.yml ci: set explicit golangci-lint config version (#19) 2026-08-09 19:28:59 -05:00
CHANGELOG.md Advertise settings capability (v0.2.2). 2026-08-10 04:37:17 -05:00
COMPATIBILITY.md chore: align module with starter template and CI 2026-07-22 19:10:04 -05:00
CONTRIBUTING.md chore: align module with starter template and CI 2026-07-22 19:10:04 -05:00
Dockerfile chore(deps): bump alpine from 3.21 to 3.24 2026-07-01 11:10:30 +00:00
go.mod Expose policy_file and audit_path via RegisterSettings. 2026-08-10 03:02:11 -05:00
go.sum Expose policy_file and audit_path via RegisterSettings. 2026-08-10 03:02:11 -05:00
LICENSE chore: add LICENSE, SECURITY.md, CHANGELOG.md, CONTRIBUTING.md, COMPATIBILITY.md, .env.example, Makefile, .golangci.yml, Dockerfile, .dockerignore 2026-06-10 06:55:42 -05:00
Makefile chore: add LICENSE, SECURITY.md, CHANGELOG.md, CONTRIBUTING.md, COMPATIBILITY.md, .env.example, Makefile, .golangci.yml, Dockerfile, .dockerignore 2026-06-10 06:55:42 -05:00
muxcore.json Advertise settings capability (v0.2.2). 2026-08-10 04:37:17 -05:00
policies.yaml fix(policy): allow native torrent and automation download events (#17) 2026-08-07 16:48:01 -05:00
README.md feat: payload checks, rate limits, capability match, audit export (#20) 2026-08-09 20:58:28 -05:00
ROADMAP.md chore: align module with starter template and CI 2026-07-22 19:10:04 -05:00
SECURITY.md chore: add LICENSE, SECURITY.md, CHANGELOG.md, CONTRIBUTING.md, COMPATIBILITY.md, .env.example, Makefile, .golangci.yml, Dockerfile, .dockerignore 2026-06-10 06:55:42 -05:00

Publish Policy Default

Default event publication access control for MuxCore.

Without this module, every event publish is denied by default. Core's event bus refuses all bus.Publish() calls until a module implementing PublishPolicyProvider registers with capability "publish.policy".

How It Works

The module loads a static YAML policy (policies.yaml) that declares which callers may publish which event types. The event bus consults this module before delivering every publish.

Downloader publishes "download.completed"
        │
        ▼
MemoryBus.Publish()
        │
        ▼
publish-policy-default.CanPublish("downloader-qbittorrent", "download.completed")
        │
        ▼
  allowed? ───yes──→ deliver to subscribers
    │
   no
    │
    ▼
  return "publish denied" error

Configuration

Policy File (policies.yaml)

Rules are evaluated in order; the first match wins. If no rule matches, the publish is denied. caller: "*" matches any module. Event types support glob matching ("download.*", "media.*", "*").

# Allow a module to publish download-related events
- caller: "downloader-qbittorrent"
  event_types: ["download.*"]

# Allow any module to publish lifecycle events
- caller: "*"
  event_types: ["module.*", "cluster.*"]

# Development mode: allow all (uncomment only for local use)
# - caller: "*"
#   event_types: ["*"]

If the policy file is missing or invalid at startup, Init fails. Ship and maintain an explicit policies.yaml (the repo includes a starter file).

Environment

Variable Default Description
PUBLISH_POLICY_FILE policies.yaml Path to policy YAML file
MUXCORE_INSECURE_DISABLE_TLS unset Set to true for insecure mesh registration (dev)

Mesh registration also uses the module SDK (MUXCORE_GRPC_ADDR, MUXCORE_MODULE_ID, --muxcore-mesh-addr, --muxcore-module-id).

Advanced rules (v0.2+)

groups:
  downloaders:
    - downloader-qbittorrent
rules:
  - caller_group: downloaders
    event_types: ["download.*"]
    rate_limit_per_min: 120
    payload_max_bytes: 65536
    payload_require_keys: ["id"]
    required_capability: "download"   # event type capability.download* or payload.capability

Set PUBLISH_POLICY_AUDIT_PATH to append JSONL allow/deny records.

Hot-Reload

SIGHUP reloads the policy file without restarting the module.

Implementation

  • Registers with capability: "publish.policy"
  • Implements contracts.PublishPolicyProvider (gRPC PolicyService.AllowPublish)
  • Denied publishes are audited by core at bus enforcement (not via module AuditLogger); module keeps counters/slog
  • Registers grpc_health_v1 (SERVING) on the module gRPC server
  • Exposes metrics: publish_policy_allowed_total, publish_policy_denied_total