Skip to content

M7: LinkRestriction — link-provenance pre-send gate - #32

Merged
GodSpeed313 merged 1 commit into
mainfrom
feature/m7-link-restriction
Jul 16, 2026
Merged

GodSpeed313 merged 1 commit into
mainfrom
feature/m7-link-restriction

Conversation

@GodSpeed313

Copy link
Copy Markdown
Owner

Implements the M7 LinkRestriction constraint, spec-first, per docs/m7_link_restriction_ruling.md (LOCKED). Second M7 constraint, after CredentialIntegrity (#31).

The rule

The agent may surface an external link only if it's (a) present in the source content it's responding to/citing, or (b) on a static, human-owned allowlist. Any novel URL — constructed, assembled from fragments, shortened/redirect, or suggested by another agent — is a violation. This is a provenance check, not payload inspection: the gate never fetches a link or judges whether it's malicious, only whether the agent had legitimate grounds to surface it.

Why

The recon notes flagged coordinated link-seeding as a live Moltbook pattern (the pyclaw/Ting_Fodder self-citation trail). v1 draws the defensible line at provenance and deliberately does not try to judge seeding chains (that's future ManipulationFlag v1.1/v2) — but it leaves the trail that later work needs.

What's here

  • moltbook/moltbook.pi — link_violation field + LinkRestriction (must equal false; freeze + escalate; priority high — a tier below CredentialIntegrity's critical). Validates clean.
  • moltbook/detector.py — scan_links: provenance classification source/allowlist/novel, subdomain-aware, catches shortened + fragment-assembled URLs.
  • moltbook/link_allowlist.json (Q1) — static, human-owned, editable only via commit/PR. Loaded as an immutable tuple with no runtime mutation path — an agent that could expand its own allowlist would defeat the constraint, same principle as key isolation.
  • moltbook/client.py — send() runs both gates (credential → links). Novel links block + latch link_violation + raise LinkBlocked. Every surfaced link is logged (Q2) regardless of outcome.

Reshare logging is moltbook-local (Q2)

The provenance log lives on the client (link_provenance_records()) for attachment to the M7 trace under moltbook/traces/. It deliberately does not modify pi_script/trace.py — core trace is shared by link-less systems (m5/es/quantization), and this is client/adapter-layer concern, consistent with the CredentialIntegrity prevention-is-client-side / Pi-Script-is-the-latch split.

Tests

20 new: required violation/clean pair, detector provenance cases, gate behavior, end-to-end block→freeze, plus the two decision-specific tests — reshare-logging (a passed source link is still logged) and allowlist-immutability (tuple, no mutation method). Updated the CredentialIntegrity enforce assertion for the now-two-constraint block.

Full suite: 315 passed, 3 xfailed.

Not in scope (by ruling)

Judging whether a link is malicious, and detecting coordinated seeding chains — future LinkRestriction v1.1 / ManipulationFlag v1.1+. IdentityIntegrity and ManipulationFlag still need their own rulings.

🤖 Generated with Claude Code

Spec-first ruling docs/m7_link_restriction_ruling.md (LOCKED), then the
implementation, following the CredentialIntegrity pattern:

- moltbook/moltbook.pi — link_violation field + LinkRestriction (must equal
  false; freeze + escalate; priority high — a tier below CredentialIntegrity's
  critical, a link is not an irreversibly-exploitable key). Joined enforce;
  arbiter never_acceptable gains link_allowlist_self_modification.
- moltbook/detector.py — scan_links: pure provenance classification
  (source / allowlist / novel), never fetches or judges the destination. novel
  catches shortened/redirect and fragment-assembled URLs; subdomain matches allow.
- moltbook/link_allowlist.json — static, human-owned allowlist (Q1). Loaded as an
  immutable tuple; the running agent has no runtime mutation path (key-isolation
  principle: an agent that could expand its own allowlist defeats the constraint).
- moltbook/client.py — send() runs both gates (credential first, then links).
  Novel links block + latch link_violation + raise LinkBlocked. Every surfaced
  link is logged via link_provenance_records() regardless of outcome (Q2) — kept
  moltbook-local, NOT a core pi_script/trace.py change (shared by link-less
  systems; client/adapter-layer concern per the CredentialIntegrity split).
- tests — violation/clean pair, detector provenance cases, gate behavior,
  end-to-end block->freeze, reshare-logging, allowlist-immutability. Updated the
  CredentialIntegrity enforce assertion for the now-two-constraint block.

Full suite: 315 passed, 3 xfailed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@GodSpeed313
GodSpeed313 merged commit a3a5be6 into main Jul 16, 2026
2 checks passed
@GodSpeed313
GodSpeed313 deleted the feature/m7-link-restriction branch July 16, 2026 17:42
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