Feat v0.6.3 dead code sweep (#38)
All checks were successful
CI/CD / detect-changes (push) Successful in 4s
CI/CD / test-frontend (push) Successful in 6s
CI/CD / test-sqlite (push) Successful in 2m46s
CI/CD / test-go-pg (push) Successful in 2m47s
CI/CD / build-and-deploy (push) Successful in 26s

Co-authored-by: Jeffrey Smith <jasafpro@gmail.com>
Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit was merged in pull request #38.
This commit is contained in:
2026-03-31 12:37:47 +00:00
committed by xcaliber
parent a887b4c78b
commit 3d4228f868
130 changed files with 522 additions and 1215 deletions

View File

@@ -1,19 +1,14 @@
// Package sandbox — runner.go
//
// v0.29.0 CS3: Runner loads a package's Starlark script, assembles
// the module set based on granted permissions, and executes it.
//
// v0.29.1 CS0: Wires api.http permission to BuildHTTPModule with
// network_access config from package manifest.
//
// v0.29.1 CS2: Adds RunContext for per-invocation state (user_id),
// vault for provider key decryption, and provider.complete module.
//
// v0.29.2 CS1: Adds db *sql.DB for the db module. SetDB() wires it
// at startup. db.read grants query/view/list_tables; db.write adds
// insert/update/delete. If both are granted, db.write wins (superset).
//
// v0.38.2: Adds lib.load() for library packages. Libraries run with
// their own permission context. Per-invocation lib cache + cycle detection.
//
// The runner is the bridge between the package/permission system
@@ -48,7 +43,7 @@ type RunContext struct {
// ChannelID is the context identifier, if any.
ChannelID string
// TeamID is the team context for settings cascade resolution (v0.2.0).
// TeamID is the team context for settings cascade resolution.
// When set, team-scoped package settings are included in the cascade.
TeamID string
}
@@ -57,13 +52,13 @@ type RunContext struct {
type Runner struct {
sandbox *Sandbox
stores store.Stores
packagesDir string // v0.38.0: disk path for load() support
packagesDir string
notifier NotificationSender // nil = notifications module unavailable
connResolver ConnectionResolver // nil = connections module unavailable (v0.38.1)
connResolver ConnectionResolver // nil = connections module unavailable
db *sql.DB // nil = db module unavailable
dbPostgres bool // true = use $N placeholders; false = use ?
allowPrivateIPs bool // v0.38.5: disable SSRF private IP check
bus *events.Bus // v0.5.0: event bus for realtime module
allowPrivateIPs bool
bus *events.Bus
}
// NewRunner creates a runner with the given sandbox and dependencies.
@@ -79,7 +74,7 @@ func (r *Runner) SetNotifier(n NotificationSender) {
r.notifier = n
}
// SetConnectionResolver attaches the connection resolver for the connections module (v0.38.1).
// SetConnectionResolver attaches the connection resolver for the connections module.
func (r *Runner) SetConnectionResolver(cr ConnectionResolver) {
r.connResolver = cr
}
@@ -94,12 +89,11 @@ func (r *Runner) SetDB(db *sql.DB, isPostgres bool) {
// SetPackagesDir sets the disk path where package archives are extracted.
// Required for load() support — scripts are read from disk at runtime.
// v0.38.0.
func (r *Runner) SetPackagesDir(dir string) {
r.packagesDir = dir
}
// SetBus attaches the event bus for the realtime module (v0.5.0).
// SetBus attaches the event bus for the realtime module.
func (r *Runner) SetBus(bus *events.Bus) {
r.bus = bus
}
@@ -114,7 +108,6 @@ func (r *Runner) SetAllowPrivateIPs(allow bool) {
// ExecPackage loads a package's script from disk (primary) or manifest
// (legacy) and executes it with modules gated by granted permissions.
//
// v0.38.0: Disk-based loading + package-scoped load() support.
//
// The RunContext carries per-invocation state (user_id for provider
// resolution). Pass nil if no per-invocation context is needed.
@@ -136,7 +129,6 @@ func (r *Runner) ExecPackage(ctx context.Context, pkg *store.PackageRegistration
return nil, err
}
// v0.38.2: per-invocation lib context for lib.load() caching + cycle detection
lc := newLibContext()
// Build modules based on granted permissions
@@ -288,7 +280,7 @@ func (r *Runner) buildModules(ctx context.Context, packageID string, manifest ma
// The manifest is passed through so modules can read their config
// (e.g., http module reads network_access, provider reads requires_provider).
// The RunContext carries per-invocation state for user-scoped modules.
// The libContext enables lib.load() caching and cycle detection (v0.38.2).
// The libContext enables lib.load() caching and cycle detection.
func (r *Runner) buildModulesWithLibCtx(ctx context.Context, packageID string, manifest map[string]any, rc *RunContext, lc *libContext) (map[string]starlark.Value, error) {
if r.stores.ExtPermissions == nil {
return nil, nil
@@ -352,8 +344,7 @@ func (r *Runner) buildModulesWithLibCtx(ctx context.Context, packageID string, m
})
}
// v0.30.0: settings module — always injected, no permission required.
// A package reads its own admin + team + user settings (v0.2.0 cascade).
// A package reads its own admin + team + user settings.
userID := ""
teamID := ""
if rc != nil {
@@ -362,7 +353,6 @@ func (r *Runner) buildModulesWithLibCtx(ctx context.Context, packageID string, m
}
modules["settings"] = BuildSettingsModule(ctx, r.stores, packageID, userID, teamID)
// v0.38.2: lib module — always injected, no permission required.
// Allows any starlark package to load declared library dependencies.
if lc != nil {
modules["lib"] = BuildLibModule(ctx, r, packageID, rc, lc)