@codyswann/lisa 4.88.1 → 4.89.0

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.
Files changed (164) hide show
  1. package/all/copy-overwrite/scripts/lisa-hooks/parity-safety-net.sh +150 -37
  2. package/dist/core/learnings.d.ts +1 -1
  3. package/dist/core/learnings.d.ts.map +1 -1
  4. package/dist/core/learnings.js +1 -1
  5. package/dist/core/learnings.js.map +1 -1
  6. package/dist/core/lisa-owned-hash-ledger.d.ts.map +1 -1
  7. package/dist/core/lisa-owned-hash-ledger.js +6 -0
  8. package/dist/core/lisa-owned-hash-ledger.js.map +1 -1
  9. package/dist/core/nightly-e2e-guard-behavior-certificate.js +2 -2
  10. package/dist/core/project-config-learnings.d.ts +21 -1
  11. package/dist/core/project-config-learnings.d.ts.map +1 -1
  12. package/dist/core/project-config-learnings.js +43 -6
  13. package/dist/core/project-config-learnings.js.map +1 -1
  14. package/dist/core/project-config.d.ts +1 -1
  15. package/dist/core/project-config.d.ts.map +1 -1
  16. package/dist/core/project-config.js +1 -1
  17. package/dist/core/project-config.js.map +1 -1
  18. package/dist/core/upstream-evidence-manifest.d.ts.map +1 -1
  19. package/dist/core/upstream-evidence-manifest.js +15 -13
  20. package/dist/core/upstream-evidence-manifest.js.map +1 -1
  21. package/dist/opencode/plugin-templates/parity-safety-net.sh +150 -37
  22. package/package.json +4 -4
  23. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  24. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  25. package/plugins/lisa/.codex-plugin/skills/lisa-github-build-intake/SKILL.md +1 -1
  26. package/plugins/lisa/.codex-plugin/skills/lisa-jira-build-intake/SKILL.md +1 -1
  27. package/plugins/lisa/.codex-plugin/skills/lisa-learnings-audit/SKILL.md +24 -1
  28. package/plugins/lisa/.codex-plugin/skills/lisa-linear-build-intake/SKILL.md +1 -1
  29. package/plugins/lisa/.codex-plugin/skills/lisa-persist-learning/SKILL.md +28 -3
  30. package/plugins/lisa/agents/learning-judge.md +5 -3
  31. package/plugins/lisa/commands/persist-learning.md +1 -1
  32. package/plugins/lisa/hooks/parity-safety-net.sh +150 -37
  33. package/plugins/lisa/rules/reference/claim-archaeology.md +2 -2
  34. package/plugins/lisa/rules/reference/config-resolution.md +1 -0
  35. package/plugins/lisa/rules/reference/factory-model.md +1 -1
  36. package/plugins/lisa/rules/reference/rejection-detection.md +3 -3
  37. package/plugins/lisa/skills/lisa-github-build-intake/SKILL.md +1 -1
  38. package/plugins/lisa/skills/lisa-jira-build-intake/SKILL.md +1 -1
  39. package/plugins/lisa/skills/lisa-learnings-audit/SKILL.md +24 -1
  40. package/plugins/lisa/skills/lisa-linear-build-intake/SKILL.md +1 -1
  41. package/plugins/lisa/skills/lisa-persist-learning/SKILL.md +28 -3
  42. package/plugins/lisa-agy/agents/learning-judge.md +5 -3
  43. package/plugins/lisa-agy/commands/lisa/persist-learning.md +1 -1
  44. package/plugins/lisa-agy/hooks/parity-safety-net.sh +150 -37
  45. package/plugins/lisa-agy/plugin.json +1 -1
  46. package/plugins/lisa-agy/skills/lisa-github-build-intake/SKILL.md +1 -1
  47. package/plugins/lisa-agy/skills/lisa-jira-build-intake/SKILL.md +1 -1
  48. package/plugins/lisa-agy/skills/lisa-learnings-audit/SKILL.md +24 -1
  49. package/plugins/lisa-agy/skills/lisa-linear-build-intake/SKILL.md +1 -1
  50. package/plugins/lisa-agy/skills/lisa-persist-learning/SKILL.md +28 -3
  51. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  52. package/plugins/lisa-cdk/.codex-plugin/plugin.json +1 -1
  53. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  54. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  55. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  56. package/plugins/lisa-cdk-devin/.claude-plugin/plugin.json +1 -1
  57. package/plugins/lisa-cdk-devin/.devin-plugin/plugin.json +1 -1
  58. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  59. package/plugins/lisa-copilot/agents/learning-judge.agent.md +5 -3
  60. package/plugins/lisa-copilot/commands/lisa/persist-learning.md +1 -1
  61. package/plugins/lisa-copilot/hooks/parity-safety-net.sh +150 -37
  62. package/plugins/lisa-copilot/rules/reference/claim-archaeology.md +2 -2
  63. package/plugins/lisa-copilot/rules/reference/config-resolution.md +1 -0
  64. package/plugins/lisa-copilot/rules/reference/factory-model.md +1 -1
  65. package/plugins/lisa-copilot/rules/reference/rejection-detection.md +3 -3
  66. package/plugins/lisa-copilot/skills/lisa-github-build-intake/SKILL.md +1 -1
  67. package/plugins/lisa-copilot/skills/lisa-jira-build-intake/SKILL.md +1 -1
  68. package/plugins/lisa-copilot/skills/lisa-learnings-audit/SKILL.md +24 -1
  69. package/plugins/lisa-copilot/skills/lisa-linear-build-intake/SKILL.md +1 -1
  70. package/plugins/lisa-copilot/skills/lisa-persist-learning/SKILL.md +28 -3
  71. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  72. package/plugins/lisa-cursor/agents/learning-judge.md +5 -3
  73. package/plugins/lisa-cursor/commands/lisa/persist-learning.md +1 -1
  74. package/plugins/lisa-cursor/hooks/parity-safety-net.sh +150 -37
  75. package/plugins/lisa-cursor/rules/claim-archaeology-reference.mdc +2 -2
  76. package/plugins/lisa-cursor/rules/config-resolution-reference.mdc +1 -0
  77. package/plugins/lisa-cursor/rules/factory-model-reference.mdc +1 -1
  78. package/plugins/lisa-cursor/rules/rejection-detection-reference.mdc +3 -3
  79. package/plugins/lisa-cursor/skills/lisa-github-build-intake/SKILL.md +1 -1
  80. package/plugins/lisa-cursor/skills/lisa-jira-build-intake/SKILL.md +1 -1
  81. package/plugins/lisa-cursor/skills/lisa-learnings-audit/SKILL.md +24 -1
  82. package/plugins/lisa-cursor/skills/lisa-linear-build-intake/SKILL.md +1 -1
  83. package/plugins/lisa-cursor/skills/lisa-persist-learning/SKILL.md +28 -3
  84. package/plugins/lisa-devin/.claude-plugin/plugin.json +1 -1
  85. package/plugins/lisa-devin/.devin-plugin/plugin.json +1 -1
  86. package/plugins/lisa-devin/agents/learning-judge.md +5 -3
  87. package/plugins/lisa-devin/hooks/parity-safety-net.sh +150 -37
  88. package/plugins/lisa-devin/rules/reference/claim-archaeology.md +2 -2
  89. package/plugins/lisa-devin/rules/reference/config-resolution.md +1 -0
  90. package/plugins/lisa-devin/rules/reference/factory-model.md +1 -1
  91. package/plugins/lisa-devin/rules/reference/rejection-detection.md +3 -3
  92. package/plugins/lisa-devin/skills/lisa-github-build-intake/SKILL.md +1 -1
  93. package/plugins/lisa-devin/skills/lisa-jira-build-intake/SKILL.md +1 -1
  94. package/plugins/lisa-devin/skills/lisa-learnings-audit/SKILL.md +24 -1
  95. package/plugins/lisa-devin/skills/lisa-linear-build-intake/SKILL.md +1 -1
  96. package/plugins/lisa-devin/skills/lisa-persist-learning/SKILL.md +28 -3
  97. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  98. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  99. package/plugins/lisa-expo-agy/plugin.json +1 -1
  100. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  101. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  102. package/plugins/lisa-expo-devin/.claude-plugin/plugin.json +1 -1
  103. package/plugins/lisa-expo-devin/.devin-plugin/plugin.json +1 -1
  104. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  105. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  106. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  107. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  108. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  109. package/plugins/lisa-harper-fabric-devin/.claude-plugin/plugin.json +1 -1
  110. package/plugins/lisa-harper-fabric-devin/.devin-plugin/plugin.json +1 -1
  111. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  112. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  113. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  114. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  115. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  116. package/plugins/lisa-nestjs-devin/.claude-plugin/plugin.json +1 -1
  117. package/plugins/lisa-nestjs-devin/.devin-plugin/plugin.json +1 -1
  118. package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
  119. package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
  120. package/plugins/lisa-openclaw-agy/plugin.json +1 -1
  121. package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
  122. package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
  123. package/plugins/lisa-openclaw-devin/.claude-plugin/plugin.json +1 -1
  124. package/plugins/lisa-openclaw-devin/.devin-plugin/plugin.json +1 -1
  125. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  126. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  127. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  128. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  129. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  130. package/plugins/lisa-phaser-devin/.claude-plugin/plugin.json +1 -1
  131. package/plugins/lisa-phaser-devin/.devin-plugin/plugin.json +1 -1
  132. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  133. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  134. package/plugins/lisa-rails-agy/plugin.json +1 -1
  135. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  136. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  137. package/plugins/lisa-rails-devin/.claude-plugin/plugin.json +1 -1
  138. package/plugins/lisa-rails-devin/.devin-plugin/plugin.json +1 -1
  139. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  140. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  141. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  142. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  143. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  144. package/plugins/lisa-typescript-devin/.claude-plugin/plugin.json +1 -1
  145. package/plugins/lisa-typescript-devin/.devin-plugin/plugin.json +1 -1
  146. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  147. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  148. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  149. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  150. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  151. package/plugins/lisa-wiki-devin/.claude-plugin/plugin.json +1 -1
  152. package/plugins/lisa-wiki-devin/.devin-plugin/plugin.json +1 -1
  153. package/plugins/src/base/agents/learning-judge.md +5 -3
  154. package/plugins/src/base/commands/persist-learning.md +1 -1
  155. package/plugins/src/base/hooks/parity-safety-net.sh +150 -37
  156. package/plugins/src/base/rules/reference/claim-archaeology.md +2 -2
  157. package/plugins/src/base/rules/reference/config-resolution.md +1 -0
  158. package/plugins/src/base/rules/reference/factory-model.md +1 -1
  159. package/plugins/src/base/rules/reference/rejection-detection.md +3 -3
  160. package/plugins/src/base/skills/lisa-github-build-intake/SKILL.md +1 -1
  161. package/plugins/src/base/skills/lisa-jira-build-intake/SKILL.md +1 -1
  162. package/plugins/src/base/skills/lisa-learnings-audit/SKILL.md +24 -1
  163. package/plugins/src/base/skills/lisa-linear-build-intake/SKILL.md +1 -1
  164. package/plugins/src/base/skills/lisa-persist-learning/SKILL.md +28 -3
@@ -728,6 +728,46 @@ follow_may_invoke() {
728
728
  return 1
729
729
  }
730
730
 
731
+ # Both the policy view and statement parser use these exact comment boundaries.
732
+ # This is fixed awk source, never source derived from the inspected command.
733
+ follow_comment_awk() {
734
+ printf '%s\n' '
735
+ # A hash starts a comment only at an unescaped shell word boundary.
736
+ # Backslash-newline pairs disappear before token recognition; a quoted or
737
+ # escaped blank is part of a word, not a boundary before its next hash.
738
+ function comment_start(at, before, escapes, k) {
739
+ before = at - 1;
740
+ while (before > 1 && substr(s, before, 1) == "\n" && substr(s, before - 1, 1) == "\\" && !comment_newline[before]) {
741
+ lookahead_step();
742
+ escapes = 0;
743
+ for (k = before - 1; k > 0 && substr(s, k, 1) == "\\"; k--) { lookahead_step(); escapes++ }
744
+ if (escapes % 2 == 0) { break }
745
+ before -= 2;
746
+ }
747
+ if (before == 0 || comment_newline[before]) { return 1 }
748
+ if (substr(s, before, 1) !~ /[ \t\n;&|()<>]/) { return 0 }
749
+ escapes = 0;
750
+ for (k = before - 1; k > 0 && substr(s, k, 1) == "\\"; k--) { lookahead_step(); escapes++ }
751
+ return escapes % 2 == 0;
752
+ }
753
+ function comment_end(at, end) {
754
+ # Address one byte at a time rather than copying the remaining file for
755
+ # every short comment. Repeated lookahead shares the existing work cap.
756
+ for (end = at; end <= n && substr(s, end, 1) != "\n"; end++) { lookahead_step() }
757
+ # Backslashes inside discarded comments do not escape their newline.
758
+ # Share this fact with the main walk and every lookahead that skips it.
759
+ if (end <= n) { comment_newline[end] = 1 }
760
+ return end;
761
+ }
762
+ # Lexical lookahead keeps an asynchronous return from ending its parent
763
+ # scan before the trailing & event. Aggregate work is capped linearly in
764
+ # input size, including overlap from nested scopes; no partial parse passes.
765
+ function lookahead_step() {
766
+ if (++lookahead_work > 8 * n + 1024) { exit 2 }
767
+ }
768
+ '
769
+ }
770
+
731
771
  # Split the command into statements at UNQUOTED separators, printing one
732
772
  # statement per line as "<separator><TAB><statement>". Quote-aware on purpose: a
733
773
  # `;` or `|` inside a quoted string is not a statement boundary, and splitting
@@ -743,21 +783,18 @@ follow_may_invoke() {
743
783
  # arrives through the ENVIRONMENT: `awk -v` processes backslash escapes in the
744
784
  # value it is given and would rewrite the command before it was ever read.
745
785
  follow_split() {
746
- LC_ALL=C SN_FOLLOW_TEXT="$1" awk '
747
- # Lexical lookahead keeps an asynchronous return from ending its parent
748
- # scan before the trailing & event. Aggregate work is capped linearly in
749
- # input size, including overlap from nested scopes; no partial parse passes.
750
- function lookahead_step() {
751
- if (++lookahead_work > 8 * n + 1024) { exit 2 }
752
- }
753
- function brace_pipe(from, opening, closing, j, c, quote, escape, braces, nesting, tail, tail_cases, tail_header, word, word_end) {
754
- quote = ""; escape = 0; braces = 1; nesting = 0; brace_redirect = ""; tail_cases = 0; tail_header = 0;
786
+ LC_ALL=C SN_FOLLOW_TEXT="$1" awk "$(follow_comment_awk)"'
787
+ function brace_pipe(from, opening, closing, j, c, quote, escape, braces, nesting, tail, tail_cases, tail_header, word, word_end, parameters) {
788
+ quote = ""; escape = 0; braces = 1; nesting = 0; brace_redirect = ""; tail_cases = 0; tail_header = 0; parameters = 0;
755
789
  for (j = from; j <= n; j++) {
756
790
  lookahead_step(); c = substr(s, j, 1);
757
- if (escape) { escape = 0; continue }
791
+ if (escape) { if (c == "$") { literal_dollars[j] = 1 } escape = 0; continue }
758
792
  if (c == "\\" && quote != "\047") { escape = 1; continue }
759
793
  if (quote != "") { if (c == quote) { quote = "" } continue }
760
794
  if (c == "\"" || c == "\047" || c == "`") { quote = c; continue }
795
+ if (c == "{" && (parameters > 0 || (substr(s, j - 1, 1) == "$" && !literal_dollars[j - 1]))) { parameters++; continue }
796
+ if (c == "}" && parameters > 0) { parameters--; continue }
797
+ if (c == "#" && parameters == 0 && comment_start(j)) { j = comment_end(j) - 1; continue }
761
798
  if (braces > 0) {
762
799
  # A case-pattern ) is not the closing parenthesis of its shell.
763
800
  if (opening == "(" && c ~ /[A-Za-z_]/) {
@@ -791,15 +828,18 @@ follow_split() {
791
828
  if (tail > 0) { brace_redirect = substr(s, tail) }
792
829
  return 0;
793
830
  }
794
- function list_async(from, j, c, quote, escape, nesting, braces) {
795
- quote = ""; escape = 0; nesting = 0; braces = 0;
831
+ function list_async(from, j, c, quote, escape, nesting, braces, parameters) {
832
+ quote = ""; escape = 0; nesting = 0; braces = 0; parameters = 0;
796
833
  for (j = from; j <= n; j++) {
797
834
  lookahead_step();
798
835
  c = substr(s, j, 1);
799
- if (escape) { escape = 0; continue }
836
+ if (escape) { if (c == "$") { literal_dollars[j] = 1 } escape = 0; continue }
800
837
  if (c == "\\" && quote != "\047") { escape = 1; continue }
801
838
  if (quote != "") { if (c == quote) { quote = "" } continue }
802
839
  if (c == "\"" || c == "\047" || c == "`") { quote = c; continue }
840
+ if (c == "{" && (parameters > 0 || (substr(s, j - 1, 1) == "$" && !literal_dollars[j - 1]))) { parameters++; continue }
841
+ if (c == "}" && parameters > 0) { parameters--; continue }
842
+ if (c == "#" && parameters == 0 && comment_start(j)) { j = comment_end(j) - 1; continue }
803
843
  if (c == "(") { nesting++; continue }
804
844
  if (c == ")") { if (nesting == 0) { return 0 } nesting--; continue }
805
845
  if (c == "{") { braces++; continue }
@@ -810,6 +850,24 @@ follow_split() {
810
850
  }
811
851
  return 0;
812
852
  }
853
+ # The reader consumes physical lines, but an unquoted/double-quoted
854
+ # backslash-newline is absent from the shell word. Preserve that join in
855
+ # emitted statements too: otherwise the next physical line can start with
856
+ # a literal word-owned hash and be discarded as a full-line comment.
857
+ function logical_lines(text, k, c, quote, escape, from, out) {
858
+ quote = ""; escape = 0; from = 1; out = "";
859
+ for (k = 1; k <= length(text); k++) {
860
+ c = substr(text, k, 1);
861
+ if (escape) {
862
+ if (c == "\n") { out = out substr(text, from, k - from - 1); from = k + 1 }
863
+ escape = 0; continue;
864
+ }
865
+ if (c == "\\" && quote != "\047") { escape = 1; continue }
866
+ if (quote != "") { if (c == quote) { quote = "" } continue }
867
+ if (c == "\"" || c == "\047") { quote = c }
868
+ }
869
+ return out substr(text, from);
870
+ }
813
871
  # U records tell the walker the stream below may not match the shell, so
814
872
  # a compound closer can no longer be trusted (follow_compound_close). They
815
873
  # only ever ADD distrust; every other record is emitted exactly as before.
@@ -819,6 +877,7 @@ follow_split() {
819
877
  # can spell `done` or `fi` on its own.
820
878
  function record(kind, text) {
821
879
  if (text ~ /\n/) { printf "U\t\n" }
880
+ text = logical_lines(text);
822
881
  printf "%s\t%s\n", kind, text;
823
882
  }
824
883
  # The first word of one separator-delimited piece of a comment, as the
@@ -828,8 +887,10 @@ follow_split() {
828
887
  gsub(/["\047]/, "", piece);
829
888
  return piece ~ /^(fi|done|esac|case|if|then|else|elif|do|while|until|for|select|function|!|\{|\})$/;
830
889
  }
831
- # This split does not recognise comments, so a comment is split as code. It
832
- # is harmless only when that split cannot change any structure the walker
890
+ # Retain the existing distrust signal for comments whose former split could
891
+ # change scope. Removing their text must not loosen a refusal that depended
892
+ # on conservative flow tracking. A comment is harmless to that tracking only
893
+ # when its former split cannot change any structure the walker
833
894
  # tracks: no piece after a separator starts with a reserved word, quotes
834
895
  # close, parentheses and braces balance, and nothing escapes or substitutes.
835
896
  # Inside a case pattern a `)` ends the pattern, so it is never harmless
@@ -861,7 +922,13 @@ follow_split() {
861
922
  if (pieces > 0 && comment_reserved(piece)) { return 1 }
862
923
  return cq != "" || parens != 0 || braces != 0;
863
924
  }
864
- function comment_check(at, pattern) {
925
+ function comment_check(at, pattern, from) {
926
+ # Full physical comment lines were absent from the old policy view and
927
+ # must not introduce new scope uncertainty merely because the parser now
928
+ # receives raw source. Inline comments keep the existing distrust rule.
929
+ if (at != 1 && substr(s, at - 1, 1) !~ /[[:space:];&|()]/) { return }
930
+ for (from = at - 1; from > 0 && substr(s, from, 1) != "\n"; from--) { lookahead_step() }
931
+ if (substr(s, from + 1, at - from - 1) ~ /^[[:space:]]*$/) { return }
865
932
  if ((at == 1 || substr(s, at - 1, 1) ~ /[[:space:];&|()]/) && comment_unsafe(at + 1, pattern)) {
866
933
  printf "U\t\n";
867
934
  }
@@ -869,16 +936,21 @@ follow_split() {
869
936
  BEGIN {
870
937
  s = ENVIRON["SN_FOLLOW_TEXT"]; n = length(s);
871
938
  q = ""; esc = 0; start = 1; sep = "o"; parens = 0;
872
- functions = 0; cases = 0; backtick = 0; brace_depth = 0; post_brace = 0;
939
+ functions = 0; cases = 0; backtick = 0; brace_depth = 0; post_brace = 0; parameters = 0;
873
940
  printf "L\t%d\n", list_async(1);
874
941
  for (i = 1; i <= n; i++) {
875
- c = substr(s, i, 1);
942
+ c = substr(s, i, 1); comment_from = 0;
876
943
  if (esc == 1) { if (c == "$") { literal_dollars[i] = 1 } esc = 0; continue }
877
944
  if (c == "\\" && q != "\047") { esc = 1; continue }
878
945
  if (functions > 0) {
879
946
  if (q != "") { if (c == q) { q = "" } continue }
880
947
  if (c == "\"" || c == "\047") { q = c; continue }
881
- if (c == "#") { comment_check(i, 0) }
948
+ if (c == "{" && (parameters > 0 || (substr(s, i - 1, 1) == "$" && !literal_dollars[i - 1]))) { parameters++; continue }
949
+ if (parameters > 0) { if (c == "}") { parameters-- } continue }
950
+ if (c == "#") {
951
+ comment_check(i, 0);
952
+ if (comment_start(i)) { i = comment_end(i) - 1; continue }
953
+ }
882
954
  if (c == "{") { functions++ }
883
955
  if (c == "}" && --functions == 0) {
884
956
  printf "N\t%s\t%s\n", sep, function_name;
@@ -892,7 +964,12 @@ follow_split() {
892
964
  quoted_expression = q == "\"" && ((c == "(" && substr(s, i - 1, 1) == "$" && !literal_dollars[i - 1]) || c == "`");
893
965
  if (q != "" && !quoted_expression) { if (c == q) { q = "" } continue }
894
966
  if (c == "\"" || c == "\047") { q = c; continue }
895
- if (c == "#") { comment_check(i, cases > 0 && case_scopes[cases] == parens && case_patterns[cases]) }
967
+ if (c == "{" && (parameters > 0 || (substr(s, i - 1, 1) == "$" && !literal_dollars[i - 1]))) { parameters++; continue }
968
+ if (c == "}" && parameters > 0) { parameters--; continue }
969
+ if (c == "#") {
970
+ comment_check(i, cases > 0 && case_scopes[cases] == parens && case_patterns[cases]);
971
+ if (parameters == 0 && comment_start(i)) { comment_from = i; i = comment_end(i); if (i > n) { i = n } c = "\n" }
972
+ }
896
973
  if (c == "`") {
897
974
  if (backtick) {
898
975
  piece = substr(s, start, i - start);
@@ -904,7 +981,7 @@ follow_split() {
904
981
  }
905
982
  continue;
906
983
  }
907
- if (i == start && c ~ /[[:space:]]/) { start = i + 1; continue }
984
+ if (i == start && c ~ /[ \t\n]/) { start = i + 1; continue }
908
985
  if (c ~ /[[:space:]]/ && substr(s, i - 1, 1) !~ /[[:space:]]/ && substr(s, start, 4) == "case") {
909
986
  piece = substr(s, start, i - start);
910
987
  if (piece ~ /^case[[:space:]].*[[:space:]]in$/) {
@@ -922,17 +999,17 @@ follow_split() {
922
999
  }
923
1000
  if (c == "{") {
924
1001
  piece = substr(s, start, i - start);
925
- definition = piece ~ /^[[:space:]]*([A-Za-z_][A-Za-z_0-9]*[[:space:]]*\([[:space:]]*\)|function[[:space:]]+[A-Za-z_][A-Za-z_0-9]*([[:space:]]*\([[:space:]]*\))?)[[:space:]]*$/;
1002
+ definition = piece ~ /^[ \t\n]*([A-Za-z_][A-Za-z_0-9]*[ \t]*\([ \t]*\)|function[ \t]+[A-Za-z_][A-Za-z_0-9]*([ \t]*\([ \t]*\))?)[ \t\n]*$/;
926
1003
  if (definition) {
927
1004
  function_name = piece;
928
- sub(/^[[:space:]]*(function[[:space:]]+)?/, "", function_name);
929
- sub(/[[:space:]\(].*$/, "", function_name);
1005
+ sub(/^[ \t\n]*(function[ \t]+)?/, "", function_name);
1006
+ sub(/[ \t\n\(].*$/, "", function_name);
930
1007
  functions = 1; function_start = i + 1;
931
1008
  continue;
932
1009
  }
933
1010
  previous = i > 1 ? substr(s, i - 1, 1) : "";
934
- group = (i == 1 || previous ~ /[[:space:];&|()]/) && substr(s, i + 1, 1) ~ /[[:space:];]/ &&
935
- piece ~ /^[[:space:]]*((then|do|else|!|time)[[:space:]]+)*$/;
1011
+ group = (i == 1 || previous ~ /[ \t\n;&|()]/) && substr(s, i + 1, 1) ~ /[ \t\n;]/ &&
1012
+ piece ~ /^[ \t\n]*((then|do|else|!|time)[ \t\n]+)*$/;
936
1013
  brace_groups[++brace_depth] = group;
937
1014
  if (group) {
938
1015
  brace_sep = sep;
@@ -963,10 +1040,10 @@ follow_split() {
963
1040
  if (c == "(") {
964
1041
  previous = i > 1 ? substr(s, i - 1, 1) : "";
965
1042
  piece = substr(s, start, i - start);
966
- header = piece ~ /^[[:space:]]*(function[[:space:]]+)?[A-Za-z_][A-Za-z_0-9]*[[:space:]]*$/ && substr(s, i + 1) ~ /^[[:space:]]*\)/;
1043
+ header = piece ~ /^[ \t]*(function[ \t]+)?[A-Za-z_][A-Za-z_0-9]*[ \t]*$/ && substr(s, i + 1) ~ /^[ \t]*\)/;
967
1044
  expression = previous ~ /[$<>]/ && !literal_dollars[i - 1] && substr(s, i + 1, 1) != "(";
968
1045
  group = (parens == 0 || scopes[parens] != 0) &&
969
- (i == 1 || previous ~ /[[:space:];&|()]/) && substr(s, i + 1, 1) != "(" && !header;
1046
+ (i == 1 || previous ~ /[ \t\n;&|()]/) && substr(s, i + 1, 1) != "(" && !header;
970
1047
  scopes[++parens] = expression ? 2 : group;
971
1048
  if (expression) {
972
1049
  expression_starts[parens] = start;
@@ -999,7 +1076,7 @@ follow_split() {
999
1076
  if (c == ";" || c == "&" || c == "|" || c == "\n") {
1000
1077
  if (parens > 0 && scopes[parens] == 0) { continue }
1001
1078
  if (c == "&" && (substr(s, i - 1, 1) ~ /[<>]/ || substr(s, i + 1, 1) == ">")) { continue }
1002
- piece = substr(s, start, i - start);
1079
+ piece = substr(s, start, (comment_from ? comment_from : i) - start);
1003
1080
  pipe = c == "|" && substr(s, i + 1, 1) != "|";
1004
1081
  if (pipe || sep == "|") { printf "(\t%s%s\nL\t%d\n", (sep == "|" ? "|" : ""), (pipe ? "+" : ""), list_async(start) }
1005
1082
  if (piece ~ /[^[:space:]]/) { record(post_brace ? "R" : sep, piece) }
@@ -1172,11 +1249,46 @@ follow_locate() {
1172
1249
  return 1
1173
1250
  }
1174
1251
 
1252
+ # Drop a physical comment line only at a real logical shell word boundary.
1253
+ # A blank after a joined newline can start a comment, but a hash in a quoted or
1254
+ # continued word cannot. Keep the old conservative inline-comment policy while
1255
+ # sharing comment/newline provenance and work bounds with the statement parser.
1256
+ follow_policy_text() {
1257
+ LC_ALL=C SN_FOLLOW_TEXT="$1" awk "$(follow_comment_awk)"'
1258
+ BEGIN {
1259
+ s = ENVIRON["SN_FOLLOW_TEXT"]; n = length(s);
1260
+ quote = ""; escape = 0; parameters = 0; line_start = 1; from = 1;
1261
+ for (i = 1; i <= n; i++) {
1262
+ lookahead_step(); c = substr(s, i, 1);
1263
+ if (c == "\n") { line_start = i + 1 }
1264
+ if (escape) { if (c == "$") { literal_dollars[i] = 1 } escape = 0; continue }
1265
+ if (c == "\\" && quote != "\047") { escape = 1; continue }
1266
+ if (quote != "") { if (c == quote) { quote = "" } continue }
1267
+ if (c == "\"" || c == "\047" || c == "`") { quote = c; continue }
1268
+ if (c == "{" && (parameters > 0 || (substr(s, i - 1, 1) == "$" && !literal_dollars[i - 1]))) { parameters++; continue }
1269
+ if (c == "}" && parameters > 0) { parameters--; continue }
1270
+ if (c == "#" && parameters == 0 && comment_start(i)) {
1271
+ end = comment_end(i);
1272
+ if (substr(s, line_start, i - line_start) ~ /^[ \t]*$/) {
1273
+ printf "%s", substr(s, from, line_start - from);
1274
+ from = end;
1275
+ }
1276
+ # Ignore quotes and backslashes owned by any real comment, including
1277
+ # inline comments whose bytes the conservative policy view retains.
1278
+ i = end - 1;
1279
+ }
1280
+ }
1281
+ printf "%s", substr(s, from);
1282
+ }
1283
+ '
1284
+ }
1285
+
1175
1286
  # Read one executed file into the text the guards will scan, then follow what IT
1176
- # executes, to a bounded depth. Full-line comments are dropped: a commented line
1177
- # is never executed, so scanning it can only manufacture a false refusal.
1287
+ # executes, to a bounded depth. Text policies retain their comment-free view;
1288
+ # the statement parser needs original physical lines to distinguish a comment
1289
+ # from a word-owned hash after a backslash-newline join.
1178
1290
  follow_take() {
1179
- local path="$1" depth="$2" size="" content="" rm_content="${3-}"
1291
+ local path="$1" depth="$2" size="" content="" source_content="" rm_content="${3-}"
1180
1292
  local invocation_kind=child
1181
1293
  if [ "$#" -eq 3 ]; then invocation_kind="$3"; fi
1182
1294
  case "$follow_paths" in
@@ -1205,17 +1317,18 @@ follow_take() {
1205
1317
  if [ "$#" -eq 4 ]; then
1206
1318
  # Scan the same complete bytes whose digest was authenticated, not a
1207
1319
  # second file read that could pair changed source with the cleanup view.
1208
- content="$(printf '%s' "$4" | sed 's/^[[:space:]]*#.*$//')" || follow_refuse "$path" "authenticated source could not be read"
1320
+ source_content="$4"
1209
1321
  else
1210
- content="$(LC_ALL=C tr -d '\000' <"$path" | sed 's/^[[:space:]]*#.*$//')" \
1322
+ source_content="$(LC_ALL=C tr -d '\000' <"$path")" \
1211
1323
  || follow_refuse "$path" "it could not be read"
1212
1324
  fi
1325
+ content="$(follow_policy_text "$source_content")" || follow_refuse "$path" "source policy view could not be read"
1213
1326
  follow_names="$follow_names $path"
1214
1327
  followed_text="$followed_text"$'\n'"$content"
1215
1328
  if [ "$#" -ne 4 ]; then
1216
1329
  rm_content="$content"
1217
1330
  else
1218
- rm_content="$(printf '%s' "$rm_content" | sed 's/^[[:space:]]*#.*$//')" || follow_refuse "$path" "supervisor cleanup view could not be read"
1331
+ rm_content="$(follow_policy_text "$rm_content")" || follow_refuse "$path" "supervisor cleanup view could not be read"
1219
1332
  fi
1220
1333
  followed_rm_text="$followed_rm_text"$'\n'"$rm_content"
1221
1334
  if [ "$depth" -lt "$FOLLOW_MAX_DEPTH" ]; then
@@ -1229,9 +1342,9 @@ follow_take() {
1229
1342
  # followed separately by follow_supervisor. Re-expanding all bootstrap
1230
1343
  # functions would re-interpret its internal protocol, not inspect a new
1231
1344
  # user-controlled file, and multiplied its native hook time fourfold.
1232
- follow_scan "$content" "$((depth + 1))" 0 1
1345
+ follow_scan "$source_content" "$((depth + 1))" 0 1
1233
1346
  else
1234
- follow_scan "$content" "$((depth + 1))" 0 0 "$invocation_kind"
1347
+ follow_scan "$source_content" "$((depth + 1))" 0 0 "$invocation_kind"
1235
1348
  fi
1236
1349
  if [ "$invocation_kind" != source ]; then
1237
1350
  follow_cwd="$saved_cwd"
@@ -30,7 +30,7 @@ Return exactly one of:
30
30
 
31
31
  ## Learning-loop exclusion (scan-side)
32
32
 
33
- An artifact this flow produced is **never** an ancestor. Exclude anything carrying `[lisa-learning-drop]`, `[lisa-learning-pr]`, `[lisa-learning-upstream-handoff]`, `[lisa-rejection-candidate]`, or `[lisa-archaeology-candidate]` markers, or the `learning:needs-triage` label.
33
+ An artifact this flow produced is **never** an ancestor. Exclude anything carrying `[lisa-learning-drop]`, `[lisa-learning-pr]`, `[lisa-learning-upstream-handoff]`, `[lisa-rejection-candidate]`, or `[lisa-archaeology-candidate]` markers, or the `learning:needs-triage` or `learning:low-confidence` label.
34
34
 
35
35
  ## Cost budget — never block the claim
36
36
 
@@ -114,7 +114,7 @@ Before any candidate is promoted to ancestor, exclude every artifact carrying an
114
114
  - `[lisa-learning-upstream-handoff]`
115
115
  - `[lisa-rejection-candidate]`
116
116
  - `[lisa-archaeology-candidate]` (this rule's own producer tag — archaeology's output must not seed the next claim's input)
117
- - the `learning:needs-triage` label
117
+ - the `learning:needs-triage` or `learning:low-confidence` label
118
118
 
119
119
  This is the **scan-side** half of the no-learning-loops guard; `rejection-detection` carries the symmetric **trigger-side** half ("a learning artifact is never a rejection-reflection trigger").
120
120
 
@@ -277,6 +277,7 @@ fi
277
277
  | `source` | no | — | Default PRD source for batch skills (`/lisa:intake`) and arg-less single-PRD skills. One of `"notion"`, `"confluence"`, `"linear"`, `"github"`, `"jira"`. Explicit URLs/keys passed to a skill always win over `source`; this is a default, not a lock. |
278
278
  | ~~`projectRulesFile`~~ | — | — | **Retired.** Host-authored rules now live in the fixed, agent-neutral directory `.agents/rules/` — not a configurable file. An existing key is still parsed and preserved so installed projects keep applying, but nothing serves rules from it. See **Host rules** below. |
279
279
  | `learnings.file` | no | `.lisa/PROJECT_LEARNINGS.md` | Safe repo-relative Markdown path for the machine-managed learnings ledger, overriding the `.lisa/` default. Rejected if it resolves inside any auto-loaded rules tree (`.claude/rules`, `.cursor/rules`, `.github/instructions`, `.agents/rules`) — the ledger must stay out of eager context. |
280
+ | `learnings.lowConfidence` | no | `human-triage` | How `lisa-persist-learning` submits a low-confidence learning PR. `human-triage` keeps auto-merge off and labels it `learning:needs-triage` for a human to merge or close. `auto-merge` submits it like a high-confidence PR, merging through the project's normal gates, labeled `learning:low-confidence`; `lisa-learnings-audit` then re-reviews those entries first. Any other value is rejected. |
280
281
  | `health.schedule` | no | `off` | Health cadence contract: `off`, `daily`, or `weekly`. `lisa sync` populates the default with `_lisaSync.populated` provenance and rejects values outside this closed vocabulary. Runtime results live only at the gitignored `.lisa/health/latest.json`, never in either config file. |
281
282
  | `usage` | no | — | Optional token/cost pricing metadata consumed by the `usage-accounting` rule. Missing pricing never blocks a lifecycle flow; Lisa records token counts with `estimated_cost: null` when no trustworthy price source is configured. |
282
283
  | `humanGate.humanOnly` | no | `[]` | Decision classes this project reserves for a person, such as `["pricing"]`. A `human_gate` reason naming one (as a whole word) is accepted by the writers and never lifted by the sweeps. Absent, only acts an agent cannot perform qualify as a human gate. `.lisa.config.local.json` replaces the list when it sets one. Read by `scripts/human-gate-act.mjs`; see `ready-role-filing`, "What a human gate is". |
@@ -64,7 +64,7 @@ Humans act only at explicit exterior gates:
64
64
 
65
65
  - flipping a draft they chose to hold back to `prd-ready` / `status:ready`,
66
66
  - approving protected deployments (`github.environments.require_approval`),
67
- - reviewing low-confidence learning PRs (auto-merge off),
67
+ - reviewing low-confidence learning PRs (auto-merge off, unless the project sets `learnings.lowConfidence: "auto-merge"`),
68
68
  - answering what intake rejected and raised.
69
69
 
70
70
  Inside a flow, never pause to ask a human whether to proceed — the invocation was the authorization.
@@ -37,7 +37,7 @@ Return exactly one of:
37
37
 
38
38
  ## Learning-loop exclusion (no learning about learning)
39
39
 
40
- An artifact this flow produced is **never** a rejection-reflection trigger, no matter how it moves. Before classifying as `rejection-reclaim`, exclude items carrying any learning marker — `[lisa-learning-drop]`, `[lisa-learning-pr]`, `[lisa-learning-upstream-handoff]` — or the `learning:needs-triage` label. Such items short-circuit to `forward-only` (treated as normal work) so the detector never fires on the flow's own learning PRs/issues.
40
+ An artifact this flow produced is **never** a rejection-reflection trigger, no matter how it moves. Before classifying as `rejection-reclaim`, exclude items carrying any learning marker — `[lisa-learning-drop]`, `[lisa-learning-pr]`, `[lisa-learning-upstream-handoff]` — or the `learning:needs-triage` or `learning:low-confidence` label. Such items short-circuit to `forward-only` (treated as normal work) so the detector never fires on the flow's own learning PRs/issues.
41
41
 
42
42
  ## Reflect on a `rejection-reclaim`
43
43
 
@@ -120,7 +120,7 @@ resolved per the `config-resolution` rule with the `src/sync/registry.ts` `BUILD
120
120
 
121
121
  This flow persists learnings via PRs and files upstream issues, so its own artifacts are themselves rejectable. If a learning PR or an auto-filed upstream issue is ever moved backward, a naive detector would fire `rejection-reclaim` on it and reflect on the flow's own output — a learning about learning, recursively.
122
122
 
123
- The trigger is therefore **suppressed at the source**. Before an item is classified `rejection-reclaim`, exclude it if it carries any of the learning producer markers — `[lisa-learning-drop]`, `[lisa-learning-pr]`, `[lisa-learning-upstream-handoff]` (embedded in the artifact body/PR the same way other Lisa markers are) — or the `learning:needs-triage` label. An excluded item is treated as `forward-only` (normal work); the rejection-reflection path never fires on it, no matter how the artifact moved. (These markers ship with the learning-persistence flow; reference them by name — do not assume their files are present in this branch.)
123
+ The trigger is therefore **suppressed at the source**. Before an item is classified `rejection-reclaim`, exclude it if it carries any of the learning producer markers — `[lisa-learning-drop]`, `[lisa-learning-pr]`, `[lisa-learning-upstream-handoff]` (embedded in the artifact body/PR the same way other Lisa markers are) — or the `learning:needs-triage` or `learning:low-confidence` label. An excluded item is treated as `forward-only` (normal work); the rejection-reflection path never fires on it, no matter how the artifact moved. (These markers ship with the learning-persistence flow; reference them by name — do not assume their files are present in this branch.)
124
124
 
125
125
  This is the **trigger-side** half of the no-learning-loops guard. The claim-time archaeology path carries the symmetric **scan-side** exclusion ("a learning PR is never treated as an ancestor").
126
126
 
@@ -286,7 +286,7 @@ The lanes compared ALWAYS come from `.lisa.config.json` — `github.labels.build
286
286
 
287
287
  ### Learning-loop exclusion
288
288
 
289
- The same learning-loop exclusion applies, for the same reason and by the same markers: an item carrying `[lisa-learning-drop]`, `[lisa-learning-pr]`, `[lisa-learning-upstream-handoff]` or the `learning:needs-triage` label is never classified `automation-reversal`, no matter how it moved. The flow must not remember being corrected about its own learning artifacts.
289
+ The same learning-loop exclusion applies, for the same reason and by the same markers: an item carrying `[lisa-learning-drop]`, `[lisa-learning-pr]`, `[lisa-learning-upstream-handoff]` or the `learning:needs-triage` or `learning:low-confidence` label is never classified `automation-reversal`, no matter how it moved. The flow must not remember being corrected about its own learning artifacts.
290
290
 
291
291
  ### The rule — a reversal raises the bar, it never resets the clock
292
292
 
@@ -498,7 +498,7 @@ A blocker is active if it is open and has no cleared status label. Treat `status
498
498
  Before the claim mutation, apply `claim-time-guards` — **Value before claim**, or **Worth doing** in `lisa-track` on runtimes without the rule tree (Antigravity). A ready label establishes neither value nor permission to expand scope. Respect the preceding human-hold gate; a declined incidental item consumes this cycle's one processed disposition.
499
499
 
500
500
 
501
- **Rejection detection runs first — before the relabel below.** Per the vendor-neutral `rejection-detection` rule (cite the slug; do not restate its classification table), classify this item at the **top of 3b, BEFORE** the `$READY → $CLAIMED` relabel — after the relabel the current-lane signal is gone. Read the item's Label-Event History from `lisa-github-read-issue` (chronological `LabeledEvent` / `UnlabeledEvent` on the configured `$READY` label) and classify it `rejection-reclaim | forward-only | never-left-ready | unknown`. Lane names come from `.lisa.config.json` (`github.labels.build.*`), never hardcoded. A failing/absent history yields `unknown` and the claim proceeds — detection never blocks the build. Items carrying a learning marker (`[lisa-learning-drop]` / `[lisa-learning-pr]` / `[lisa-learning-upstream-handoff]`) or the `learning:needs-triage` label are never rejection triggers (no learning-about-learning). Carry the classification into the relabel and lifecycle below.
501
+ **Rejection detection runs first — before the relabel below.** Per the vendor-neutral `rejection-detection` rule (cite the slug; do not restate its classification table), classify this item at the **top of 3b, BEFORE** the `$READY → $CLAIMED` relabel — after the relabel the current-lane signal is gone. Read the item's Label-Event History from `lisa-github-read-issue` (chronological `LabeledEvent` / `UnlabeledEvent` on the configured `$READY` label) and classify it `rejection-reclaim | forward-only | never-left-ready | unknown`. Lane names come from `.lisa.config.json` (`github.labels.build.*`), never hardcoded. A failing/absent history yields `unknown` and the claim proceeds — detection never blocks the build. Items carrying a learning marker (`[lisa-learning-drop]` / `[lisa-learning-pr]` / `[lisa-learning-upstream-handoff]`) or the `learning:needs-triage` or `learning:low-confidence` label are never rejection triggers (no learning-about-learning). Carry the classification into the relabel and lifecycle below.
502
502
 
503
503
  **On `rejection-reclaim`, reflect before re-implementing** (per `rejection-detection`): read the rejection evidence through the access layer — the issue comments posted after the backward transition (the QA rejection comment) and the review threads on the rejected PR via `lisa-github-read-issue` — assemble ONE candidate learning (rule, why, provenance linking the rejection comment + rejected PR, evidence links, scope hint, triggering issue, fingerprint `sll4-sha1(rule\ntriggering_issue)[:12]`), and route it to the `lisa-persist-learning` skill. If that skill is absent, record the candidate as a comment carrying a **visible prose line plus** the marker (a bare marker renders as an empty bubble) — `Recorded a candidate learning from this rejection (queued for the judgment gate): <one-line candidate rule>.` then `<!-- [lisa-rejection-candidate] key=<issue>-<transition-ts> -->` — and proceed. Dedupe on `<issue>-<backward-transition-timestamp>` — a second re-claim produces no duplicate. Unreadable/absent evidence → no candidate, still implement.
504
504
 
@@ -379,7 +379,7 @@ This gate never blocks a legitimate flat Task/Bug: those have no open children a
379
379
  Before the claim mutation, apply `claim-time-guards` — **Value before claim**, or **Worth doing** in `lisa-track` on runtimes without the rule tree (Antigravity). A ready label establishes neither value nor permission to expand scope. Respect the preceding human-hold gate; a declined incidental item consumes this cycle's one processed disposition.
380
380
 
381
381
 
382
- **Rejection detection runs first — before the transition below.** Per the vendor-neutral `rejection-detection` rule (cite the slug; do not restate its classification table), classify this ticket at the **top of 3b, BEFORE** the `$READY → $CLAIMED` transition — after the transition the current-status signal is gone. Read the ticket's status changelog via `lisa-atlassian-access operation: changelog key: <TICKET>` and classify it `rejection-reclaim | forward-only | never-left-ready | unknown` (a `rejection-reclaim` is a changelog entry whose `to` is the configured `$READY` status following an earlier `review`/`done`-ward status). Status names come from `.lisa.config.json`, never hardcoded. A failing/absent changelog yields `unknown` and the claim proceeds — detection never blocks the build. Tickets carrying a learning marker (`[lisa-learning-drop]` / `[lisa-learning-pr]` / `[lisa-learning-upstream-handoff]`) or the `learning:needs-triage` label are never rejection triggers (no learning-about-learning). Carry the classification into the transition and lifecycle below.
382
+ **Rejection detection runs first — before the transition below.** Per the vendor-neutral `rejection-detection` rule (cite the slug; do not restate its classification table), classify this ticket at the **top of 3b, BEFORE** the `$READY → $CLAIMED` transition — after the transition the current-status signal is gone. Read the ticket's status changelog via `lisa-atlassian-access operation: changelog key: <TICKET>` and classify it `rejection-reclaim | forward-only | never-left-ready | unknown` (a `rejection-reclaim` is a changelog entry whose `to` is the configured `$READY` status following an earlier `review`/`done`-ward status). Status names come from `.lisa.config.json`, never hardcoded. A failing/absent changelog yields `unknown` and the claim proceeds — detection never blocks the build. Tickets carrying a learning marker (`[lisa-learning-drop]` / `[lisa-learning-pr]` / `[lisa-learning-upstream-handoff]`) or the `learning:needs-triage` or `learning:low-confidence` label are never rejection triggers (no learning-about-learning). Carry the classification into the transition and lifecycle below.
383
383
 
384
384
  **On `rejection-reclaim`, reflect before re-implementing** (per `rejection-detection`): read the rejection evidence through the access layer — the ticket comments posted after the backward transition (the QA rejection comment) via `lisa-atlassian-access operation: read-ticket` / `comment` reads and the review threads on the rejected PR — assemble ONE candidate learning (rule, why, provenance linking the rejection comment + rejected PR, evidence links, scope hint, triggering issue, fingerprint `sll4-sha1(rule\ntriggering_issue)[:12]`), and route it to the `lisa-persist-learning` skill. If that skill is absent, record the candidate via `lisa-atlassian-access operation: comment` as a comment carrying a **visible prose line plus** the marker (a bare marker renders as an empty bubble) — `Recorded a candidate learning from this rejection (queued for the judgment gate): <one-line candidate rule>.` then `<!-- [lisa-rejection-candidate] key=<issue>-<transition-ts> -->` — and proceed. Dedupe on `<issue>-<backward-transition-timestamp>` — a second re-claim produces no duplicate. Unreadable/absent evidence → no candidate, still implement.
385
385
 
@@ -92,6 +92,26 @@ ready gate itself — the `work-item-definition-of-ready` rule or the validators
92
92
  S18 dry-run — rather than one more ledger entry competing for the projection.
93
93
  A recurring miss counts once per `[lisa-planning-miss]` note on distinct items.
94
94
 
95
+ **Auto-merged low-confidence entries are re-reviewed first.** A project
96
+ that sets `learnings.lowConfidence: "auto-merge"` (resolve it with
97
+ `resolveLearningsSettings(config).lowConfidence` from
98
+ `@codyswann/lisa/learnings`) lets `lisa-persist-learning` merge `low`
99
+ learnings without a human reading them (CodySwannGT/lisa#4659). In that mode,
100
+ every parsed ledger entry with `confidence: "low"` that has never been
101
+ confirmed (`last_confirmed` equals `first_learned`) goes to the **front** of
102
+ this run's audit order, oldest first, and has all five evidence axes
103
+ gathered. A CONFIRM bumps `last_confirmed`, which ends the priority, so the
104
+ front of the queue holds only entries nobody has checked yet. The ordering
105
+ changes no cap: PROMOTE/DEMOTE tickets for these entries count toward
106
+ `max_candidates` like any other. Low confidence is the reason an entry is
107
+ checked first, never evidence for a change: RETIRE or DEMOTE still needs
108
+ proof (a contradiction, staleness, a mechanical owner), and Recurrence
109
+ evidence that it applied is a CONFIRM. Name these entries in the run proof
110
+ (`low-confidence re-reviewed: <ids>`), so an operator can see that the
111
+ skipped human gate was paid for here. Under the default `human-triage` a
112
+ `low` entry reached the ledger only through a human merge, so it keeps the
113
+ normal order.
114
+
95
115
  **The eager tier is audited every run** — including
96
116
  **Lisa's own shipped eager rules**, not just host additions. Admission is demotion-biased and
97
117
  earned only by repeated-miss evidence (see the `promotion-contract` rule);
@@ -106,7 +126,10 @@ evidence:
106
126
  - All learning-machinery artifacts: items carrying `[lisa-learning-drop]`,
107
127
  `[lisa-learning-pr]`, `[lisa-learning-upstream-handoff]` (any
108
128
  `[lisa-learning-*]` marker), `[lisa-rejection-candidate]`, or
109
- `[lisa-archaeology-candidate]`, and the `learning:needs-triage` label.
129
+ `[lisa-archaeology-candidate]`, and the `learning:needs-triage` and
130
+ `learning:low-confidence` labels. The label exclusion covers the PR
131
+ artifact only; the ledger entry it merged is still audited (see
132
+ **Auto-merged low-confidence entries** above).
110
133
 
111
134
  ## Scope
112
135
 
@@ -382,7 +382,7 @@ Before the claim mutation, apply `claim-time-guards` — **Value before claim**,
382
382
 
383
383
  **Rejection detection runs first — before the transition below.** Per the vendor-neutral `rejection-detection` rule (cite the slug; do not restate its classification table), classify this Issue at the **top of 3b, BEFORE** the `$READY → $CLAIMED` transition — afterwards the current-lane signal is gone. Read the Issue's history via `lisa-linear-access operation: history id: <ISSUE-ID>`, keyed on **workflow-state** history, and classify it `rejection-reclaim | forward-only | never-left-ready | unknown` (a `rejection-reclaim` is a move back into `$READY` from a later lane). State names come from `.lisa.config.json`, never hardcoded.
384
384
 
385
- > Reading state history is strictly simpler than the label history this used to key on: `IssueHistory` inlines `fromState.name` / `toState.name` on each node, so the transition is read directly with no label-ID resolution against `list-issue-labels` and no reconstruction from `addedLabelIds`/`removedLabelIds` deltas. That reconstruction was lossy — the deltas carry no prior/next full set — which is one more reason the build lane moved to states. A failing/absent history yields `unknown` and the claim proceeds — detection never blocks the build. Issues carrying a learning marker (`[lisa-learning-drop]` / `[lisa-learning-pr]` / `[lisa-learning-upstream-handoff]`) or the `learning:needs-triage` label are never rejection triggers (no learning-about-learning). Carry the classification into the transition and lifecycle below.
385
+ > Reading state history is strictly simpler than the label history this used to key on: `IssueHistory` inlines `fromState.name` / `toState.name` on each node, so the transition is read directly with no label-ID resolution against `list-issue-labels` and no reconstruction from `addedLabelIds`/`removedLabelIds` deltas. That reconstruction was lossy — the deltas carry no prior/next full set — which is one more reason the build lane moved to states. A failing/absent history yields `unknown` and the claim proceeds — detection never blocks the build. Issues carrying a learning marker (`[lisa-learning-drop]` / `[lisa-learning-pr]` / `[lisa-learning-upstream-handoff]`) or the `learning:needs-triage` or `learning:low-confidence` label are never rejection triggers (no learning-about-learning). Carry the classification into the transition and lifecycle below.
386
386
 
387
387
  **On `rejection-reclaim`, reflect before re-implementing** (per `rejection-detection`): read the rejection evidence through the access layer — the Issue comments posted after the backward transition (the QA rejection comment) via `lisa-linear-access operation: list-comments` and the review threads on the rejected PR — assemble ONE candidate learning (rule, why, provenance linking the rejection comment + rejected PR, evidence links, scope hint, triggering issue, fingerprint `sll4-sha1(rule\ntriggering_issue)[:12]`), and route it to the `lisa-persist-learning` skill. If that skill is absent, record the candidate via `lisa-linear-access operation: save-comment` as a comment carrying a **visible prose line plus** the marker (a bare marker renders as an empty bubble) — `Recorded a candidate learning from this rejection (queued for the judgment gate): <one-line candidate rule>.` then `<!-- [lisa-rejection-candidate] key=<issue>-<transition-ts> -->` — and proceed. Dedupe on `<issue>-<backward-transition-timestamp>` — a second re-claim produces no duplicate. Unreadable/absent evidence → no candidate, still implement.
388
388
 
@@ -235,15 +235,40 @@ No learning content is ever committed without a PR — there is no other write p
235
235
  Stage: <planning_stage>. The worker could not find: "<quoted>". Planning skills read this rule back through the bounded projection (`lisa-task-decomposition` step 0).
236
236
  ```
237
237
 
238
- For a **low-confidence** PR (other than a `wrongly-escalated` one, which no human merges — step 6), the body must additionally end with this fixed decision-framing line so the human at the gate knows exactly what merging means:
238
+ For a **low-confidence** PR (other than a `wrongly-escalated` one, which no human merges — step 6), the body must additionally end with one fixed line chosen by the step-6 routing mode. Under `human-triage` (the default) it is this decision-framing line, so the human at the gate knows exactly what merging means:
239
239
 
240
240
  ```markdown
241
241
  **Merge** to adopt this rule into every future session for all six coding agents; **close** to discard it.
242
242
  ```
243
243
 
244
- 6. **Confidence routing.**
244
+ Under `auto-merge` nobody stands at that gate, so the line instead says why the PR merges unattended and who re-checks it (resolve the mode with the step-6 command before writing the body):
245
+
246
+ ```markdown
247
+ Low-confidence learning: merges through the normal gates under `learnings.lowConfidence: "auto-merge"`; the gardener (`lisa-learnings-audit`) re-reviews it first.
248
+ ```
249
+
250
+ 6. **Confidence routing.** A `signal: wrongly-escalated` candidate always takes its own bullet below, whatever its confidence and whatever this setting says. Any other `low` verdict routes by the project's `learnings.lowConfidence` setting. Resolve it through the same executable contract as the ledger path in step 2 — never by reading `.lisa.config.json` by hand. A value other than `"auto-merge"` or `"human-triage"` is rejected by the config read itself, so it already stopped the run at step 2 and nothing was persisted:
251
+
252
+ ```bash
253
+ LOW_CONFIDENCE=$(node -e 'import("@codyswann/lisa/learnings").then(async m => { const c = await m.readProjectConfig(process.cwd()); console.log(m.resolveLearningsSettings(c).lowConfidence); })')
254
+ ```
255
+
256
+ It prints `human-triage` when the key is absent — the default, unchanged — or `auto-merge` when the project opted in.
257
+
245
258
  - **`high`** → submit through `lisa-git-submit-pr` with its defaults: auto-merge ON, merging through the project's normal gates.
246
- - **`low`** → submit through `lisa-git-submit-pr` with `auto_merge=false` (drives the PR to green-and-open `awaiting-human`, never merging — even on repos that disallow auto-merge). Then apply the human-triage label, creating it idempotently first (the `lisa-drive-pr-to-merge` label pattern — `|| true` tolerates only already-exists, so verify):
259
+ - **`low` + `auto-merge`** → submit through `lisa-git-submit-pr` with its defaults, exactly like `high`: auto-merge ON, merging through the project's normal gates — the gates are not skipped, only the human wait is. This is for operators who involve humans only when an agent is genuinely stuck; the human gate's purpose is still covered, because the ledger is a cold, bounded projection, a planning-miss rule only adds a planning check, and the gardener can retire or demote a wrong entry. Keep the entry findable without blocking the merge: the ledger entry already carries `confidence: low` (step 3), and the PR gets the `learning:low-confidence` label (never `learning:needs-triage`, which means a human still has to act), created idempotently first:
260
+
261
+ ```bash
262
+ gh label create "learning:low-confidence" \
263
+ --description "Low-confidence learning auto-merged; gardener re-reviews first" \
264
+ --color C5DEF5 || true
265
+ gh label list --search "learning:low-confidence" --json name \
266
+ --jq '[.[].name] | contains(["learning:low-confidence"])' # must print true
267
+ gh pr edit <pr> --add-label "learning:low-confidence"
268
+ ```
269
+
270
+ Labeling never blocks: if it fails, report it in the run summary and leave the PR armed. The run summary names the routing mode used.
271
+ - **`low` + `human-triage`** (the default) → submit through `lisa-git-submit-pr` with `auto_merge=false` (drives the PR to green-and-open `awaiting-human`, never merging — even on repos that disallow auto-merge). Then apply the human-triage label, creating it idempotently first (the `lisa-drive-pr-to-merge` label pattern — `|| true` tolerates only already-exists, so verify):
247
272
 
248
273
  ```bash
249
274
  gh label create "learning:needs-triage" \