5 comments

  • dkoy3 hours ago
    Briefly checked out the repo and demo, looks neat!<p>Bookmarked to keep a tab on for future reference.<p>I noticed that SQLAlchemy (an ORM) is part of the stack, and that “Postgres support” is in the roadmap. For people coming from Supabase and the like which is Postgres-first, some upfront clarification around which database is already supported, would be helpful.
    • lalitgehani2 hours ago
      Thanks for the kind words and the bookmark!<p>You&#x27;re right. Since I use SQLAlchemy, the core is already database agnostic. Swapping the connection string to Postgres actually works for most features right now.<p>I listed it as &quot;Roadmap&quot; only because I haven&#x27;t finished the full end-to-end test suite for Postgres yet, and I wanted the default &quot;Quick Start&quot; to be a zero dependency SQLite setup. I am also working on native read&#x2F;write splitting so that the system can properly leverage scaling architectures (like Amazon Aurora&#x27;s single-writer &#x2F; multi-reader clusters) out of the box.<p>I&#x27;ll make sure to clarify in the docs that it&#x27;s currently &quot;experimental&quot; rather than missing. Appreciate the feedback!
  • notpushkin2 hours ago
    This is really cool. I probably won’t be using it directly, but will definitely study some architecture and implementation decisions.<p>&gt; Compliance Core: Immutable audit logs with blockchain-style hashing (prev_hash) for integrity.<p>Had this in the back of my mind for a while now, too. In terms of prior art, Keybase had been doing something similar, but with Merkle trees.<p>&gt; I’d love feedback on the DSL implementation<p>Could you tell in a bit more detail why you decided to go with your own DSL here? :)
    • lalitgehani1 hour ago
      Great question!<p>Keybase&#x27;s Merkle approach is elegant for their use case (efficient proofs without revealing the full chain), but I went simpler with a linear chain because:<p>1. Audit trails are inherently sequential - they&#x27;re ordered by time and typically read&#x2F;written in order. Merkle trees shine for unordered data where you need efficient inclusion proofs. 2. Verification simplicity - with a linear chain, integrity verification is just &quot;walk the sequence and check that each entry&#x27;s previous_hash matches the prior entry&#x27;s checksum.&quot; O(n) and dead simple. 3. Storage efficiency - each entry stores two SHA-256 hashes as strings. No tree overhead. 4. Regulatory fit - for GxP&#x2F;CFR Part 11 compliance, the requirement is tamper detection, not zero-knowledge proofs. A linear chain detects any modification equally well.<p>That said, if I ever need selective verification (prove entry #500 is valid without transmitting the full chain), I&#x27;d revisit Merkle. The implementation is in src&#x2F;snackbase&#x2F;infrastructure&#x2F;persistence&#x2F;repositories&#x2F;audit_log_repository.py if you&#x27;re curious.<p>On the custom DSL: This was the biggest architectural decision in SnackBase. Here&#x27;s the honest breakdown:<p>Why not just use existing options? &gt;Approach: Python eval() &gt;&gt;Why I didn&#x27;t choose it: Security nightmare - can&#x27;t safely let users store arbitrary code in the database<p>&gt;Approach: CEL (Google&#x27;s Common Expression Language) &gt;&gt;Why I didn&#x27;t choose it: Battle-tested, but heavy dependency and less control over semantics<p>&gt;Approach: JEXL&#x2F;JSONLogic &gt;&gt;Why I didn&#x27;t choose it: Another runtime to learn, harder to integrate with my macro system<p>&gt;Approach: Pure JSON rules &gt;&gt;Why I didn&#x27;t choose it: Becomes unreadable for complex expressions<p>What drove the decision:<p>1. Permissions are database-storable - rules live as strings in the permissions table, editable via API and admin UI. I needed something safe to parse and evaluate at runtime. 2. Sandboxed execution - the DSL only exposes specific operations (==, in, @has_role(), etc.). No imports, no file access, no arbitrary code. Even if someone compromises the admin UI, they can only express logic within the vocabulary I provide. 3. Syntax for non-programmers - &quot;@has_role(&#x27;admin&#x27;) and @owns_record()&quot; is more approachable than Python lambdas when you&#x27;re building permissions in a web UI. 4. Macro integration - the @ prefix ties into my SQL macro system, letting users define reusable business logic like @is_department_head() that executes database queries.<p>The trade-off:<p>It&#x27;s 700+ lines of lexer&#x2F;parser&#x2F;evaluator code I have to maintain. Every edge case (null handling, type coercion, short-circuit evaluation) needs explicit test coverage. Debugging a failed rule means returning syntax errors at position X rather than a stack trace.<p>If I were starting fresh today, I&#x27;d give CEL harder consideration. But since permissions are a core differentiator for SnackBase, having full control over the semantics has been worth it—especially for field-level access control and the wildcard collection system.<p>Implementation files if you&#x27;re interested in it: - src&#x2F;snackbase&#x2F;core&#x2F;rules&#x2F;lexer.py - tokenizer - src&#x2F;snackbase&#x2F;core&#x2F;rules&#x2F;parser.py - recursive descent → AST - src&#x2F;snackbase&#x2F;core&#x2F;rules&#x2F;evaluator.py - async evaluation with short-circuiting<p>Happy to go deeper on any of this!
  • mring336212 hours ago
    I&#x27;m not sure the AGPL license is a good choice for this.<p>None of Django, Rails, Pocketbase or Supabase, which I think count as competitors, use AGPL.<p>Unless you can clarify that custom hooks and schemas are outside of the AGPL license, SnackBase may be a non-starter for commercial use.
    • lalitgehani2 hours ago
      Fair point.<p>Honestly, I picked AGPL mainly to prevent &quot;cloud wrapping&quot;. I definitely don&#x27;t intend for your business logic to get infected by it.<p>In my view, the custom hooks and schemas are &quot;content&#x2F;configuration&quot; rather than derivative works, but I get that running in-process makes that legally murky.<p>To clear that up, I&#x27;ll add a specific linking exception (like the Classpath Exception) to explicitly exempt user-defined hooks from the license. I want this to be safe for commercial teams to self-host, just not safe for cloud providers to resell.