Skip to content

feat: plugin system#159

Merged
NTBBloodbath merged 12 commits into
masterfrom
push-npoyokxzwnmz
Jun 29, 2026
Merged

feat: plugin system#159
NTBBloodbath merged 12 commits into
masterfrom
push-npoyokxzwnmz

Conversation

@NTBBloodbath

Copy link
Copy Markdown
Collaborator

TBD: provide a proper PR body message once I mark it as ready to review

Resolves #57

- PluginInfo (repr(C)), PluginFn/FreeStringFn type aliases
- PluginManifest with plugin.toml parsing and ABI/semver validation
- PluginHooks bitmask, PluginInstance, empty PluginManager shell
- PluginManager::load() scans plugins/ dir, parses plugin.toml
- ABI + semver validation before loading shared library
- Hook mask validation, graceful skip + warn on failures
- Unit tests for empty/missing/invalid plugin dirs
…ory management

- call_hook_safe() with thread-based timeout and panic isolation
- NULL return optimization, libc::free on plugin-allocated strings
- parse_hook_response() and parse_status_response() for JSON handling
- C test plugins compiled via build.rs, integration tests for all paths
- sandbox-linux feature flag (default off), landlock 0.4 on Linux only
- apply_landlock() with runtime detection and graceful degradation
- Restricts FS to site, public, plugins, cache directories
- pre_build/post_build in build.rs bookend the full build
- post_convert/post_render in build_content_entry modify per-page HTML
- dev.rs: PluginManager in ServerState, hooks in render_all_pages
- sandbox: fix redundant closure in unwrap_or_else
@NTBBloodbath

Copy link
Copy Markdown
Collaborator Author

For some reason the Linux build CI using Nix shat itself after 6908709 even tho the commit didn't modify anything related to Nix lmfao

- list: show loaded plugins with name, version, hooks, status
- new: scaffold plugin dir with Cargo.toml, plugin.toml, src/lib.rs
- install: validate manifest, cargo build --release, copy .so + manifest
- uninstall: remove plugin directory
- make library_filename/library_extension pub for install command
- workspace root Cargo.toml with members core and sdk
- core/: norgolith binary, all existing code
- sdk/: norgolith-plugin-sdk v0.1.0
- SDK provides PluginInfo, context types, register_plugin! macro

Note: plugin sdk can be published to crates.io with no hassle, but core
needs the rust-norg git dep to be published as a crate.
- __bridge_json: universal JSON I/O bridge (C string → handler → JSON/NULL/error)
- __set_hook: maps hook name to bitmask + array index
- register_plugin! generates init fn + bridge fns per hook
- integration test: Rust cdylib plugin built + loaded by PluginManager
call_hook() already extracts html from JSON via
parse_hook_response(). The build and dev commands were
parsing the result a second time, silently dropping all
plugin output

Also fix build output: add blank line before Plugins section,
remove blank line between Plugins and Contenr
- Validate plugin names to block path traversal
- Add priority field for deterministic execution ordering
- Propagate hook errors visibly to user
- Track and print per-plugin hook timing
- Document allocator assumption: libc::free assumes system allocator
- Document Landlock timing gap: .so constructors run before sandbox
- Name on its own line, version/status/hooks/priority/abi/norgolith/timeout/fs/net below
- Status shows "ok" (green) or "no hooks" (yellow) when no hooks declared
- Empty state improved with installation hints
@NTBBloodbath NTBBloodbath marked this pull request as ready for review June 29, 2026 20:24
@NTBBloodbath

Copy link
Copy Markdown
Collaborator Author

I think this is ready for an MVP release. I'll improve the system further down the road

@NTBBloodbath NTBBloodbath merged commit 3df145b into master Jun 29, 2026
4 checks passed
@NTBBloodbath NTBBloodbath deleted the push-npoyokxzwnmz branch June 29, 2026 20:25
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.

[Feature]: plugin system

1 participant