New
Apps 6,235Makers 6,214This week 13
Promote your app−30%
Premise screenshot 1
4views in
the last 30 days

A shared memory for a team's AI coding agents that records which rule each piece of code was written under, so that when a rule changes, every file written under the old version is found, including files that never mention the rule, and handed to the right person's agent.

The scenario is an invented Indian and US wallet company, Tilldesk, under RBI and FinCEN rules. Premise supports evidence; it certifies nothing and is not legal or compliance advice.

Premise demo video: when a rule changes, find the code your AI agents built on it

Watch the demo on YouTube (6:37): the problem, what FalkorDB is and why a graph fits it, how Premise connects to Claude Code, one graph per team, speed, and the measured results.

What it is

AI agents write code because of a rule they were told: "cash loading is capped at ₹50,000 a month". When the rule changes, someone updates the places they remember. The others keep the old rule, often the ones that never name it, like an early-warning alert at 40_000_00 (80% of the limit) in src/admin/.

Premise sits between the agents and the code:

  1. Before an edit, an agent that opens a file is told the rules that govern it (a Claude Code hook), and an edit to a governed file is refused once until the agent has seen them.
  2. While writing, the agent looks figures up with the rule_lookup MCP tool instead of remembering them. Each lookup is recorded against the file being written, wherever it lives.
  3. After the edit, the change is stored with the exact rule versions it relied on, at one of four strengths: asked (looked up for this file), shown (shown before the edit), in_scope (in the rule's folders, but edited by hand or by a shell command), session (written in a session that looked the rule up for another file).
  4. When a rule is a draft, a dry run shows every place that would change, with no tasks opened.
  5. When it becomes final, Premise follows the graph from the old version to every file still written under it, opens a review task for the owner of each file, due on the effective date, and a Reviewer agent proposes for each file whether it really needs changing. It also checks every file whose latest content it holds for the old figure in any spelling, so a person's edit that no agent recorded is caught too (mentions), and Premise never finds less than grep would on the files it has seen.
  6. Every step is kept, so the path behind any file can be shown: which session changed it, relying on which version of which rule, and what has happened since.

Around that core:

  • Rules built on rules. An internal rule such as "alert at 80% of the cash limit" DERIVES_FROM the regulation; a change to the regulation also reaches code written under the derived rule, which never mentions the regulation.
  • Before changing a rule: what will it touch? The Impact page counts the files each rule reaches, directly and through rules derived from it, and names the files that sit under several rules at once (algo.WCC), where fixing one rule can break another. The Why page draws the shortest connection from a file to each regulator (algo.SPpaths).
  • Audit evidence per rule: every version, approver and reason, every AI change made under it (file, member, session, model, tier), every review and its resolution; as a page, JSON or CSV.
  • One-click fix, on a branch a person merges. For each file the Reviewer says needs a change, it proposes line replacements against the copy it read, and Premise turns them into a real diff. npx premise-fix <rule change> puts them all on a new branch, premise/<rule>-v<n>, in a separate git worktree, so the developer's checkout and main are never touched; a fix whose file has changed since review does not apply and is listed instead. It never pushes or merges. The receipt page shows the command and offers the patch as a download.
  • Guessed figures, in one queue. An agent that needs a figure nobody recorded writes it down as a draft with its source ("unverified: from memory") instead of typing it silently. The Guesses page lists each one with whose agent recorded it and every file already built on it, most relied on first. Compliance confirms it against a named source (the draft becomes final in place, with an APPROVED_BY edge) or corrects it, which is a rule change that opens a task for each of those files. The Tallyroll sessions left eight such figures, among them the EPF rate (12%), the EPS share (8.33%) and the FLSA overtime rate.
  • Handoffs: a task passed to a teammate carries a note; their next session opens with it.
  • Team conventions too: a repository's .claude/rules/*.md are imported as versioned rules, scoped by their paths:; when a rules file changes, code written under the old convention is found.

The agents in the demo are Claude Code sessions (developers' agents, through hooks and MCP) plus Premise's own Reviewer agent (Claude Haiku 5.5). What every agent is told, and what it does next, comes out of a graph query.

What it remembers

Kind of memory Premise
Episodic memory Sessions, changes, and what each agent was shown and asked for
Semantic memory Rules, versioned, with citations, effective dates and markets
Procedural memory Rules shown before every edit in scope; the standing instruction to look figures up
Persistent history Every rule version, change, propagation and verdict; the why-path
Shared state and handoffs Review tasks assigned to the owner's agent, claimed atomically, handed on with a note (an edge), opened at the next session
High-concurrency reads and writes Every agent's file read and edit is a graph read or write (measured)
Separate memory per tenant One graph per team, chosen by the caller's key; a cross-tenant test through every hook and MCP tool

Setup

Needs Node 22 and Docker. From a fresh clone:

git clone https://github.com/siddheshsonawane07/premise && cd premise
npm ci
npm run db:up                               # FalkorDB falkordb/falkordb:v4.22.0, pinned
npx tsx scripts/setup-demo.ts --replay      # the Tilldesk demo graph, rebuilt from the captured sessions;
                                            # writes the demo members' keys to .env.demo.local (git-ignored)
PREMISE_WEB_MEMBER=tilldesk.chitra npm start

Open http://localhost:8080. Run the demo on Home (or Take the tour in the header) opens the team's demo rule with its form already filled in with the real change it was tested on (Tilldesk: the RBI cash-load cap, ₹50,000 → ₹10,000; Tallyroll: the EPF wage ceiling, ₹15,000 → ₹25,000). A nine-step walkthrough, drawn with Driver.js, then guides the visitor: preview the change, see the files that need a fix and those still fine, the one-command fix, one file traced to its regulator, and that same trace walked through as a graph, column by column (who changed the file, which rules it used and who made them, and the shortest path FalkorDB found). It starts only when asked: a first-time visitor gets a one-line offer on Home, which goes away for good once taken, declined or finished (kept in the browser's localStorage; ?tour=reset on any page forgets that and starts the tour again). ×, Esc or Skip tour ends it at any step, and it works as a plain page without JavaScript. A preview assigns nothing, and the receipt shows the Reviewer's progress while it checks (about 25 seconds for Tallyroll's ten files). Home shows how Premise works as a four-step picture and what is waiting for you; Rules lists the official rules with how many files each is built into, and changes one (a preview that assigns nothing, or, as the compliance member Chitra, an official change that assigns a fix per file; money is typed in ₹ or $); the receipt that follows draws what the change found (the files built on the old version, split into those that need a fix and those still fine) and lists every file, the Reviewer's answer and the one-click fix; Guesses holds the figures agents recorded from memory; Tasks the fixes to make; Why the chain from a file to each regulator, in words and as the graph. The graph algorithms (algo.pageRank, algo.WCC) are at http://localhost:8080/impact, left out of the menu. The raw graph is in FalkorDB Browser at http://localhost:3000.

npm test                                    # 103 tests, against the real FalkorDB
npx tsx scripts/measure.ts                  # grep vs the rule's folders vs Premise, against an answer key
npx tsx scripts/measure.ts --payroll --rule us-flsa-salary  # the second test (setup-demo.ts --payroll --replay first)
npx tsx scripts/ablate.ts                   # what breaks without the graph (start the server first)
npx tsx scripts/import-rules.ts ../some-repo # a repo's .claude/rules/*.md as versioned rules

The Reviewer needs an Anthropic key: cp .env.example .env and set ANTHROPIC_API_KEY (and REVIEW_DAILY_CAP_USD, default 1). Without it every verdict is unknown, and everything else works.

Connect your own agent. Wire any repository to the server, then start Claude Code there with a member's key:

node scripts/connect-repo.mjs ../some-repo http://localhost:8080   # writes .claude/settings.json and .mcp.json
set -a; . ./.env.demo.local; set +a
cd ../some-repo && PREMISE_KEY=$PREMISE_KEY_ASHA claude

The key is read from PREMISE_KEY at run time; it is never written into a file.

The graph data model

One graph per team, t_<teamId>, plus _control for teams, members and hashed keys. Every node key has a range index and a unique constraint, created at start-up and verified; the server refuses to start if one is missing.

flowchart LR
  Rule -- CURRENT --> RV[RuleVersion]
  RV -- OF --> Rule
  Rule -- "DERIVES_FROM {how}" --> Base[Rule]
  RV -- "PARENT · SUPERSEDES {reason}" --> RVold[RuleVersion]
  RV -- APPROVED_BY --> Member
  Rule -- APPLIES_IN --> Jurisdiction
  Rule -- "SCOPE {declared · proposed}" --> Folder
  Folder -- SERVES --> Jurisdiction
  File -- IN --> Folder
  Session -- BY --> Member
  Session -- "SHOWN {path}" --> RV
  Lookup -- BY --> Member
  Lookup -- OF --> RV
  Change -- IN --> Session
  Change -- TO --> File
  Change -- "RELIED_ON {tier}" --> RVold
  File -- LATEST --> FileSnapshot
  Session -- "LEAK_WARNED {path}" --> RV
  File -- "IMPORTS {names}" --> File
  Propagation -- FROM --> RVold
  Propagation -- TO --> RV
  Propagation -- "FOUND {tier}" --> File
  ReviewTask -- FOR --> File
  ReviewTask -- BECAUSE --> Propagation
  ReviewTask -- ASSIGNED --> Member
  ReviewTask -- HAS --> Verdict
  Verdict -- ON --> FileSnapshot
  Verdict -- AGAINST --> RV
  ReviewTask -- "HANDED_OFF {note}" --> Member
  Claim -- ON --> ReviewTask
  Claim -- BY --> Member
Label Properties that matter
Rule id, title, type, risk
RuleVersion id (<rule>@<n>), n, text, figure (smallest currency unit), unit, citation, effective_from, status (draft, final), and on a confirmed guess verified_citation
Jurisdiction code (IN, US, and TEAM for a team's own conventions), regulator
Folder, File path, always relative to the repo root
Session id (Claude Code's session id), tool, model, started_at
Lookup path, at: a member asked for a rule version while writing this path
Change id (the tool call's id, so a retried hook records nothing twice), diff, at
Propagation dry_run, status, and the receipt's counts as plain numbers
ReviewTask status (open, proposed_clear, resolved), tier, due, resolved_reason
Verdict verdict (needs_change, still_fine, unknown), reason, patch, model, prompt_version
FileSnapshot hash, content: what the Reviewer reads

The core edge is (Change)-[:RELIED_ON {tier}]->(RuleVersion), written in the same query as the change. Its tier is decided at edit time from what the graph holds: a Lookup by this member for this path since the session began (asked), a SHOWN edge from this session for this path (shown), the file merely being in scope (in_scope), or a lookup in this session for another file, kept to the markets the file's folders serve (session). It is never recomputed.

Why a graph. The answer to "which code still follows the old rule, and who owns it?" is a path: rule → the version that changed → the changes that relied on it → the files → the member behind each file's latest change. The strongest link, an agent asking for the figure while editing a file outside the rule's folders, exists only as an edge in the graph; no folder list, grep or git log holds it. The graph also decides where a plain text match is wrong: ₹10,000 and $10,000 are both 10_000_00 in minor units, so a match in a file whose folders serve only another market is dropped.

Which file a borrowed figure lives in is also a path. Each snapshot records the repo files it imports from as (File)-[:IMPORTS {names}]->(File), replaced whenever the content changes. When a rule changes, the Reviewer follows up to three IMPORTS hops from each found file to the files that still hold the old figure (TEAM.importedSources) and reads them too. A file that only uses an imported constant, such as topup.ts → limits.ts or reports/compliance.ts → hr/onboarding.ts → in/epf.ts, is then judged against the file that defines it instead of blind.

The same edges keep a figure in its one setting. Before an agent's edit, Premise checks whether the text it adds spells the current figure of a rule in the file's markets. If a file already exports that figure as a constant, the one most imported (TEAM.figureHome), the edit is denied once with the constant's name and the import line to use; the warning is a LEAK_WARNED edge, and the same edit retried goes through, because the number may mean something else. Replaying the captured sessions, it would have warned 10 times for the two rules that later changed; 9 of those files are in the answer keys (Tilldesk's cash-intake.ts, which kept its own copy of the limit, and eight tests that typed the boundary). The tenth was test/esi.test.ts, where ₹15,000 is an ESI input, not the EPF ceiling.

The Cypher queries

Every query is in src/db/queries.ts, each with every value passed as a parameter. All of them, with what each is for: docs/QUERIES.md. The ones the product's claim rests on:

TEAM.rulesForPath

Q5. The current rules governing a path: a SCOPE edge to the file or any folder above it, kept to the markets the path's folders serve (if any). For each, whether this session was already shown it for this path, and whether this member looked it up for this path since the session began. $pathsUp is the path itself followed by every folder above it.

OPTIONAL MATCH (sf:Folder)-[:SERVES]->(sj:Jurisdiction)
WHERE sf.path IN $pathsUp
WITH collect(DISTINCT sj.code) AS served
OPTIONAL MATCH (sess:Session {id: $session})
WITH served, coalesce(sess.started_at, $fallbackSince) AS since
OPTIONAL MATCH (lastChange:Change)-[:TO]->(:File {path: $path})
WITH served, since, max(lastChange.at) AS lastEdit
MATCH (r:Rule)-[:SCOPE]->(s)
WHERE s.path IN $pathsUp
MATCH (r)-[:CURRENT]->(v:RuleVersion)
MATCH (r)-[:APPLIES_IN]->(j:Jurisdiction)
WITH DISTINCT served, since, lastEdit, r, v, j
WHERE size(served) = 0 OR j.code IN served OR j.code = 'TEAM'
OPTIONAL MATCH (:Session {id: $session})-[sh:SHOWN {path: $path}]->(v)
WITH since, lastEdit, r, v, j, count(sh) > 0 AS shown
OPTIONAL MATCH (:Member {id: $member})<-[:BY]-(lk:Lookup {path: $path})-[:OF]->(v)
WHERE lk.at >= since
WITH lastEdit, r, v, j, shown, count(lk) > 0 AS asked
OPTIONAL MATCH (v)-[:PARENT]->(prev:RuleVersion)
RETURN r.id AS ruleId, r.title AS title, r.risk AS risk, j.code AS jurisdiction,
       v.id AS versionId, v.n AS n, v.text AS text, v.figure AS figure, v.unit AS unit,
       v.citation AS citation, v.effective_from AS effectiveFrom, v.status AS status, v.at AS versionAt,
       prev.figure AS previousFigure, lastEdit, shown, asked
ORDER BY ruleId

TEAM.recordLookup

Q4b. Record that this member asked for this rule version while writing this path.

MATCH (m:Member {id: $member})
MATCH (v:RuleVersion {id: $versionId})
CREATE (l:Lookup {id: $id, path: $path, at: $at})
CREATE (l)-[:BY]->(m)
CREATE (l)-[:OF]->(v)
RETURN l.id AS id

TEAM.sessionLookups

Rule versions this member looked up since the session began, for any file, with their market. An edited file that is not in such a rule's scope still relied on it at tier session: the agent had the figure in hand (real sessions copy it into tests written right after).

MATCH (s:Session {id: $session})
MATCH (:Member {id: $member})<-[:BY]-(lk:Lookup)-[:OF]->(v:RuleVersion)
WHERE lk.at >= s.started_at
MATCH (r:Rule {id: v.rule_id})-[:APPLIES_IN]->(j:Jurisdiction)
RETURN DISTINCT v.id AS versionId, r.id AS ruleId, j.code AS jurisdiction

TEAM.recordChange

Q7. One edit, recorded in one query (STRICT 5.6): the Change, the session and file it belongs to, one RELIED_ON edge per rule version in scope at the tier decided from what was shown or asked, and any open review task this change resolves (it relied on the task's new version at tier asked). An unrelated edit, such as a typo fix, resolves nothing.

MERGE (s:Session {id: $session})
ON CREATE SET s.tool = $tool, s.started_at = $at, s.branch = $branch
WITH s
MATCH (m:Member {id: $member})
MERGE (s)-[:BY]->(m)

FOREACH (link IN $chain |
  MERGE (c:Folder {path: link.child})
  MERGE (p:Folder {path: link.parent})
  MERGE (c)-[:IN]->(p))
MERGE (d:Folder {path: $dir})
MERGE (f:File {path: $path})
MERGE (f)-[:IN]->(d)
CREATE (ch:Change {id: $changeId, diff: $diff, at: $at, branch: $branch})
CREATE (ch)-[:IN]->(s)
CREATE (ch)-[:TO]->(f)
WITH ch, f
UNWIND $relied AS rel
MATCH (v:RuleVersion {id: rel.versionId})
CREATE (ch)-[:RELIED_ON {tier: rel.tier}]->(v)
WITH ch, f, v, rel
OPTIONAL MATCH (t:ReviewTask)-[:FOR]->(f), (t)-[:BECAUSE]->(:Propagation)-[:TO]->(v)
WHERE rel.tier = 'asked' AND t.status IN ['open', 'proposed_clear']
FOREACH (x IN CASE WHEN t IS NULL THEN [] ELSE [t] END |
  SET x.status = 'resolved', x.resolved_reason = $resolvedReason, x.resolved_at = $at)
RETURN count(DISTINCT t) AS resolved

TEAM.supersede

Q10. A rule changes, in one query (STRICT 5.6). The new version links to the current one by PARENT and SUPERSEDES {reason}, and a Propagation is queued from old to new. A final moves CURRENT and records who approved it; a draft leaves CURRENT where it is, so the propagation is a dry run.

MATCH (r:Rule {id: $ruleId})-[cur:CURRENT]->(old:RuleVersion)
MATCH (sibling:RuleVersion {rule_id: $ruleId})
WITH r, cur, old, max(sibling.n) AS top
CREATE (v:RuleVersion {id: $ruleId + '@' + toString(top + 1), rule_id: $ruleId, n: top + 1,
                       text: $text, hash: $hash, at: $at, author: $author, citation: $citation,
                       effective_from: $effectiveFrom, status: $status})
SET v += $figure
CREATE (v)-[:OF]->(r)
CREATE (v)-[:PARENT]->(old)
CREATE (v)-[:SUPERSEDES {reason: $reason}]->(old)
CREATE (p:Propagation {id: $propagationId, rule_id: $ruleId, at: $at, dry_run: $dryRun, status: 'queued'})
CREATE (p)-[:FROM]->(old)
CREATE (p)-[:TO]->(v)
WITH r, cur, old, v, p
MATCH (author:Member {id: $author})
FOREACH (x IN CASE WHEN $dryRun T

Description taken from the repository README.

Ratings

–
0 ratings
5 0
4 0
3 0
2 0
1 0

Rate this app

Sign in to rate

Comments 0

Sign in to comment

No comments yet.

Related apps

#ai-agents · #dev-tools · #memory