Skip to main content

Module user_rules

Module user_rules 

Source
Expand description

Standing rules shared by every seat of this user, and by every machine that shares the tracker repository.

ljos prefer --user and ljos rule --user write them. The copy the hooks read is the user config, not the pack, so the review clock never sees them. The tracker carries one file per machine, and a sync merges those files by id.

A row written before basis was kept has neither basis nor from. It stays in the preface, marked not confirmed, until the person runs ljos prefer --user --review --keep. The cutoff is a local receipt written once by the first person-side command. A row written after that receipt with no basis stays out. A hook does not write the receipt: it runs under the runner.

Structs§

People
Handles and names a guard matches. The prose of the rule is not read.
UserRule
One standing rule. due_at is never written. A sweep drops a row only when that field is present and already past, which a row this module writes is not.

Constants§

PREFACE_BUDGET
How much of the preface a brief or a hook will carry.
RULES_FILE_CAP
The most a user-rules file may hold. A larger file is not read.

Functions§

ack
The rule as one line a person reads after writing it.
forget
Tombstone id. The author and the reason stay, so a later sync can say who removed it and why the rule stood. The lesson, if this row was promoted, is not touched.
format_list
Text lines for ljos rules, empty when there are none. A row held from before a basis was kept is listed apart from a promoted rule the pack does not confirm, which is unverified, with why.
guard_line
The user-rule verdict for a shell line, if one fires.
guard_payload
The user-rule verdict for a hook payload that names a tool, if the tool is a GitHub comment, review, issue or pull-request write.
held_count
How many user rules [is_held] counts. Session start and the doctor report this. Neither path is required to have written the cutoff.
is_due
Whether a row would be due at now. A row with no due_at is never due.
keep_held
Keep one held user rule as the person’s.
lesson_hash
Sha256 of what makes lesson record atom the lesson it is: its kind, its text, its ts and valid_from, and the origin it was stored under as [super::stored_by] reads it. packsetd keeps the first ts when a tombstoned id is posted again and stamps a new valid_from, so a repost is another lesson even in the same words, as are an edit of the text and an origin changed in place. Links, grades and the update stamp move on writes that leave the lesson as it was, and are not read.
load
The rows on disk that are still in force. An absent file is an empty list. Tombstones are left out.
mcp_event_denies
Whether rule is an outbound-post denial, the only verdict beforeMCPExecution enforces.
merge_rows
Merge rows by id. The newer updated_at wins, and that row’s author and reason come with it. A tombstone beats an older edit of the same id, and it also beats a live row that carries the same stamp.
note_cutoff
Record the cutoff for user-rule basis, once, from a person-side command.
preface
The preface injected ahead of seat memory. Empty when there are no rules the preface may show. A held row is shown in its own section, not as a rule the person confirmed.
prepend
body, with the user-rule preface in front. An empty preface leaves body as it is.
promote_atom
Copy one lesson atom into a user rule. The atom is not modified.
promote_lesson
Read lesson id from this seat’s pack and copy it into a user rule. The lesson stays in the pack. Under a runner, or with person_words (the MCP path), the lesson’s text must be in the person’s latest prompt, as write_preference asks of the words.
review_due
How many rows would be due at now. Ordinary rows contribute nothing.
review_list
List the user rules the upgrade held back.
review_sentence
The sentence the doctor and ljos prefer --user --review share.
rules_path
$XDG_CONFIG_HOME/ljos/user-rules.json, else ~/.config/ljos/user-rules.json.
sweep
Drop rows whose due_at is already past now, and leave every other row where it is. Returns how many were dropped.
sync_for_hook
Pull and push before a hook builds its line. A tracker that does not answer is ignored, and the local file is what the hook shows.
sync_now
One pull and push, as ljos prefer --user --sync runs it.
to_value
The rule as the object an MCP tool returns.
without_preface
text with one leading preface removed, so a session line and a prompt note that both carry it are not pasted twice.
write_argv
Write one argv law into the user file, under the same checks as a seat rule, with basis as the caller decided it, as a seat rule takes it.
write_preference
Write one prose rule. It is not also posted to the seat pack.