code wiki / (root) / nx_claim_check.nx

nx_claim_check.nx source

↩ module page · 60 lines · 2817 B

1// nx_claim_check.nx -- CLI for session claims (coordination rung 1; core = nx_claim_core.nx). 2// Concurrent Claude sessions coordinate through this organ: 3// claim <sess8> <ws-slug> <scope-csv> <ttl_ms> register/refresh this session's claim 4// beat <sess8> renew liveness (call on significant progress) 5// release <sess8> explicit hand-back (claim stops blocking) 6// check <sess8> <path>... exit 0 GRANT / 3 DENY (pre-commit tooth: 7// a path inside ANOTHER live claim's scope) 8// walk print every claude_* claim + verdict 9// Wire: .git/hooks/pre-commit runs `check ${NX_SESSION:-unclaimed} <staged paths>`. 10// license_tier: ORIGINAL 11import "nx_claim_core.nx" 12 13const CLI_EXIT_USAGE: i64 = 4 14 15func main(argc: i64, argv: *i64) -> i64 { 16 if argc < 2 { 17 std_putln("usage: nx_claim_check claim <sess8> <ws> <scope-csv> <ttl_ms> | beat <sess8> | release <sess8> | check <sess8> <path>... | walk" as *u8) 18 sys_exit(CLI_EXIT_USAGE) 19 return CLI_EXIT_USAGE 20 } 21 let verb: *u8 = argv[1] as *u8 22 if std_streq(verb, "claim" as *u8) == 1 { 23 if argc < 6 { std_putln("claim needs <sess8> <ws> <scope-csv> <ttl_ms>" as *u8); sys_exit(CLI_EXIT_USAGE); return CLI_EXIT_USAGE } 24 let t: *u8 = argv[5] as *u8 25 cc_register(argv[2] as *u8, argv[3] as *u8, argv[4] as *u8, std_atoi(t)) 26 std_putln("CLAIMED (leash row claude_<sess8>; beat on progress; cadence supervises)" as *u8) 27 sys_exit(0) 28 return 0 29 } 30 if std_streq(verb, "beat" as *u8) == 1 { 31 if argc < 3 { std_putln("beat needs <sess8>" as *u8); sys_exit(CLI_EXIT_USAGE); return CLI_EXIT_USAGE } 32 cc_beat(argv[2] as *u8) 33 std_putln("BEAT" as *u8) 34 sys_exit(0) 35 return 0 36 } 37 if std_streq(verb, "release" as *u8) == 1 { 38 if argc < 3 { std_putln("release needs <sess8>" as *u8); sys_exit(CLI_EXIT_USAGE); return CLI_EXIT_USAGE } 39 cc_release(argv[2] as *u8) 40 std_putln("RELEASED" as *u8) 41 sys_exit(0) 42 return 0 43 } 44 if std_streq(verb, "check" as *u8) == 1 { 45 if argc < 4 { std_putln("check needs <sess8> <path>..." as *u8); sys_exit(CLI_EXIT_USAGE); return CLI_EXIT_USAGE } 46 let pathv: *i64 = ((argv as i64) + 24) as *i64 47 let v: i64 = cc_check(argv[2] as *u8, pathv, argc - 3) 48 sys_exit(v) 49 return v 50 } 51 if std_streq(verb, "walk" as *u8) == 1 { 52 let z: *u8 = sys_mmap(8) as *u8 53 z[0] = 0 as u8 54 cc_walk(z) 55 sys_exit(0) 56 return 0 57 } 58 std_putln("unknown verb (claim|beat|release|check|walk)" as *u8) 59 sys_exit(CLI_EXIT_USAGE) 60 return CLI_EXIT_USAGE 61}