Store copies of one posting as roles.dup_of and leave them out of the feed, the counts and the model stages

Migration 18 adds roles.dup_of with a partial index and runs the first rebuild. Store.rebuild_dupes feeds app.dupes.assign the open roles of every (company_key, title_key) with more than one, rewrites dup_of where it changed, clears it on closed roles, and hands read_at and votes to a changed group's kept role. The pull's settle and `app dupes` run it. RoleRow.copies counts a row's open copies; Role.copies lists them and Role.dup_of names a copy's kept role.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
WolfandClaude Opus 5.5 committed 2026-09-29 23:09:20 +02:00
1 parent 55e353e764
commit 545c932f7b
10 files changed
+490 -41

No files matched your search

+17
View File
@@ -7,6 +7,7 @@
app searches add|list|remove
app agents list|prompt
app stages [extract|summarise on|off]
app dupes
app db init
`app job` queues the work on a queue of its own and drains it here, so a
@@ -155,6 +156,8 @@ def build_parser() -> argparse.ArgumentParser:
stages.add_argument("name", nargs="?", choices=["extract", "summarise"])
stages.add_argument("state", nargs="?", choices=["on", "off"])
sub.add_parser("dupes", help="recompute which open roles are copies of one posting")
db = sub.add_parser("db", help="database housekeeping")
db.add_argument("action", choices=["init"])
return parser
@@ -179,6 +182,8 @@ def main(argv: list[str] | None = None) -> int:
return run_agents(args)
if args.command == "stages":
return run_stages(args)
if args.command == "dupes":
return run_dupes(args)
return init_db(args)
except (FileNotFoundError, config_mod.ConfigError) as exc:
print(exc, file=sys.stderr)
@@ -626,6 +631,18 @@ def run_stages(args: argparse.Namespace) -> int:
return 0
def run_dupes(args: argparse.Namespace) -> int:
"""`app dupes`: what the end of every pull runs, `Store.rebuild_dupes`,
now. Prints the groups (kept roles with a copy), the copies the feed
hides and the rows whose `dup_of` changed, as JSON."""
from app.storage import Store
config = config_mod.load(args.config)
counts = Store(config.database).rebuild_dupes()
print(json.dumps(counts._asdict()))
return 0
def init_db(args: argparse.Namespace) -> int:
"""Create the file, or bring it to the current schema."""
from app.storage import LATEST, Store