Commit graph

242 commits

Author SHA1 Message Date
af3132930d Fix view decorators missing functools.wraps
The super_fly_required decorator was missing functools.wraps, causing
Pyramid to fail to properly register topsecret views. Added wraps to
all three view decorators for consistency.
2026-02-05 12:41:36 -05:00
89644d2117 Fix embed overflow: add box-sizing border-box with padding
Padding without border-box caused content to overflow the iframe
since body has min-width: 100%.
2026-02-02 15:38:21 -05:00
a6ee451069 Add horizontal padding to embed mode body
Prevents content from sitting flush against the iframe edges.
2026-02-02 15:22:27 -05:00
3579c89d4c Replace AI with machine learning in UI labels, docs, and CLAUDE.md 2026-02-02 15:17:59 -05:00
timehexon
6916c92333 Replace "AI" with "machine learning" in CLAUDE.md
Machine learning is what we grow. "AI" is forbidden in all
permacomputer discourse, marketing, & documentation.
2026-02-02 19:57:12 +00:00
82316fb8f7 Fix spam_held reference in thread_uri code path after rebase 2026-02-02 14:14:48 -05:00
070a6b678d Add spam moderation UI, node spam fields, and namespace spam toggle
- spam_score and spam_reason columns on Node model (alembic migration)
- spam_filter_enabled column on Namespace (owners can disable Hermes)
- check_spam always returns full result dict with score/signals/reason
- Spam data stored on every node for moderation display
- "(spam)" label on flagged nodes with hover showing Hermes explanation
- Spam moderation page at /ns/{namespace}/nodes?spam with bulk actions
- Bulk approve/disable for spam nodes with checkboxes
- Hermes reason shown prominently on spam page for each flagged node
- Namespace settings checkbox: "Enable Spam Filter (Hermes AI)"
- Namespace.spam_filter_enabled respected by LLM check gate
- spam_nodes property on Namespace for querying flagged nodes
- Unit tests for spam scoring, LLM mocked tests, live Hermes integration
  tests covering embed mode, site mode, edge cases (44 new tests)
2026-02-02 14:13:47 -05:00
timehexon
5042a7d9f1 Use embed-identical root node creation when thread_uri is provided
When thread_uri is given to POST /api/v1/threads, the API now uses
get_or_create_node_by_uri (same as the embed iframe) to create the
root node, then posts the comment as a child reply. This ensures
threads created via the API are structurally identical to those
created by the embed, so the iframe can find and display them.

Without thread_uri, behavior is unchanged (standalone root node).
2026-02-02 18:47:38 +00:00
timehexon
a3e6c0b046 Fix failing API tests after namespace validation change
- Add trailing slash to URI lookup in test_create_thread_with_uri
  to match how get_or_create_uri stores the URL
- Create localhost namespace in TestAPIAuthenticatedEditing.setUp
  since api_create_thread no longer auto-creates namespaces
2026-02-02 18:29:51 +00:00
timehexon
bc751728f5 Link thread_uri to root node in POST /api/v1/threads
The API was creating orphan root nodes with no Uri record, so
the embed iframe could never find them. Now when thread_uri is
provided, a Uri record is created and linked to the node — same
association the embed uses via get_or_create_node_by_uri.

Returns 409 if a thread already exists for the given URI.
2026-02-02 18:22:41 +00:00
timehexon
df3f3d231e Reject thread creation on nonexistent namespaces
POST /api/v1/threads now returns 404 if the namespace doesn't already
exist, instead of auto-creating it. Prevents phantom namespaces from
accumulating when callers mistype the namespace name.

get_or_create_namespace is still used for read-only endpoints (GET)
where lazy creation is acceptable.
2026-02-02 18:04:53 +00:00
66964f736a Add spam prevention, superuser system, and LLM relevance checking
- Thread creation rate limit: 1 per 7 min per user/IP via API
- is_superuser column on User model with alembic migration
- Superusers bypass namespace-scoped is_moderator() checks
- super_fly_required now checks is_superuser instead of hardcoded names
- /topsecret/users admin page to promote/demote superusers
- Spam scoring module with 6 signals (link density, patterns, duplicates,
  new account velocity, IP reputation, content length)
- Hard threshold (0.8) rejects, soft threshold (0.5) holds for moderation
- LLM relevance checking via Hermes (hermes.ai.unturf.com) on every
  message when enabled, including embed mode parent page URL context
- Admin API endpoints: GET /api/v1/admin/namespaces, recent-nodes
- Spam hunting scripts: scan.py, disable_spam.py, promote_superuser.py
- Updated Python client with admin methods
2026-02-02 09:19:16 -05:00
8d836dae34 Make Alembic migrations idempotent for SQLite
Check if columns/tables exist before adding them so migrations
don't fail on re-run when schema was applied out of band.
2026-02-02 08:31:36 -05:00
b6739fff70 Fix thread search suggestions: navigate on click, fix duplicate ID
- Add explicit click handler on suggestions so clicking navigates
  to the existing thread instead of interacting with the form
- Fix duplicate id="thread_title_input" in forms.j2 edit macro
  (renamed to edit_title_input to avoid conflict with create form)
2026-02-02 08:13:05 -05:00
c038b649b2 Fix thread search: strip stop words, use OR matching for keywords
"Do you have an API?" now correctly matches "API testing journey"
by stripping stop words (do, you, have, an) and punctuation, then
matching remaining keywords with OR logic across titles and content.
2026-02-02 08:02:02 -05:00
165aff32e2 Improve thread search to keyword matching across titles and content
Search now splits query into keywords and matches each against both
title and data fields (not just title prefix). Also searches child
node content and returns parent threads for matches.
2026-02-01 21:52:31 -05:00
c93647e2b7 Resolve @mentions in markdown preview endpoint
Pass dbsession to markdown_to_html so @username mentions are
converted to profile links during live preview, not just on save.
2026-02-01 21:44:43 -05:00
8260897aeb Add node moderation API endpoints and enforce production rules
- PATCH /api/v1/nodes/{id} now accepts disabled, approved, locked fields
- DELETE /api/v1/nodes/{id} for permanent deletion (moderator only)
- Python client: disable_node, enable_node, approve_node, lock_node,
  unlock_node, delete_node methods plus CLI commands
- CLAUDE.md: production rules forbidding direct SQL, mandate API client
- Fix modify_node.py Python 2 remnants (unicode, raw_input)
2026-02-01 21:23:37 -05:00
c530e0f9dc Fix empty active nodes page: namespace filter now includes root nodes
Root nodes have root_id=NULL, so the IN subquery missed them entirely.
Added OR clause to also match nodes by namespace_id directly.
2026-02-01 21:06:05 -05:00
44e9fe94d2 Add missing Alembic migration for user push columns and webmention table
The previous commit added notification_preference and push_subscriptions
columns to rb_user and a new rb_webmention table without migrations,
causing 502 on production.
2026-02-01 20:46:55 -05:00
f1cffe2e79 Resolve all 14 tracked tickets (T0-T13)
High priority fixes:
- T0: Profile page now filters comments by namespace (was leaking cross-site)
- T1: URI hostnames and namespace names normalized to lowercase (was causing
  duplicate threads and "stock comments" bug). Includes merge script.
- T2: Thread detail API now paginated with SQL-side filtering (was 502 on
  267+ reply threads)

Features:
- T3: GDPR account deletion (tombstone user with scrubbed PII) and data export
- T4: Customizable button text and comment labels per namespace
- T5: Self-service namespace deletion for owners
- T6: @mention notifications with profile links
- T7: Webmention receiving endpoint with h-card extraction
- T8: Configurable max nesting depth and collapse depth per namespace
- T9: AJAX thread title search to prevent duplicates
- T10: Browser push notification support (VAPID/service worker)

Docs and housekeeping:
- T11: Documented thread_uri behavior when moving embeds
- T12/T13: Drafted community replies for resolved feature requests
- Collapse depth defaults to infinite (load-more disabled unless configured)

364 tests pass, 4 skipped.
2026-02-01 20:02:47 -05:00
c5823c62ac Update functional test to preserve journey thread narrative
Instead of overwriting the thread body with raw test data,
the test now only updates the "Latest: X/Y passed" line.
The narrative content stays as written.
2026-02-01 17:39:13 -05:00
0ea91d6859 Fix commit-hash.txt placement: copy into env before creating tarball 2026-02-01 17:17:00 -05:00
4f60f6fbed Fix version endpoint to read commit-hash.txt from CI build
The deploy environment has no .git directory. Now reads
commit-hash.txt (written by CI) from the virtualenv, repo
root, or /opt/remarkbox before falling back to git rev-parse.
CI build step now copies commit-hash.txt into the virtualenv.
2026-02-01 16:57:19 -05:00
f0e365fd43 Add GET /api/v1/version endpoint for deploy verification
Returns the git commit hash of the running code. CLAUDE.md
updated to check this endpoint after pushing to confirm
deployment is live.
2026-02-01 16:44:42 -05:00
5a10e155bd Add Python client, profile endpoint, and functional test
- remarkbox_client.py: stdlib-only Python client with cookie
  persistence, 3-tier config (args/env/file), CLI mode
- GET/PATCH /api/v1/user/profile: read and update display name
- GET /api/v1/clients/python: serve client for curl/wget download
- functional_test.py: idempotent live test that maintains a
  journey thread documenting each run
- Remove email2 spam honeypot from API (not useful for agents)
- Bump content limit to 500k chars (~128k tokens)
2026-02-01 16:39:19 -05:00
9d59a3ca8a Add JSON API for agent access (/api/v1/)
REST API with endpoints for threads, replies, nodes, and email OTP
authentication. Includes in-memory sliding-window rate limiting,
global api.enabled INI kill-switch, per-namespace api_access opt-out
with settings UI checkbox, and 500k character content limit (~128k
tokens) for long-form agent content. Ships enabled by default.
2026-02-01 14:49:01 -05:00
8666e97721 Only show Comments header in site mode, not embed mode 2026-01-29 09:40:00 -05:00
b39e5dd55d Add Comments section header to distinguish from main content 2026-01-29 09:38:15 -05:00
3ac6cbee50 Add margin-top to reply form for spacing from content 2026-01-29 09:36:26 -05:00
4d8d77c9b8 Add postmortem for duplicate email accounts issue 2026-01-29 09:32:22 -05:00
cc968f6c5f Enable remarkbox-theme-meta dependency for deployment 2026-01-29 09:16:15 -05:00
8d838dbcba Fix merge script to handle duplicate namespace/watcher constraints 2026-01-29 09:15:33 -05:00
8b4d0bdeb6 Add GitLab pipeline status check to CLAUDE.md 2026-01-29 09:12:04 -05:00
9330782999 Fix case-sensitive email duplicates and add merge script
- Normalize emails to lowercase on user creation
- Use case-insensitive lookup in get_user_by_email
- Add merge_duplicate_email_users script to merge existing duplicates
- Add unit and integration tests to prevent regression
- Update CLAUDE.md with tmux-hosts production troubleshooting
2026-01-29 08:33:35 -05:00
df5c656eb0 Add whitespace between thread and new message form 2026-01-29 07:31:01 -05:00
32b1eae840 Fix getElementById('') warning when no hash fragment present 2026-01-28 07:50:45 -05:00
8971a46659 Hide preview toggle when JavaScript is disabled 2026-01-24 08:35:35 -05:00
67648f06f9 Persist preview visibility state in localStorage 2026-01-24 08:04:37 -05:00
2f8e676f78 Add template syntax validation tests
Validates all Jinja2 templates can be parsed without syntax errors.
Catches issues like mismatched {% if %}/{% endif %} blocks before deployment.
2026-01-22 12:48:02 -05:00
a49446cfef Add parallel test execution with pytest-xdist
Implements per-worker database isolation for parallel test runs:
- Add pytest-xdist and pytest-cov to test dependencies
- Configure Makefile to run tests with -n auto flag
- Update test.ini to use environment variable for database path
- Create conftest.py with per-worker database isolation
- Enable SQLite WAL mode for better concurrency
- Auto-cleanup test databases after completion

Expected performance improvement similar to make_post_sell (~16x speedup).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-21 12:36:31 -05:00
06ba106795 Fix sitemap lastmod date format for Google 2026-01-11 09:28:59 -05:00
a6c04d565a Add google_site_verification support for namespaces
- Add google_site_verification column to rb_namespace table
- Add settings form field in Stand-alone Mode Settings
- Render meta tag on root path when set
- Update CLAUDE.md with Alembic migration workflow
- Fix development.ini alembic paths
2026-01-11 09:11:07 -05:00
9936b21467 Add twine-venv target in /tmp for PyPI uploads
Uses a persistent virtualenv in /tmp/twine-venv to avoid
relying on system python/twine in CI.
2025-12-29 09:35:08 -05:00
00edd84398 Update .gitlab-ci.yml file 2025-12-29 14:31:53 +00:00
a362190ea5 Update .gitlab-ci.yml 2025-12-29 14:29:28 +00:00
033fe1f1a7 Update setup.py 2025-12-29 14:26:10 +00:00
43f794e385 Merge branch 'anonymous' into 'main'
Add allow_anonymous namespace setting for email-free commenting

See merge request engineering/remarkbox/remarkbox!29
2025-12-20 16:26:51 +00:00
6b2be261f5 Add functional tests for anonymous commenting feature
Tests cover:
- Anonymous reply creates UserSurrogate
- Anonymous reply with no name defaults to 'Anonymous'
- Regular namespace still requires email
- Anonymous comments are marked as verified
- Namespace settings toggle for allow_anonymous
2025-12-20 11:17:12 -05:00
19415fff06 Add allow_anonymous namespace setting for email-free commenting
When enabled, commenters can post with just a display name (no email required).
Comments are attached to UserSurrogate instead of User.

Trade-offs for anonymous commenters:
- No email notifications for replies
- Cannot edit their comments
- Cannot log in to manage comments
- No cross-site identity

Works with existing moderation (hide_unless_approved) - anonymous
comments are never auto-approved when moderation is enabled.
2025-12-20 11:06:31 -05:00