Repository navigation
M7: LinkRestriction — link-provenance pre-send gate - #32
Merged
Merged
Conversation
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>
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.
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_violationfield +LinkRestriction(must equal false;freeze + escalate; priorityhigh— a tier below CredentialIntegrity'scritical). Validates clean.moltbook/detector.py—scan_links: provenance classificationsource/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 + latchlink_violation+ raiseLinkBlocked. 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 undermoltbook/traces/. It deliberately does not modifypi_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
sourcelink 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