sphica 0.6.39 → 0.6.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/README.md +1 -0
- package/db/migrations/0012.sql +59 -0
- package/db/schema.sql +44 -2
- package/dist/capture.js +6 -2
- package/dist/cli.js +6 -2
- package/dist/deliver.js +6 -2
- package/dist/mcp-record.js +92 -32
- package/dist/mcp.js +246 -11
- package/package.json +1 -1
- package/skills/glean/SKILL.md +2 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://anthropic.com/claude-code/plugin.schema.json",
|
|
3
3
|
"name": "sphica",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.41",
|
|
5
5
|
"description": "Records Claude Code and Codex sessions on your machine and keeps past implementation and decisions, with their sources, for your agent to find.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "iroha924",
|
package/README.md
CHANGED
|
@@ -28,6 +28,7 @@ The database is a single SQLite file on your machine.
|
|
|
28
28
|
- **Search in Japanese and English.** Records are made with search words in both languages, so a question in either language is more likely to find them.
|
|
29
29
|
- **Find what you asked before.** Ask the agent whether you asked something like this before: `search` with `asked: true` shows your earlier messages in other sessions, the records that quote them (with what replaced them), and says "no recorded decision" when none was recorded, including a matter you raised in several sessions.
|
|
30
30
|
- **See what is live, and what needs a look.** Ask for the overview: `view: "live"` lists every active decision and constraint by the directory it applies to; `view: "look"` lists records whose file is gone or whose symbol is not found, conditions you said would bring a rejected option back, and lines in your instruction files whose record was replaced. Nothing is expired or changed on its own.
|
|
31
|
+
- **See what Sphica showed your agent.** Ask what Sphica has been showing: `view: "delivery"` (with `days`, 1 to 90, 7 by default) counts the deliveries the hooks logged by event and by main agent or subagent, lists the records shown most, and gives recent sessions with each record's key, so you can judge whether each helped. It says what the log leaves out, and marks a record "named later" only when a later reply wrote its key.
|
|
31
32
|
- **Track your own fields on records (trial).** Say in a session which extra field to keep on records (the affected tenant, a p95 figure); trace then saves a value only when the conversation writes it, with the quote. `/sphica:fields` shows each field and how many records carry a value.
|
|
32
33
|
- **Share decisions as a file.** `/sphica:export` writes the live decisions you pick, with the words quoted for them and the older decisions they replaced, to a Markdown file in your repository for people who do not run Sphica. You see the whole file before it is written, and it is never committed for you.
|
|
33
34
|
- **Rule text from records.** `/sphica:rules` drafts lines for CLAUDE.md, AGENTS.md, or `.claude/rules` from the constraints and decisions you pick, each marked with its record key so the overview flags it once the record changes. It never edits the file.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
-- Revision 11 → 12 of generation 2: glean keeps the owner's words that retired or moved an anchor (unit_anchor_retirement). Anchors
|
|
2
|
+
-- retired before it have no reason row; nothing is inferred for them. Every statement is the same as in the schema at revision 12.
|
|
3
|
+
|
|
4
|
+
create table unit_anchor_retirement (
|
|
5
|
+
anchor_id integer primary key not null references unit_anchor (id) on delete cascade,
|
|
6
|
+
run_id integer not null references extraction_run (id),
|
|
7
|
+
source_id integer not null references source (id) on delete cascade,
|
|
8
|
+
span_start integer not null check (span_start >= 0),
|
|
9
|
+
span_end integer not null check (span_end > span_start),
|
|
10
|
+
added_at text not null check (strftime('%Y-%m-%dT%H:%M:%fZ', added_at) is added_at)
|
|
11
|
+
) strict;
|
|
12
|
+
create index unit_anchor_retirement_run on unit_anchor_retirement (run_id);
|
|
13
|
+
create index unit_anchor_retirement_source on unit_anchor_retirement (source_id);
|
|
14
|
+
create trigger unit_anchor_retirement_check before insert on unit_anchor_retirement begin
|
|
15
|
+
select raise(abort, 'a retirement reason is written for a retired anchor')
|
|
16
|
+
where not exists (select 1 from unit_anchor where id = new.anchor_id and retired_at is not null);
|
|
17
|
+
select raise(abort, 'retirement reason and anchor belong to different projects')
|
|
18
|
+
where (select u.project_id from unit_anchor a join unit u on u.id = a.unit_id where a.id = new.anchor_id)
|
|
19
|
+
is not (select project_id from source where id = new.source_id)
|
|
20
|
+
or (select u.project_id from unit_anchor a join unit u on u.id = a.unit_id where a.id = new.anchor_id)
|
|
21
|
+
is not (select project_id from extraction_run where id = new.run_id);
|
|
22
|
+
select raise(abort, 'only the owner''s words retire an anchor')
|
|
23
|
+
where not exists (select 1 from source where id = new.source_id and author_kind = 'owner');
|
|
24
|
+
select raise(abort, 'retirement span is outside the source text')
|
|
25
|
+
where new.span_end > (select length(cast(text as blob)) from source where id = new.source_id);
|
|
26
|
+
select raise(abort, 'a span starts or ends inside a character')
|
|
27
|
+
where hex(substr((select cast(text as blob) from source where id = new.source_id), new.span_start + 1, 1)) between '80' and 'BF'
|
|
28
|
+
or hex(substr((select cast(text as blob) from source where id = new.source_id), new.span_end + 1, 1)) between '80' and 'BF';
|
|
29
|
+
end;
|
|
30
|
+
create trigger unit_anchor_retirement_frozen before update on unit_anchor_retirement begin
|
|
31
|
+
select raise(abort, 'a retirement reason is never changed');
|
|
32
|
+
end;
|
|
33
|
+
create trigger unit_anchor_retirement_no_delete before delete on unit_anchor_retirement
|
|
34
|
+
when exists (select 1 from unit_anchor where id = old.anchor_id) and exists (select 1 from source where id = old.source_id) begin
|
|
35
|
+
select raise(abort, 'a retirement reason goes only with its anchor or its source');
|
|
36
|
+
end;
|
|
37
|
+
|
|
38
|
+
drop trigger session_cited;
|
|
39
|
+
create trigger session_cited before delete on session
|
|
40
|
+
when exists (select 1 from project where id = old.project_id) and (
|
|
41
|
+
exists (select 1 from source s where s.session_id = old.id and (
|
|
42
|
+
exists (select 1 from unit_evidence e where e.source_id = s.id or e.retraction_source_id = s.id)
|
|
43
|
+
or exists (select 1 from unit_adoption a where a.source_id = s.id or a.retraction_source_id = s.id)
|
|
44
|
+
or exists (select 1 from field_def d where d.source_id = s.id)
|
|
45
|
+
or exists (select 1 from unit_field f where f.source_id = s.id)
|
|
46
|
+
or exists (select 1 from unit_state t where t.source_id = s.id)
|
|
47
|
+
or exists (select 1 from unit_anchor_retirement r where r.source_id = s.id)))
|
|
48
|
+
or exists (select 1 from edit_observation o join unit_anchor a on a.edit_observation_id = o.id where o.session_id = old.id)) begin
|
|
49
|
+
select raise(abort, 'records cite this session; forget its messages with /sphica:forget rather than deleting it');
|
|
50
|
+
end;
|
|
51
|
+
|
|
52
|
+
create trigger unit_rev_retirement_i after insert on unit_anchor_retirement begin
|
|
53
|
+
update unit set revision = revision + 1 where id = (select unit_id from unit_anchor where id = new.anchor_id);
|
|
54
|
+
end;
|
|
55
|
+
create trigger unit_rev_retirement_d after delete on unit_anchor_retirement begin
|
|
56
|
+
update unit set revision = revision + 1 where id = (select unit_id from unit_anchor where id = old.anchor_id);
|
|
57
|
+
end;
|
|
58
|
+
|
|
59
|
+
pragma user_version = 12;
|
package/db/schema.sql
CHANGED
|
@@ -141,7 +141,8 @@ when exists (select 1 from project where id = old.project_id) and (
|
|
|
141
141
|
or exists (select 1 from unit_adoption a where a.source_id = s.id or a.retraction_source_id = s.id)
|
|
142
142
|
or exists (select 1 from field_def d where d.source_id = s.id)
|
|
143
143
|
or exists (select 1 from unit_field f where f.source_id = s.id)
|
|
144
|
-
or exists (select 1 from unit_state t where t.source_id = s.id)
|
|
144
|
+
or exists (select 1 from unit_state t where t.source_id = s.id)
|
|
145
|
+
or exists (select 1 from unit_anchor_retirement r where r.source_id = s.id)))
|
|
145
146
|
or exists (select 1 from edit_observation o join unit_anchor a on a.edit_observation_id = o.id where o.session_id = old.id)) begin
|
|
146
147
|
select raise(abort, 'records cite this session; forget its messages with /sphica:forget rather than deleting it');
|
|
147
148
|
end;
|
|
@@ -699,6 +700,41 @@ end;
|
|
|
699
700
|
create trigger unit_anchor_no_delete before delete on unit_anchor when exists (select 1 from unit where id = old.unit_id) begin
|
|
700
701
|
select raise(abort, 'anchors are retired, never deleted');
|
|
701
702
|
end;
|
|
703
|
+
-- The owner's words that retired an anchor (moved or retired by glean). Forgetting that source removes only this row: the anchor stays retired
|
|
704
|
+
create table unit_anchor_retirement (
|
|
705
|
+
anchor_id integer primary key not null references unit_anchor (id) on delete cascade,
|
|
706
|
+
run_id integer not null references extraction_run (id),
|
|
707
|
+
source_id integer not null references source (id) on delete cascade,
|
|
708
|
+
span_start integer not null check (span_start >= 0),
|
|
709
|
+
span_end integer not null check (span_end > span_start),
|
|
710
|
+
added_at text not null check (strftime('%Y-%m-%dT%H:%M:%fZ', added_at) is added_at)
|
|
711
|
+
) strict;
|
|
712
|
+
create index unit_anchor_retirement_run on unit_anchor_retirement (run_id);
|
|
713
|
+
create index unit_anchor_retirement_source on unit_anchor_retirement (source_id);
|
|
714
|
+
create trigger unit_anchor_retirement_check before insert on unit_anchor_retirement begin
|
|
715
|
+
select raise(abort, 'a retirement reason is written for a retired anchor')
|
|
716
|
+
where not exists (select 1 from unit_anchor where id = new.anchor_id and retired_at is not null);
|
|
717
|
+
select raise(abort, 'retirement reason and anchor belong to different projects')
|
|
718
|
+
where (select u.project_id from unit_anchor a join unit u on u.id = a.unit_id where a.id = new.anchor_id)
|
|
719
|
+
is not (select project_id from source where id = new.source_id)
|
|
720
|
+
or (select u.project_id from unit_anchor a join unit u on u.id = a.unit_id where a.id = new.anchor_id)
|
|
721
|
+
is not (select project_id from extraction_run where id = new.run_id);
|
|
722
|
+
select raise(abort, 'only the owner''s words retire an anchor')
|
|
723
|
+
where not exists (select 1 from source where id = new.source_id and author_kind = 'owner');
|
|
724
|
+
select raise(abort, 'retirement span is outside the source text')
|
|
725
|
+
where new.span_end > (select length(cast(text as blob)) from source where id = new.source_id);
|
|
726
|
+
select raise(abort, 'a span starts or ends inside a character')
|
|
727
|
+
where hex(substr((select cast(text as blob) from source where id = new.source_id), new.span_start + 1, 1)) between '80' and 'BF'
|
|
728
|
+
or hex(substr((select cast(text as blob) from source where id = new.source_id), new.span_end + 1, 1)) between '80' and 'BF';
|
|
729
|
+
end;
|
|
730
|
+
create trigger unit_anchor_retirement_frozen before update on unit_anchor_retirement begin
|
|
731
|
+
select raise(abort, 'a retirement reason is never changed');
|
|
732
|
+
end;
|
|
733
|
+
-- Removed only with its anchor (the unit's deletion) or the source it quotes (forget)
|
|
734
|
+
create trigger unit_anchor_retirement_no_delete before delete on unit_anchor_retirement
|
|
735
|
+
when exists (select 1 from unit_anchor where id = old.anchor_id) and exists (select 1 from source where id = old.source_id) begin
|
|
736
|
+
select raise(abort, 'a retirement reason goes only with its anchor or its source');
|
|
737
|
+
end;
|
|
702
738
|
|
|
703
739
|
-- What an active unit must have, in one place: missing says what it lacks, and is null when it lacks nothing. Activating reads it, and so
|
|
704
740
|
-- does every change that can take support away (a retraction, retiring an anchor), so the two never disagree.
|
|
@@ -1015,6 +1051,12 @@ create trigger unit_rev_link_u after update on unit_link begin
|
|
|
1015
1051
|
end;
|
|
1016
1052
|
create trigger unit_rev_anchor_i after insert on unit_anchor begin update unit set revision = revision + 1 where id = new.unit_id; end;
|
|
1017
1053
|
create trigger unit_rev_anchor_u after update on unit_anchor begin update unit set revision = revision + 1 where id = new.unit_id; end;
|
|
1054
|
+
create trigger unit_rev_retirement_i after insert on unit_anchor_retirement begin
|
|
1055
|
+
update unit set revision = revision + 1 where id = (select unit_id from unit_anchor where id = new.anchor_id);
|
|
1056
|
+
end;
|
|
1057
|
+
create trigger unit_rev_retirement_d after delete on unit_anchor_retirement begin
|
|
1058
|
+
update unit set revision = revision + 1 where id = (select unit_id from unit_anchor where id = old.anchor_id);
|
|
1059
|
+
end;
|
|
1018
1060
|
create trigger unit_rev_alias_i after insert on unit_alias begin update unit set revision = revision + 1 where id = new.unit_id; end;
|
|
1019
1061
|
create trigger unit_rev_field_i after insert on unit_field begin update unit set revision = revision + 1 where id = new.unit_id; end;
|
|
1020
1062
|
create trigger unit_rev_field_d after delete on unit_field when exists (select 1 from unit where id = old.unit_id) begin
|
|
@@ -1225,4 +1267,4 @@ create trigger capture_delivery_prune_insert instead of insert on capture_delive
|
|
|
1225
1267
|
order by d.at, d.id limit 200);
|
|
1226
1268
|
end;
|
|
1227
1269
|
|
|
1228
|
-
pragma user_version =
|
|
1270
|
+
pragma user_version = 12;
|
package/dist/capture.js
CHANGED
|
@@ -11396,7 +11396,7 @@ var HOST_MARKS = new Set([".orphaned_at", ".in_use"]);
|
|
|
11396
11396
|
|
|
11397
11397
|
// server/src/sqlite.ts
|
|
11398
11398
|
var SCHEMA_GENERATION = 2;
|
|
11399
|
-
var SCHEMA_REVISION =
|
|
11399
|
+
var SCHEMA_REVISION = 12;
|
|
11400
11400
|
var sphicaHome = () => process.env.SPHICA_HOME || path2.join(os.homedir(), ".sphica");
|
|
11401
11401
|
var dbFile = () => process.env.SPHICA_DB || path2.join(sphicaHome(), "sphica.db");
|
|
11402
11402
|
function requireRuntime() {
|
|
@@ -11606,6 +11606,7 @@ var INGEST_INSERTS = new Set([
|
|
|
11606
11606
|
"unit_state",
|
|
11607
11607
|
"unit_replacement",
|
|
11608
11608
|
"unit_anchor",
|
|
11609
|
+
"unit_anchor_retirement",
|
|
11609
11610
|
"unit_alias",
|
|
11610
11611
|
"field_def",
|
|
11611
11612
|
"unit_field",
|
|
@@ -11650,7 +11651,9 @@ var INGEST_TRIGGER_WRITES = {
|
|
|
11650
11651
|
"anchor_u",
|
|
11651
11652
|
"alias_i",
|
|
11652
11653
|
"field_i",
|
|
11653
|
-
"field_d"
|
|
11654
|
+
"field_d",
|
|
11655
|
+
"retirement_i",
|
|
11656
|
+
"retirement_d"
|
|
11654
11657
|
].map((t) => [`unit_rev_${t}`, ["update unit"]])),
|
|
11655
11658
|
unit_fts_ai: ["insert unit_fts"],
|
|
11656
11659
|
unit_fts_ad: ["delete unit_fts"],
|
|
@@ -11694,6 +11697,7 @@ var FORGET_WRITES = {
|
|
|
11694
11697
|
"unit_adoption",
|
|
11695
11698
|
"source_processing",
|
|
11696
11699
|
"harvest_run_source",
|
|
11700
|
+
"unit_anchor_retirement",
|
|
11697
11701
|
"source_fts",
|
|
11698
11702
|
"field_def",
|
|
11699
11703
|
"unit_field",
|
package/dist/cli.js
CHANGED
|
@@ -4911,7 +4911,7 @@ ${indent}${caution(note)}` : ""}`);
|
|
|
4911
4911
|
|
|
4912
4912
|
// server/src/sqlite.ts
|
|
4913
4913
|
var SCHEMA_GENERATION = 2;
|
|
4914
|
-
var SCHEMA_REVISION =
|
|
4914
|
+
var SCHEMA_REVISION = 12;
|
|
4915
4915
|
var sphicaHome = () => process.env.SPHICA_HOME || path3.join(os2.homedir(), ".sphica");
|
|
4916
4916
|
var dbFile = () => process.env.SPHICA_DB || path3.join(sphicaHome(), "sphica.db");
|
|
4917
4917
|
function requireRuntime() {
|
|
@@ -15965,6 +15965,7 @@ var INGEST_INSERTS = new Set([
|
|
|
15965
15965
|
"unit_state",
|
|
15966
15966
|
"unit_replacement",
|
|
15967
15967
|
"unit_anchor",
|
|
15968
|
+
"unit_anchor_retirement",
|
|
15968
15969
|
"unit_alias",
|
|
15969
15970
|
"field_def",
|
|
15970
15971
|
"unit_field",
|
|
@@ -16009,7 +16010,9 @@ var INGEST_TRIGGER_WRITES = {
|
|
|
16009
16010
|
"anchor_u",
|
|
16010
16011
|
"alias_i",
|
|
16011
16012
|
"field_i",
|
|
16012
|
-
"field_d"
|
|
16013
|
+
"field_d",
|
|
16014
|
+
"retirement_i",
|
|
16015
|
+
"retirement_d"
|
|
16013
16016
|
].map((t2) => [`unit_rev_${t2}`, ["update unit"]])),
|
|
16014
16017
|
unit_fts_ai: ["insert unit_fts"],
|
|
16015
16018
|
unit_fts_ad: ["delete unit_fts"],
|
|
@@ -16053,6 +16056,7 @@ var FORGET_WRITES = {
|
|
|
16053
16056
|
"unit_adoption",
|
|
16054
16057
|
"source_processing",
|
|
16055
16058
|
"harvest_run_source",
|
|
16059
|
+
"unit_anchor_retirement",
|
|
16056
16060
|
"source_fts",
|
|
16057
16061
|
"field_def",
|
|
16058
16062
|
"unit_field",
|
package/dist/deliver.js
CHANGED
|
@@ -11427,7 +11427,7 @@ var HOST_MARKS = new Set([".orphaned_at", ".in_use"]);
|
|
|
11427
11427
|
|
|
11428
11428
|
// server/src/sqlite.ts
|
|
11429
11429
|
var SCHEMA_GENERATION = 2;
|
|
11430
|
-
var SCHEMA_REVISION =
|
|
11430
|
+
var SCHEMA_REVISION = 12;
|
|
11431
11431
|
var sphicaHome = () => process.env.SPHICA_HOME || path3.join(os.homedir(), ".sphica");
|
|
11432
11432
|
var dbFile = () => process.env.SPHICA_DB || path3.join(sphicaHome(), "sphica.db");
|
|
11433
11433
|
function requireRuntime() {
|
|
@@ -11672,6 +11672,7 @@ var INGEST_INSERTS = new Set([
|
|
|
11672
11672
|
"unit_state",
|
|
11673
11673
|
"unit_replacement",
|
|
11674
11674
|
"unit_anchor",
|
|
11675
|
+
"unit_anchor_retirement",
|
|
11675
11676
|
"unit_alias",
|
|
11676
11677
|
"field_def",
|
|
11677
11678
|
"unit_field",
|
|
@@ -11716,7 +11717,9 @@ var INGEST_TRIGGER_WRITES = {
|
|
|
11716
11717
|
"anchor_u",
|
|
11717
11718
|
"alias_i",
|
|
11718
11719
|
"field_i",
|
|
11719
|
-
"field_d"
|
|
11720
|
+
"field_d",
|
|
11721
|
+
"retirement_i",
|
|
11722
|
+
"retirement_d"
|
|
11720
11723
|
].map((t) => [`unit_rev_${t}`, ["update unit"]])),
|
|
11721
11724
|
unit_fts_ai: ["insert unit_fts"],
|
|
11722
11725
|
unit_fts_ad: ["delete unit_fts"],
|
|
@@ -11760,6 +11763,7 @@ var FORGET_WRITES = {
|
|
|
11760
11763
|
"unit_adoption",
|
|
11761
11764
|
"source_processing",
|
|
11762
11765
|
"harvest_run_source",
|
|
11766
|
+
"unit_anchor_retirement",
|
|
11763
11767
|
"source_fts",
|
|
11764
11768
|
"field_def",
|
|
11765
11769
|
"unit_field",
|
package/dist/mcp-record.js
CHANGED
|
@@ -46183,7 +46183,7 @@ var HOST_MARKS = new Set([".orphaned_at", ".in_use"]);
|
|
|
46183
46183
|
|
|
46184
46184
|
// server/src/sqlite.ts
|
|
46185
46185
|
var SCHEMA_GENERATION = 2;
|
|
46186
|
-
var SCHEMA_REVISION =
|
|
46186
|
+
var SCHEMA_REVISION = 12;
|
|
46187
46187
|
var sphicaHome = () => process.env.SPHICA_HOME || path2.join(os.homedir(), ".sphica");
|
|
46188
46188
|
var dbFile = () => process.env.SPHICA_DB || path2.join(sphicaHome(), "sphica.db");
|
|
46189
46189
|
function requireRuntime() {
|
|
@@ -46407,6 +46407,7 @@ var INGEST_INSERTS = new Set([
|
|
|
46407
46407
|
"unit_state",
|
|
46408
46408
|
"unit_replacement",
|
|
46409
46409
|
"unit_anchor",
|
|
46410
|
+
"unit_anchor_retirement",
|
|
46410
46411
|
"unit_alias",
|
|
46411
46412
|
"field_def",
|
|
46412
46413
|
"unit_field",
|
|
@@ -46451,7 +46452,9 @@ var INGEST_TRIGGER_WRITES = {
|
|
|
46451
46452
|
"anchor_u",
|
|
46452
46453
|
"alias_i",
|
|
46453
46454
|
"field_i",
|
|
46454
|
-
"field_d"
|
|
46455
|
+
"field_d",
|
|
46456
|
+
"retirement_i",
|
|
46457
|
+
"retirement_d"
|
|
46455
46458
|
].map((t) => [`unit_rev_${t}`, ["update unit"]])),
|
|
46456
46459
|
unit_fts_ai: ["insert unit_fts"],
|
|
46457
46460
|
unit_fts_ad: ["delete unit_fts"],
|
|
@@ -46495,6 +46498,7 @@ var FORGET_WRITES = {
|
|
|
46495
46498
|
"unit_adoption",
|
|
46496
46499
|
"source_processing",
|
|
46497
46500
|
"harvest_run_source",
|
|
46501
|
+
"unit_anchor_retirement",
|
|
46498
46502
|
"source_fts",
|
|
46499
46503
|
"field_def",
|
|
46500
46504
|
"unit_field",
|
|
@@ -49239,6 +49243,11 @@ var File2 = exports_external.object({
|
|
|
49239
49243
|
commit: exports_external.string().min(1).max(100).default("HEAD"),
|
|
49240
49244
|
lines: exports_external.tuple([exports_external.number().int().positive(), exports_external.number().int().positive()])
|
|
49241
49245
|
}).strict();
|
|
49246
|
+
var From = exports_external.object({
|
|
49247
|
+
path: exports_external.string().min(1),
|
|
49248
|
+
symbol: exports_external.string().min(1).optional(),
|
|
49249
|
+
role: exports_external.enum(["applies_to", "evidence"]).optional()
|
|
49250
|
+
}).strict();
|
|
49242
49251
|
var Op = exports_external.discriminatedUnion("op", [
|
|
49243
49252
|
exports_external.object({
|
|
49244
49253
|
op: exports_external.literal("add_evidence"),
|
|
@@ -49264,7 +49273,7 @@ var Op = exports_external.discriminatedUnion("op", [
|
|
|
49264
49273
|
op: exports_external.literal("replace_anchor"),
|
|
49265
49274
|
unit,
|
|
49266
49275
|
revision,
|
|
49267
|
-
from:
|
|
49276
|
+
from: From,
|
|
49268
49277
|
to: exports_external.object({
|
|
49269
49278
|
path: exports_external.string().min(1).max(500),
|
|
49270
49279
|
symbol: exports_external.string().min(1).max(200).optional(),
|
|
@@ -49273,6 +49282,7 @@ var Op = exports_external.discriminatedUnion("op", [
|
|
|
49273
49282
|
source: SOURCE_REF2,
|
|
49274
49283
|
quote
|
|
49275
49284
|
}).strict(),
|
|
49285
|
+
exports_external.object({ op: exports_external.literal("retire_anchor"), unit, revision, from: From, source: SOURCE_REF2, quote }).strict(),
|
|
49276
49286
|
exports_external.object({
|
|
49277
49287
|
op: exports_external.literal("retract_evidence"),
|
|
49278
49288
|
unit,
|
|
@@ -49436,6 +49446,7 @@ async function checkGlean(db, target, raw, facts = prepareGlean(target.root, raw
|
|
|
49436
49446
|
return { s, at };
|
|
49437
49447
|
};
|
|
49438
49448
|
const replaced = new Map;
|
|
49449
|
+
const retired = new Set;
|
|
49439
49450
|
const anchored = new Set;
|
|
49440
49451
|
const places = [];
|
|
49441
49452
|
const unsourcedSaid = new Set;
|
|
@@ -49500,34 +49511,43 @@ async function checkGlean(db, target, raw, facts = prepareGlean(target.root, raw
|
|
|
49500
49511
|
errors3.push(`${what}: commit ${op.commit.slice(0, 12)} does not hold ${rel2} in the repository`);
|
|
49501
49512
|
}
|
|
49502
49513
|
let replaces = null;
|
|
49503
|
-
|
|
49504
|
-
|
|
49514
|
+
let retires = null;
|
|
49515
|
+
if (op.op === "replace_anchor" || op.op === "retire_anchor") {
|
|
49516
|
+
if (op.op === "replace_anchor" && !repoPath(op.to.path))
|
|
49505
49517
|
errors3.push(`${what}: the path is not inside the repository`);
|
|
49506
49518
|
const said2 = await span(op.source, op.quote, what);
|
|
49507
49519
|
if (said2 && said2.s.author_kind !== "owner")
|
|
49508
|
-
errors3.push(`${what}: only the owner's words can move an anchor`);
|
|
49520
|
+
errors3.push(`${what}: only the owner's words can ${op.op === "retire_anchor" ? "retire" : "move"} an anchor`);
|
|
49509
49521
|
const from = repoPath(op.from.path);
|
|
49510
49522
|
if (!from)
|
|
49511
49523
|
errors3.push(`${what}: the from path is not inside the repository`);
|
|
49512
49524
|
else {
|
|
49513
|
-
let q = db.selectFrom("unit_anchor").select(["id", "path", "symbol", "role", "commit_sha"]).where("unit_id", "=", u.id).where("path", "=", from).where("retired_at", "is", null);
|
|
49525
|
+
let q = db.selectFrom("unit_anchor").select(["id", "path", "symbol", "role", "commit_sha", "line_start", "line_end"]).where("unit_id", "=", u.id).where("path", "=", from).where("retired_at", "is", null);
|
|
49514
49526
|
if (op.from.symbol)
|
|
49515
49527
|
q = q.where("symbol", "=", op.from.symbol);
|
|
49516
|
-
|
|
49517
|
-
|
|
49518
|
-
|
|
49519
|
-
|
|
49520
|
-
|
|
49521
|
-
|
|
49528
|
+
if (op.from.role)
|
|
49529
|
+
q = q.where("role", "=", op.from.role);
|
|
49530
|
+
const live = await q.orderBy("id").execute();
|
|
49531
|
+
const name = `${from}${op.from.symbol ? ` ${op.from.symbol}` : ""}${op.from.role ? ` (${op.from.role})` : ""}`;
|
|
49532
|
+
const held = live.length === 1 ? live[0] : undefined;
|
|
49533
|
+
if (held) {
|
|
49534
|
+
if (op.op === "replace_anchor" && held.commit_sha === null && held.path === repoPath(op.to.path) && held.symbol === (op.to.symbol ?? null) && held.role === op.to.role)
|
|
49522
49535
|
errors3.push(`${what}: the anchor on ${name} is already that place`);
|
|
49523
|
-
if (
|
|
49524
|
-
errors3.push(`${what}: another operation in this batch already replaces ${name}`);
|
|
49525
|
-
if (
|
|
49526
|
-
|
|
49536
|
+
if (replaced.has(held.id) || retired.has(held.id))
|
|
49537
|
+
errors3.push(`${what}: another operation in this batch already retires or replaces ${name}`);
|
|
49538
|
+
if (op.op === "replace_anchor") {
|
|
49539
|
+
replaces = held.id;
|
|
49540
|
+
replaced.set(held.id, i);
|
|
49541
|
+
} else {
|
|
49542
|
+
retires = held.id;
|
|
49543
|
+
retired.add(held.id);
|
|
49544
|
+
}
|
|
49527
49545
|
} else if (!live.length)
|
|
49528
49546
|
errors3.push(`${what}: no live anchor on ${name}`);
|
|
49529
|
-
else
|
|
49530
|
-
|
|
49547
|
+
else {
|
|
49548
|
+
const which = live.map((a) => `${a.role}${a.symbol ? ` ${inline(head(a.symbol, 80))}` : ""}${a.commit_sha ? ` at ${a.commit_sha.slice(0, 12)}` : ""}${!a.symbol && a.line_start ? ` lines ${a.line_start}-${a.line_end ?? a.line_start}` : ""}`);
|
|
49549
|
+
errors3.push(`${what}: ${live.length} live anchors on ${name} (${which.join("; ")}); give from.symbol or from.role`);
|
|
49550
|
+
}
|
|
49531
49551
|
}
|
|
49532
49552
|
}
|
|
49533
49553
|
const dest = op.op === "anchor" ? op : op.op === "replace_anchor" ? op.to : null;
|
|
@@ -49604,10 +49624,22 @@ async function checkGlean(db, target, raw, facts = prepareGlean(target.root, raw
|
|
|
49604
49624
|
if (bad.length)
|
|
49605
49625
|
errors3.push(`${what}: aliases must be 1 to 40 characters; ${bad.map((a) => JSON.stringify(inline(head(a, 60)))).join(", ")}`);
|
|
49606
49626
|
}
|
|
49607
|
-
ops.push({
|
|
49627
|
+
ops.push({
|
|
49628
|
+
input: op,
|
|
49629
|
+
unitId: u.id,
|
|
49630
|
+
lifecycle: u.lifecycle,
|
|
49631
|
+
excerpt,
|
|
49632
|
+
retracts,
|
|
49633
|
+
replaces,
|
|
49634
|
+
retires,
|
|
49635
|
+
aliases
|
|
49636
|
+
});
|
|
49608
49637
|
}
|
|
49609
49638
|
for (const x of places) {
|
|
49610
|
-
const gone = [
|
|
49639
|
+
const gone = [
|
|
49640
|
+
...retired,
|
|
49641
|
+
...[...replaced].filter(([, by]) => x.replacing === null || by < x.replacing).map(([id]) => id)
|
|
49642
|
+
];
|
|
49611
49643
|
let q = db.selectFrom("unit_anchor").select("id").where("unit_id", "=", x.unit).where("path", "=", x.rel).where("role", "=", x.role).where("retired_at", "is", null).where("id", "not in", [...gone, -1]);
|
|
49612
49644
|
q = x.symbol ? q.where("symbol", "=", x.symbol) : q.where("symbol", "is", null);
|
|
49613
49645
|
q = x.commit ? q.where("commit_sha", "=", x.commit) : q.where("commit_sha", "is", null);
|
|
@@ -49676,10 +49708,23 @@ ${c.errors.map((e) => ` ${e}`).join(`
|
|
|
49676
49708
|
const touched = new Map;
|
|
49677
49709
|
const withdraw = new Map;
|
|
49678
49710
|
const adopted = new Set;
|
|
49711
|
+
const moves = ["retire_anchor", "replace_anchor"];
|
|
49679
49712
|
const ordered = [
|
|
49713
|
+
...c.ops.filter((p) => p.input.op === "retire_anchor"),
|
|
49680
49714
|
...c.ops.filter((p) => p.input.op === "replace_anchor"),
|
|
49681
|
-
...c.ops.filter((p) => p.input.op
|
|
49715
|
+
...c.ops.filter((p) => !moves.includes(p.input.op))
|
|
49682
49716
|
];
|
|
49717
|
+
const reason2 = async (anchorId, ref, q) => {
|
|
49718
|
+
const s = await spanOf(ref, q);
|
|
49719
|
+
await trx.insertInto("unit_anchor_retirement").values({
|
|
49720
|
+
anchor_id: anchorId ?? -1,
|
|
49721
|
+
run_id: runId,
|
|
49722
|
+
source_id: s.id,
|
|
49723
|
+
span_start: s.start,
|
|
49724
|
+
span_end: s.end,
|
|
49725
|
+
added_at: now
|
|
49726
|
+
}).execute();
|
|
49727
|
+
};
|
|
49683
49728
|
for (const p of ordered) {
|
|
49684
49729
|
const op = p.input;
|
|
49685
49730
|
touched.set(p.unitId, op.unit);
|
|
@@ -49737,9 +49782,15 @@ ${c.errors.map((e) => ` ${e}`).join(`
|
|
|
49737
49782
|
run_id: runId,
|
|
49738
49783
|
added_at: now
|
|
49739
49784
|
}).returning("id").executeTakeFirstOrThrow();
|
|
49740
|
-
if (op.op === "replace_anchor")
|
|
49785
|
+
if (op.op === "replace_anchor") {
|
|
49741
49786
|
await trx.updateTable("unit_anchor").set({ retired_at: now, replaced_by: added.id }).where("id", "=", p.replaces ?? -1).where("retired_at", "is", null).execute();
|
|
49787
|
+
await reason2(p.replaces, op.source, op.quote);
|
|
49788
|
+
}
|
|
49742
49789
|
changed2.push(`${op.unit}: anchor ${op.op === "anchor" ? "added" : "replaced"}`);
|
|
49790
|
+
} else if (op.op === "retire_anchor") {
|
|
49791
|
+
await trx.updateTable("unit_anchor").set({ retired_at: now }).where("id", "=", p.retires ?? -1).where("retired_at", "is", null).execute();
|
|
49792
|
+
await reason2(p.retires, op.source, op.quote);
|
|
49793
|
+
changed2.push(`${op.unit}: anchor retired`);
|
|
49743
49794
|
} else if (op.op === "replace_aliases") {
|
|
49744
49795
|
const { content_hash } = await trx.selectFrom("unit").select("content_hash").where("id", "=", p.unitId).executeTakeFirstOrThrow();
|
|
49745
49796
|
await trx.insertInto("unit_alias").values({
|
|
@@ -49751,17 +49802,17 @@ ${c.errors.map((e) => ` ${e}`).join(`
|
|
|
49751
49802
|
}).execute();
|
|
49752
49803
|
changed2.push(`${op.unit}: aliases ${p.aliases?.length ? "replaced" : "cleared"}`);
|
|
49753
49804
|
} else {
|
|
49754
|
-
const
|
|
49805
|
+
const reason3 = await spanOf(op.reason_source, op.reason_quote);
|
|
49755
49806
|
const retraction = {
|
|
49756
49807
|
retracted_at: now,
|
|
49757
49808
|
retraction_reason: op.reason_quote,
|
|
49758
|
-
retraction_source_id:
|
|
49759
|
-
retraction_span_start:
|
|
49760
|
-
retraction_span_end:
|
|
49809
|
+
retraction_source_id: reason3.id,
|
|
49810
|
+
retraction_span_start: reason3.start,
|
|
49811
|
+
retraction_span_end: reason3.end
|
|
49761
49812
|
};
|
|
49762
49813
|
if (op.op === "resolve_conflict") {
|
|
49763
49814
|
const other = await trx.selectFrom("unit").select("id").where("project_id", "=", target.projectId).where("key", "=", op.with).executeTakeFirstOrThrow();
|
|
49764
|
-
await trx.updateTable("unit_link").set({ resolved_at: now, resolution: `${head(op.reason_quote, 400)} (s${
|
|
49815
|
+
await trx.updateTable("unit_link").set({ resolved_at: now, resolution: `${head(op.reason_quote, 400)} (s${reason3.id})` }).where("kind", "=", "conflicts").where("resolved_at", "is", null).where((eb) => eb.or([
|
|
49765
49816
|
eb.and([eb("from_unit", "=", p.unitId), eb("to_unit", "=", other.id)]),
|
|
49766
49817
|
eb.and([eb("from_unit", "=", other.id), eb("to_unit", "=", p.unitId)])
|
|
49767
49818
|
])).execute();
|
|
@@ -49769,7 +49820,7 @@ ${c.errors.map((e) => ` ${e}`).join(`
|
|
|
49769
49820
|
continue;
|
|
49770
49821
|
}
|
|
49771
49822
|
if (op.op === "withdraw") {
|
|
49772
|
-
withdraw.set(p.unitId, { reason: `withdrawn: ${head(op.reason_quote, 200)}`, source:
|
|
49823
|
+
withdraw.set(p.unitId, { reason: `withdrawn: ${head(op.reason_quote, 200)}`, source: reason3.id });
|
|
49773
49824
|
continue;
|
|
49774
49825
|
}
|
|
49775
49826
|
const table = op.op === "retract_evidence" ? "unit_evidence" : "unit_adoption";
|
|
@@ -50340,13 +50391,18 @@ ${v.errors.map((e) => ` ${e}`).join(`
|
|
|
50340
50391
|
`)}`);
|
|
50341
50392
|
const { saved, changed: changed2 } = await v.write(trx);
|
|
50342
50393
|
await finishRun(trx, v.run.id);
|
|
50394
|
+
const warnings = [
|
|
50395
|
+
...new Set([
|
|
50396
|
+
...saved.anchorProblems.map((a) => `△ ${a}`),
|
|
50397
|
+
...v.ops === null ? v.problems.map((n) => `△ ${n}`) : []
|
|
50398
|
+
])
|
|
50399
|
+
];
|
|
50343
50400
|
return [
|
|
50344
50401
|
...saved.active.map((k) => `✓ ${k} active`),
|
|
50345
50402
|
...saved.superseded.map((k) => `✓ ${k} superseded`),
|
|
50346
50403
|
...saved.candidates.map((c) => `△ ${c.key} candidate: ${c.why}`),
|
|
50347
50404
|
...saved.quarantined.map((q) => `△ ${q} quarantined`),
|
|
50348
|
-
...
|
|
50349
|
-
...v.ops === null ? v.problems.map((n) => `△ ${n}`) : [],
|
|
50405
|
+
...warnings,
|
|
50350
50406
|
...changed2.map((c) => `✓ ${c}`),
|
|
50351
50407
|
"✓ saved"
|
|
50352
50408
|
].join(`
|
|
@@ -50399,7 +50455,8 @@ async function forgetIn(trx, projectId2, ids, at) {
|
|
|
50399
50455
|
sources: rows.map((r) => ({ id: r.id, kind: r.kind, artifact: r.artifact, bytes: r.bytes })),
|
|
50400
50456
|
already,
|
|
50401
50457
|
units: [],
|
|
50402
|
-
fields: { definitions: 0, values: 0 }
|
|
50458
|
+
fields: { definitions: 0, values: 0 },
|
|
50459
|
+
anchorReasons: 0
|
|
50403
50460
|
};
|
|
50404
50461
|
if (!rows.length)
|
|
50405
50462
|
return outcome;
|
|
@@ -50418,6 +50475,7 @@ async function forgetIn(trx, projectId2, ids, at) {
|
|
|
50418
50475
|
...defIds.length ? [eb("field_def_id", "in", defIds)] : []
|
|
50419
50476
|
])).select((eb) => eb.fn.countAll().as("n")).executeTakeFirstOrThrow()).n)
|
|
50420
50477
|
};
|
|
50478
|
+
outcome.anchorReasons = Number((await trx.selectFrom("unit_anchor_retirement as r").innerJoin("unit_anchor as a", "a.id", "r.anchor_id").innerJoin("unit as u", "u.id", "a.unit_id").where("u.project_id", "=", projectId2).where("r.source_id", "in", targets).select((eb) => eb.fn.countAll().as("n")).executeTakeFirstOrThrow()).n);
|
|
50421
50479
|
const removed = new Map;
|
|
50422
50480
|
for (const u of touched)
|
|
50423
50481
|
removed.set(u.id, await count("unit_evidence", u.id) + await count("unit_adoption", u.id));
|
|
@@ -50508,6 +50566,8 @@ function forgetText(o, file3) {
|
|
|
50508
50566
|
}
|
|
50509
50567
|
if (o.fields.definitions || o.fields.values)
|
|
50510
50568
|
lines.push(`- ${plural2(o.fields.definitions, "field definition")} and ${plural2(o.fields.values, "field value")} go with them`);
|
|
50569
|
+
if (o.anchorReasons)
|
|
50570
|
+
lines.push(`- ${plural2(o.anchorReasons, "reason")} for retiring or moving an anchor ${o.anchorReasons === 1 ? "goes" : "go"} with them; the anchors stay retired`);
|
|
50511
50571
|
if (o.units.length || o.fields.values)
|
|
50512
50572
|
lines.push("Records keep their own text: if one repeats the forgotten words, they stay in it.");
|
|
50513
50573
|
let copies;
|
package/dist/mcp.js
CHANGED
|
@@ -46004,7 +46004,7 @@ var HOST_MARKS = new Set([".orphaned_at", ".in_use"]);
|
|
|
46004
46004
|
|
|
46005
46005
|
// server/src/sqlite.ts
|
|
46006
46006
|
var SCHEMA_GENERATION = 2;
|
|
46007
|
-
var SCHEMA_REVISION =
|
|
46007
|
+
var SCHEMA_REVISION = 12;
|
|
46008
46008
|
var sphicaHome = () => process.env.SPHICA_HOME || path2.join(os.homedir(), ".sphica");
|
|
46009
46009
|
var dbFile = () => process.env.SPHICA_DB || path2.join(sphicaHome(), "sphica.db");
|
|
46010
46010
|
function requireRuntime() {
|
|
@@ -46105,6 +46105,12 @@ function kyselyOn(connect) {
|
|
|
46105
46105
|
function openReader(file2 = dbFile()) {
|
|
46106
46106
|
return kyselyOn(() => connectReader(file2));
|
|
46107
46107
|
}
|
|
46108
|
+
var iso = (d) => {
|
|
46109
|
+
const t = new Date(d);
|
|
46110
|
+
if (Number.isNaN(t.getTime()))
|
|
46111
|
+
throw new RangeError(`Not a readable time: ${String(d)}`);
|
|
46112
|
+
return t.toISOString();
|
|
46113
|
+
};
|
|
46108
46114
|
function byUnit(rows) {
|
|
46109
46115
|
const out = new Map;
|
|
46110
46116
|
for (const r of rows) {
|
|
@@ -46828,10 +46834,6 @@ function askedText(r, known = true) {
|
|
|
46828
46834
|
`);
|
|
46829
46835
|
}
|
|
46830
46836
|
|
|
46831
|
-
// server/src/export.ts
|
|
46832
|
-
import fs5 from "node:fs";
|
|
46833
|
-
import path5 from "node:path";
|
|
46834
|
-
|
|
46835
46837
|
// server/src/frame.ts
|
|
46836
46838
|
import crypto2 from "node:crypto";
|
|
46837
46839
|
function framed(body) {
|
|
@@ -46892,7 +46894,24 @@ async function describe3(db, u, root, asOf, renames) {
|
|
|
46892
46894
|
"s.created_at",
|
|
46893
46895
|
"s.text"
|
|
46894
46896
|
]).orderBy("a.id").execute(),
|
|
46895
|
-
db.selectFrom("unit_anchor").
|
|
46897
|
+
db.selectFrom("unit_anchor as a").leftJoin("unit_anchor as to", "to.id", "a.replaced_by").leftJoin("unit_anchor_retirement as r", (j) => j.onRef("r.anchor_id", "=", "a.id").on("r.added_at", "<=", asOf ?? "9999")).leftJoin("source as s", "s.id", "r.source_id").select([
|
|
46898
|
+
"a.path",
|
|
46899
|
+
"a.symbol",
|
|
46900
|
+
"a.role",
|
|
46901
|
+
"a.commit_sha",
|
|
46902
|
+
"a.line_start",
|
|
46903
|
+
"a.retired_at",
|
|
46904
|
+
"to.path as to_path",
|
|
46905
|
+
"to.symbol as to_symbol",
|
|
46906
|
+
"r.span_start",
|
|
46907
|
+
"r.span_end",
|
|
46908
|
+
"s.id as source",
|
|
46909
|
+
"s.author_kind",
|
|
46910
|
+
"s.author_login",
|
|
46911
|
+
"s.author_association",
|
|
46912
|
+
"s.created_at",
|
|
46913
|
+
"s.text"
|
|
46914
|
+
]).where("a.unit_id", "=", u.id).where("a.added_at", "<=", asOf ?? "9999").orderBy("a.id").execute(),
|
|
46896
46915
|
db.selectFrom("unit_link as l").innerJoin("unit as a", "a.id", "l.from_unit").innerJoin("unit as b", "b.id", "l.to_unit").where((eb) => eb.or([eb("l.from_unit", "=", u.id), eb("l.to_unit", "=", u.id)])).where("l.added_at", "<=", asOf ?? "9999").select((eb) => [
|
|
46897
46916
|
"l.kind",
|
|
46898
46917
|
"l.resolved_at",
|
|
@@ -46985,6 +47004,16 @@ async function describe3(db, u, root, asOf, renames) {
|
|
|
46985
47004
|
out.push(` - ${where} (${a.role}${a.commit_sha ? `, commit ${a.commit_sha.slice(0, 12)}` : ""}): ${c.state}${c.line ? ` at line ${c.line}` : ""}${c.state === "missing" ? ` — needs review: the code it points at is gone${movedTo(root, a, renames, used)}` : ""}`);
|
|
46986
47005
|
}
|
|
46987
47006
|
}
|
|
47007
|
+
const retired = anchors.filter((a) => a.retired_at);
|
|
47008
|
+
if (retired.length) {
|
|
47009
|
+
out.push("Retired anchors (they no longer count for delivery; a live anchor on the same path still does; kept with the words that retired them):");
|
|
47010
|
+
for (const a of retired) {
|
|
47011
|
+
const where = inline(`${a.path}${a.symbol ? ` ${a.symbol}` : ""}`);
|
|
47012
|
+
const moved = a.to_path ? `, moved to ${inline(`${a.to_path}${a.to_symbol ? ` ${a.to_symbol}` : ""}`)}` : "";
|
|
47013
|
+
const why = a.source !== null && a.text !== null && a.author_kind !== null && a.span_start !== null && a.span_end !== null ? `s${a.source}, ${speaker({ author_kind: a.author_kind, author_login: a.author_login, author_association: a.author_association })}, ${a.created_at}: "${inline(cut(a.text, a.span_start, a.span_end))}"` : "reason not recorded";
|
|
47014
|
+
out.push(` - ${where} (${a.role}${a.commit_sha ? `, commit ${a.commit_sha.slice(0, 12)}` : ""}): retired ${a.retired_at}${moved}; ${why}`);
|
|
47015
|
+
}
|
|
47016
|
+
}
|
|
46988
47017
|
out.push(...await replacements(db, u.id, links, asOf));
|
|
46989
47018
|
const conflicting = links.filter((l) => l.kind === "conflicts");
|
|
46990
47019
|
const sides = await authorityOf(db, conflicting.map((l) => l.from_id === u.id ? l.to_id : l.from_id), asOf);
|
|
@@ -47170,7 +47199,208 @@ async function readRefs(db, projectId, refs, root) {
|
|
|
47170
47199
|
`)}${tail(next)}`);
|
|
47171
47200
|
}
|
|
47172
47201
|
|
|
47202
|
+
// server/src/delivery-view.ts
|
|
47203
|
+
var DELIVERY_DAYS = { min: 1, max: 90, default: 7 };
|
|
47204
|
+
var DELIVERY_LIMITS = {
|
|
47205
|
+
records: 20,
|
|
47206
|
+
sessions: 5,
|
|
47207
|
+
deliveries: 15,
|
|
47208
|
+
keys: 8,
|
|
47209
|
+
key: 200,
|
|
47210
|
+
path: 200,
|
|
47211
|
+
agent: 40,
|
|
47212
|
+
session: 80
|
|
47213
|
+
};
|
|
47214
|
+
var DAY_MS = 24 * 60 * 60 * 1000;
|
|
47215
|
+
var MORE_LINE = 120;
|
|
47216
|
+
var WHO = ["main", "subagent", "subagent, id unknown"];
|
|
47217
|
+
var who = (named, event, reason2) => named ? "subagent" : event === "session_start" && reason2 === "subagent" ? "subagent, id unknown" : "main";
|
|
47218
|
+
var DELIVERY_LIMITS_TEXT = [
|
|
47219
|
+
"Counted are the logged delivery rows only: since 0.6.16 a read or edit that showed nothing is not logged (older rows show it as nothing), and a delivery answered while the write lock was busy, or whose log write failed, is not either.",
|
|
47220
|
+
"A session's rows are dropped once its last delivery is older than 90 days, so a long period is not a rolling window.",
|
|
47221
|
+
"The text delivered then is not kept, only the record ids: a record shown now may have changed since.",
|
|
47222
|
+
"Outcomes suppressed and unavailable are not written today, so only emitted and nothing appear.",
|
|
47223
|
+
"Rows without an agent id count as main, as the host reported them, except a subagent start logged without one: subagent, id unknown.",
|
|
47224
|
+
"named later: a captured reply of the same session, after the delivery, writes the key whole (questions asked with AskUserQuestion are not counted). An agent may use a record without naming it, naming it does not mean it helped, a reply may be missing, cut, or redacted in capture, and it may come from any agent of the session."
|
|
47225
|
+
];
|
|
47226
|
+
var CLOSING = "Read a record by its key or u<id> before relying on it. Change a record only with the owner's words, through /sphica:trace or /sphica:glean.";
|
|
47227
|
+
var BEFORE_KEY = /[A-Za-z0-9_./:-]/;
|
|
47228
|
+
var AFTER_KEY = /[A-Za-z0-9_/-]/;
|
|
47229
|
+
var KEY_AFTER_DOT = /[A-Za-z0-9_./-]/;
|
|
47230
|
+
var QUESTION2 = /:ask:.*:q:/s;
|
|
47231
|
+
function namesKey(text2, key) {
|
|
47232
|
+
for (let i = text2.indexOf(key);i !== -1 && key; i = text2.indexOf(key, i + 1)) {
|
|
47233
|
+
const before = text2[i - 1];
|
|
47234
|
+
const after = text2[i + key.length];
|
|
47235
|
+
const next = text2[i + key.length + 1];
|
|
47236
|
+
const goesOn = after !== undefined && (AFTER_KEY.test(after) || after === "." && next !== undefined && KEY_AFTER_DOT.test(next));
|
|
47237
|
+
if ((before === undefined || !BEFORE_KEY.test(before)) && !goesOn)
|
|
47238
|
+
return true;
|
|
47239
|
+
}
|
|
47240
|
+
return false;
|
|
47241
|
+
}
|
|
47242
|
+
async function deliveryOverview(db, projectId, days, now = new Date) {
|
|
47243
|
+
const to = iso(now);
|
|
47244
|
+
const from = iso(now.getTime() - days * DAY_MS);
|
|
47245
|
+
const logged = () => db.selectFrom("delivery as d").innerJoin("session as s", "s.id", "d.session_id").where("s.project_id", "=", projectId).where("d.at", ">=", from).where("d.at", "<", to);
|
|
47246
|
+
const keyed = () => logged().where((eb) => eb.exists(eb.selectFrom("delivery_unit as k").whereRef("k.delivery_id", "=", "d.id").select("k.unit_id")));
|
|
47247
|
+
const delivered = () => db.selectFrom("delivery_unit as du").innerJoin("delivery as d", "d.id", "du.delivery_id").innerJoin("session as s", "s.id", "d.session_id").where("s.project_id", "=", projectId).where("d.at", ">=", from).where("d.at", "<", to);
|
|
47248
|
+
const [oldest, groups, top, units, recent, sessions] = await Promise.all([
|
|
47249
|
+
db.selectFrom("delivery as d").innerJoin("session as s", "s.id", "d.session_id").where("s.project_id", "=", projectId).select((eb) => eb.fn.min("d.at").as("at")).executeTakeFirst(),
|
|
47250
|
+
logged().select((eb) => [
|
|
47251
|
+
"d.event",
|
|
47252
|
+
"d.outcome",
|
|
47253
|
+
"d.reason",
|
|
47254
|
+
"d.omitted",
|
|
47255
|
+
eb("d.agent_id", "is not", null).as("named"),
|
|
47256
|
+
eb.exists(eb.selectFrom("delivery_unit as k").whereRef("k.delivery_id", "=", "d.id").select("k.unit_id")).as("keyed"),
|
|
47257
|
+
eb.fn.countAll().as("n")
|
|
47258
|
+
]).groupBy(["d.event", "d.outcome", "d.reason", "d.omitted", "named", "keyed"]).execute(),
|
|
47259
|
+
delivered().innerJoin("unit as u", "u.id", "du.unit_id").select((eb) => [
|
|
47260
|
+
"u.id",
|
|
47261
|
+
"u.key",
|
|
47262
|
+
"u.kind",
|
|
47263
|
+
"u.lifecycle",
|
|
47264
|
+
eb.fn.count("d.session_id").distinct().as("sessions"),
|
|
47265
|
+
eb.fn.countAll().as("deliveries")
|
|
47266
|
+
]).groupBy("u.id").orderBy("sessions", "desc").orderBy("deliveries", "desc").orderBy("u.id").limit(DELIVERY_LIMITS.records).execute(),
|
|
47267
|
+
delivered().select((eb) => eb.fn.count("du.unit_id").distinct().as("n")).executeTakeFirst(),
|
|
47268
|
+
keyed().select((eb) => ["s.id", "s.host", "s.external_id", "s.branch", eb.fn.max("d.at").as("last")]).groupBy("s.id").orderBy("last", "desc").orderBy("s.id").limit(DELIVERY_LIMITS.sessions).execute(),
|
|
47269
|
+
keyed().select((eb) => eb.fn.count("d.session_id").distinct().as("n")).executeTakeFirst()
|
|
47270
|
+
]);
|
|
47271
|
+
const via = top.length ? await delivered().where("du.unit_id", "in", top.map((t) => t.id)).select(["du.unit_id", "d.event"]).distinct().orderBy("d.event").execute() : [];
|
|
47272
|
+
const shown = await Promise.all(recent.map(async (r) => {
|
|
47273
|
+
const rows = keyed().where("d.session_id", "=", r.id);
|
|
47274
|
+
const [list, n] = await Promise.all([
|
|
47275
|
+
rows.select(["d.id", "d.at", "d.event", "d.agent_id", "d.reason", "d.path"]).orderBy("d.at").orderBy("d.id").limit(DELIVERY_LIMITS.deliveries).execute(),
|
|
47276
|
+
rows.select((eb) => eb.fn.countAll().as("n")).executeTakeFirst()
|
|
47277
|
+
]);
|
|
47278
|
+
return { session: r, list, total: Number(n?.n ?? 0) };
|
|
47279
|
+
}));
|
|
47280
|
+
const ids = shown.flatMap((s) => s.list.map((d) => d.id));
|
|
47281
|
+
const keys = ids.length ? await db.selectFrom("delivery_unit as du").innerJoin("unit as u", "u.id", "du.unit_id").where("du.delivery_id", "in", ids).select(["du.delivery_id", "u.id", "u.key"]).orderBy("du.delivery_id").orderBy("u.id").execute() : [];
|
|
47282
|
+
const byDelivery = new Map;
|
|
47283
|
+
for (const k of keys)
|
|
47284
|
+
byDelivery.set(k.delivery_id, [...byDelivery.get(k.delivery_id) ?? [], k]);
|
|
47285
|
+
const replies = () => db.selectFrom("source as m").where("m.kind", "=", "session_message").where("m.author_kind", "=", "assistant").where("m.created_at", "<", to);
|
|
47286
|
+
const holding = (keys2) => (eb) => eb.or(keys2.map((k) => eb(eb.fn("instr", ["m.text", eb.val(k)]), ">", 0)));
|
|
47287
|
+
const reply = (r) => !QUESTION2.test(r.external_id);
|
|
47288
|
+
const namedIn = new Map;
|
|
47289
|
+
for (const t of top) {
|
|
47290
|
+
const found = await replies().innerJoin(delivered().where("du.unit_id", "=", t.id).select((f) => ["d.session_id", f.fn.min("d.at").as("first")]).groupBy("d.session_id").as("f"), (j) => j.onRef("f.session_id", "=", "m.session_id")).whereRef("m.created_at", ">", "f.first").where(holding([t.key])).select(["m.session_id", "m.external_id", "m.text"]).execute();
|
|
47291
|
+
namedIn.set(t.id, new Set(found.filter((r) => reply(r) && namesKey(r.text, t.key)).map((r) => r.session_id)).size);
|
|
47292
|
+
}
|
|
47293
|
+
const later = new Map;
|
|
47294
|
+
for (const s of shown) {
|
|
47295
|
+
const wanted = [...new Set(s.list.flatMap((d) => (byDelivery.get(d.id) ?? []).map((k) => k.key)))];
|
|
47296
|
+
const since = s.list[0]?.at;
|
|
47297
|
+
if (since && wanted.length)
|
|
47298
|
+
later.set(s.session.id, (await replies().where("m.session_id", "=", s.session.id).where("m.created_at", ">", since).where(holding(wanted)).select(["m.external_id", "m.created_at", "m.text"]).execute()).filter(reply));
|
|
47299
|
+
}
|
|
47300
|
+
const counts = countTable(groups);
|
|
47301
|
+
const fixedTop = [
|
|
47302
|
+
`# Delivery log of the last ${days} day${days === 1 ? "" : "s"}`,
|
|
47303
|
+
`Period: from ${from} up to ${to} (UTC). Oldest delivery still logged for this project: ${oldest?.at ?? "none"}.`,
|
|
47304
|
+
"",
|
|
47305
|
+
"## Logged delivery rows",
|
|
47306
|
+
...counts,
|
|
47307
|
+
""
|
|
47308
|
+
];
|
|
47309
|
+
const fixedEnd = ["", "## Limits", ...DELIVERY_LIMITS_TEXT.map((l) => `- ${l}`), "", CLOSING];
|
|
47310
|
+
let room = READ_BUDGET - bytes(framed("")) - bytes(fixedTop.join(`
|
|
47311
|
+
`)) - bytes(fixedEnd.join(`
|
|
47312
|
+
`)) - MORE_LINE * (2 + shown.length) - 512;
|
|
47313
|
+
const fit = (lines) => {
|
|
47314
|
+
const b = lines.reduce((sum, l) => sum + bytes(l) + 1, 0);
|
|
47315
|
+
if (b > room)
|
|
47316
|
+
return false;
|
|
47317
|
+
room -= b;
|
|
47318
|
+
return true;
|
|
47319
|
+
};
|
|
47320
|
+
const events = new Map;
|
|
47321
|
+
for (const v of via)
|
|
47322
|
+
events.set(v.unit_id, [...events.get(v.unit_id) ?? [], v.event]);
|
|
47323
|
+
const topLines = [];
|
|
47324
|
+
for (const t of top) {
|
|
47325
|
+
const line = `- ${head(inline(t.key), DELIVERY_LIMITS.key)} (u${t.id}, ${t.kind}, ${t.lifecycle} now): ${t.sessions} session${Number(t.sessions) === 1 ? "" : "s"}, ${t.deliveries} deliver${Number(t.deliveries) === 1 ? "y" : "ies"}, via ${(events.get(t.id) ?? []).join(", ")}; named later in ${namedIn.get(t.id) ?? 0} of those sessions`;
|
|
47326
|
+
if (!fit([line]))
|
|
47327
|
+
break;
|
|
47328
|
+
topLines.push(line);
|
|
47329
|
+
}
|
|
47330
|
+
const recordsLeft = Number(units?.n ?? 0) - topLines.length;
|
|
47331
|
+
const sessionParts = [];
|
|
47332
|
+
let sessionsShown = 0;
|
|
47333
|
+
for (const s of shown) {
|
|
47334
|
+
const heading = `### ${inline(s.session.host)} session ${head(inline(s.session.external_id), DELIVERY_LIMITS.session)}${s.session.branch ? ` (branch ${head(inline(s.session.branch), DELIVERY_LIMITS.path)})` : ""}, last delivery with a record ${s.session.last}`;
|
|
47335
|
+
const replies2 = later.get(s.session.id) ?? [];
|
|
47336
|
+
const lines = s.list.map((d) => deliveryLine(d, byDelivery.get(d.id) ?? [], (key) => replies2.some((r) => r.created_at > d.at && namesKey(r.text, key))));
|
|
47337
|
+
if (!lines.length || !fit([heading, lines[0] ?? ""]))
|
|
47338
|
+
break;
|
|
47339
|
+
const part = [heading, lines[0] ?? ""];
|
|
47340
|
+
let n = 1;
|
|
47341
|
+
for (const l of lines.slice(1)) {
|
|
47342
|
+
if (!fit([l]))
|
|
47343
|
+
break;
|
|
47344
|
+
part.push(l);
|
|
47345
|
+
n++;
|
|
47346
|
+
}
|
|
47347
|
+
if (s.total > n)
|
|
47348
|
+
part.push(`(${s.total - n} more deliver${s.total - n === 1 ? "y" : "ies"} with records in this session not shown.)`);
|
|
47349
|
+
sessionParts.push(...part);
|
|
47350
|
+
sessionsShown++;
|
|
47351
|
+
}
|
|
47352
|
+
const sessionsLeft = Number(sessions?.n ?? 0) - sessionsShown;
|
|
47353
|
+
return [
|
|
47354
|
+
...fixedTop,
|
|
47355
|
+
"## Records delivered most",
|
|
47356
|
+
...topLines.length ? topLines : ["No record was delivered in this period."],
|
|
47357
|
+
...recordsLeft > 0 ? [`(${recordsLeft} more delivered record${recordsLeft === 1 ? "" : "s"} not shown.)`] : [],
|
|
47358
|
+
"",
|
|
47359
|
+
"## Example sessions, the most recent first",
|
|
47360
|
+
...sessionParts.length ? sessionParts : ["No session was delivered a record in this period."],
|
|
47361
|
+
...sessionsLeft > 0 ? [
|
|
47362
|
+
`(${sessionsLeft} more session${sessionsLeft === 1 ? "" : "s"} delivered records in this period, not shown.)`
|
|
47363
|
+
] : [],
|
|
47364
|
+
...fixedEnd
|
|
47365
|
+
].join(`
|
|
47366
|
+
`);
|
|
47367
|
+
}
|
|
47368
|
+
function countTable(groups) {
|
|
47369
|
+
const rows = new Map;
|
|
47370
|
+
for (const g of groups) {
|
|
47371
|
+
const id = `${g.event}\x00${g.outcome}`;
|
|
47372
|
+
const row = rows.get(id) ?? { by: new Map, keyless: 0, left: 0 };
|
|
47373
|
+
const w = who(Boolean(Number(g.named)), g.event, g.reason);
|
|
47374
|
+
const n = Number(g.n);
|
|
47375
|
+
row.by.set(w, (row.by.get(w) ?? 0) + n);
|
|
47376
|
+
if (g.outcome === "emitted" && !Number(g.keyed))
|
|
47377
|
+
row.keyless += n;
|
|
47378
|
+
row.left += Number(g.omitted) * n;
|
|
47379
|
+
rows.set(id, row);
|
|
47380
|
+
}
|
|
47381
|
+
if (!rows.size)
|
|
47382
|
+
return ["No delivery was logged for this project in this period."];
|
|
47383
|
+
return [
|
|
47384
|
+
`| event | outcome | ${WHO.join(" | ")} | emitted rows with no logged record key | left out |`,
|
|
47385
|
+
`|${" --- |".repeat(WHO.length + 4)}`,
|
|
47386
|
+
...[...rows.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([id, r]) => {
|
|
47387
|
+
const [event, outcome] = id.split("\x00");
|
|
47388
|
+
return `| ${event} | ${outcome} | ${WHO.map((w) => r.by.get(w) ?? 0).join(" | ")} | ${outcome === "emitted" ? r.keyless : "-"} | ${r.left} |`;
|
|
47389
|
+
}),
|
|
47390
|
+
"left out: the sum of the counts each row logged of what applied but was not shown; a session start also counts work items."
|
|
47391
|
+
];
|
|
47392
|
+
}
|
|
47393
|
+
function deliveryLine(d, units, namedLater) {
|
|
47394
|
+
const w = who(d.agent_id !== null, d.event, d.reason);
|
|
47395
|
+
const agent = w === "subagent" && d.agent_id ? ` ${head(inline(d.agent_id), DELIVERY_LIMITS.agent)}` : "";
|
|
47396
|
+
const named = units.slice(0, DELIVERY_LIMITS.keys).map((u) => `${head(inline(u.key), DELIVERY_LIMITS.key)} (u${u.id}${namedLater(u.key) ? ", named later" : ""})`).join(", ");
|
|
47397
|
+
const more = units.length > DELIVERY_LIMITS.keys ? ` (+${units.length - DELIVERY_LIMITS.keys} more)` : "";
|
|
47398
|
+
return `- ${d.at} ${d.event}, ${w}${agent}${d.path ? ` ${head(inline(d.path), DELIVERY_LIMITS.path)}` : ""}: ${named}${more}`;
|
|
47399
|
+
}
|
|
47400
|
+
|
|
47173
47401
|
// server/src/export.ts
|
|
47402
|
+
import fs5 from "node:fs";
|
|
47403
|
+
import path5 from "node:path";
|
|
47174
47404
|
var EXPORT_LIMITS = { records: 50, depth: 20, bytes: 60 * 1024 };
|
|
47175
47405
|
async function chosen(db, projectId, ref) {
|
|
47176
47406
|
const byId = /^u([1-9][0-9]{0,15})$/.exec(ref);
|
|
@@ -47704,7 +47934,7 @@ ${shown.length ? shown.join(`
|
|
|
47704
47934
|
${notChecked.length ? notChecked.map((n) => `- ${n}`).join(`
|
|
47705
47935
|
`) : "nothing: every place above was checked"}`,
|
|
47706
47936
|
stop ? `Partial: more follow. Call overview with view look and after: "${cursorText(stop)}". Pages are read at different times: a record or file that changed in between may be missed or shown twice.` : "Complete: every section was listed to its end. Not checked entries on any page still apply.",
|
|
47707
|
-
"Read a record by its key before acting on it. Change a record only
|
|
47937
|
+
"Read a record by its key before acting on it. Change a record only with the owner's words, through /sphica:trace or /sphica:glean."
|
|
47708
47938
|
].join(`
|
|
47709
47939
|
|
|
47710
47940
|
`);
|
|
@@ -48339,15 +48569,20 @@ server.registerTool("fields", {
|
|
|
48339
48569
|
var DIFF = exports_external.string().min(1).max(2000000).describe("The change under review as a unified diff (git diff output)");
|
|
48340
48570
|
var notChecked = (e) => text2(`Decision lane: not checked. Sphica unavailable: ${head(reason(e), 300)}. Report the decision check as not run, not as passed.`, true);
|
|
48341
48571
|
server.registerTool("overview", {
|
|
48342
|
-
title: "Live decisions,
|
|
48343
|
-
description: "On request, not before every change. view live lists every active decision and constraint of the project, grouped by the directory it " + "applies to, a page at a time (pass after from the previous page). view look lists live records whose code file is gone or whose symbol " + "is not found, written conditions for reconsidering an option (for you to judge, never applied), and lines in CLAUDE.md, AGENTS.md, or " + ".claude/rules marked <!-- sphica: key --> whose record was replaced or withdrawn, a page at a time until one says Complete (pass the after it gives). " + "Read a record by its key before relying on it.",
|
|
48572
|
+
title: "Live decisions, records that need a look, and what Sphica showed",
|
|
48573
|
+
description: "On request, not before every change. view live lists every active decision and constraint of the project, grouped by the directory it " + "applies to, a page at a time (pass after from the previous page). view look lists live records whose code file is gone or whose symbol " + "is not found, written conditions for reconsidering an option (for you to judge, never applied), and lines in CLAUDE.md, AGENTS.md, or " + ".claude/rules marked <!-- sphica: key --> whose record was replaced or withdrawn, a page at a time until one says Complete (pass the after it gives). " + "view delivery shows what Sphica's hooks showed the agent over the last days (default 7): logged rows by event, the records delivered most, " + "and example sessions; use it when the user asks what Sphica has been showing. " + "Read a record by its key before relying on it.",
|
|
48344
48574
|
inputSchema: exports_external.object({
|
|
48345
|
-
view: exports_external.enum(["live", "look"]).describe("live: every active decision and constraint; look: records that need a look"),
|
|
48575
|
+
view: exports_external.enum(["live", "look", "delivery"]).describe("live: every active decision and constraint; look: records that need a look; delivery: what the hooks showed the agent"),
|
|
48346
48576
|
after: exports_external.union([exports_external.number().int().min(0), exports_external.string().min(1).max(8192)]).optional().describe("With live: the id the previous page said to continue after. With look: the cursor the previous page gave, as it is"),
|
|
48577
|
+
days: exports_external.number().int().min(DELIVERY_DAYS.min).max(DELIVERY_DAYS.max).optional().describe(`With delivery: how many days back to look, ending now (default ${DELIVERY_DAYS.default})`),
|
|
48347
48578
|
cwd: CWD
|
|
48348
48579
|
}).strict(),
|
|
48349
48580
|
annotations: READ_ONLY
|
|
48350
48581
|
}, async (a, extra) => {
|
|
48582
|
+
if (a.view !== "delivery" && a.days !== undefined)
|
|
48583
|
+
return text2("days: only with view delivery", true);
|
|
48584
|
+
if (a.view === "delivery" && a.after !== undefined)
|
|
48585
|
+
return text2("after: not with view delivery, which is one page", true);
|
|
48351
48586
|
if (a.view === "live" && typeof a.after === "string")
|
|
48352
48587
|
return text2("after: with view live, pass the id the previous page gave", true);
|
|
48353
48588
|
if (a.view === "look" && typeof a.after === "number")
|
|
@@ -48358,7 +48593,7 @@ server.registerTool("overview", {
|
|
|
48358
48593
|
const p = await projectOf(a.cwd, extra._meta);
|
|
48359
48594
|
if (typeof p === "string")
|
|
48360
48595
|
return text2(p);
|
|
48361
|
-
return text2(framed(typeof a.after === "string" || a.view === "look" ? await lookOverview(db, p.id, p.root, typeof a.after === "string" ? a.after : undefined) : await liveOverview(db, p.id, a.after ?? null)));
|
|
48596
|
+
return text2(framed(a.view === "delivery" ? await deliveryOverview(db, p.id, a.days ?? DELIVERY_DAYS.default) : typeof a.after === "string" || a.view === "look" ? await lookOverview(db, p.id, p.root, typeof a.after === "string" ? a.after : undefined) : await liveOverview(db, p.id, a.after ?? null)));
|
|
48362
48597
|
} catch (e) {
|
|
48363
48598
|
return text2(`Sphica unavailable: ${head(reason(e), 300)}`, true);
|
|
48364
48599
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sphica",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.41",
|
|
4
4
|
"description": "Records Claude Code and Codex sessions on your machine and keeps past implementation and decisions, with their sources, for your agent to find.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
package/skills/glean/SKILL.md
CHANGED
|
@@ -72,7 +72,8 @@ read tools `search` and `read`. Pass the repository root as `cwd` to every tool.
|
|
|
72
72
|
|---|---|
|
|
73
73
|
| `add_evidence` | Cites a `source` ref or a committed `file` (path, commit, lines). `role` as in trace. When the owner reports what someone else said, add `reported_speaker`: it stays the owner's report, never that person's statement or an adoption. A file excerpt is stored with keys masked, so quote words around a key, never the key, and cite whole lines around it: a range that cuts through a private key, or leaves a key's name outside, is refused |
|
|
74
74
|
| `adopt` | The owner's (or a maintainer's) words that settle a decision or constraint. "Kimura said it was agreed" is not adoption; the owner saying "let's make it final" is |
|
|
75
|
-
| `anchor` / `replace_anchor` | Adds a code location, or replaces one whose code moved (`from` and `to`, citing the owner's words); the old one is kept as history. A replacement carries no commit, so an implementation whose proof was the replaced anchor goes back to candidate: add an `anchor` op with `commit` in the same batch to keep it active. A `symbol` that is a key or a value Sphica masks is refused: anchor a name, or the path alone. A warning that the path is not in the working tree (with near paths), is a directory, or does not hold the symbol means fix it and check again |
|
|
75
|
+
| `anchor` / `replace_anchor` | Adds a code location, or replaces one whose code moved (`from` and `to`, citing the owner's words); the old one is kept as history with those words. A replacement carries no commit, so an implementation whose proof was the replaced anchor goes back to candidate: add an `anchor` op with `commit` in the same batch to keep it active. A `symbol` that is a key or a value Sphica masks is refused: anchor a name, or the path alone. A warning that the path is not in the working tree (with near paths), is a directory, or does not hold the symbol means fix it and check again |
|
|
76
|
+
| `retire_anchor` | Retires a code location with nothing in its place (`from`, citing the owner's words). Reads and edits are matched by path, so the record stops being shown on that file only once it has no live `applies_to` anchor on the path; retire each one, whatever its symbol. `from` names one live anchor by `path`, and `symbol` or `role` when the path holds more than one; check lists them when it cannot tell. The anchor is kept as history with the owner's words, and read shows it under retired anchors. Retiring an implementation's only code proof puts it back to candidate. In one batch, retirements run first, then replacements, then new anchors |
|
|
76
77
|
| `replace_aliases` | Replaces the record's search words (`aliases`, up to 12, each 1 to 40 characters) when search needs a word it lacks (the other language, a common term) or an alias is so broad it floods results. Search only, never evidence, so no quote; read prints the current ones, and `[]` clears them |
|
|
77
78
|
| `retract_evidence` / `retract_adoption` | Marks a link mistaken, citing the owner's words (`reason_source`, `reason_quote`). When the record cites the same source more than once, add `quote` to say which one. It is kept as history, and the record is judged again |
|
|
78
79
|
| `resolve_conflict` | Ends an unresolved conflict between `unit` and `with`, citing the owner's words (`reason_source`, `reason_quote`). Until then each is held back from being shown on its own, except the owner's decision, which only another record the owner adopted holds back |
|