instar 1.3.2028 → 1.3.2030

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 (38) hide show
  1. package/dist/commands/init.d.ts.map +1 -1
  2. package/dist/commands/init.js +6 -0
  3. package/dist/commands/init.js.map +1 -1
  4. package/dist/core/PostUpdateMigrator.d.ts.map +1 -1
  5. package/dist/core/PostUpdateMigrator.js +6 -0
  6. package/dist/core/PostUpdateMigrator.js.map +1 -1
  7. package/dist/core/sqlCommandContext.d.ts +3 -0
  8. package/dist/core/sqlCommandContext.d.ts.map +1 -0
  9. package/dist/core/sqlCommandContext.js +171 -0
  10. package/dist/core/sqlCommandContext.js.map +1 -0
  11. package/dist/data/standards-guard-index.json +1 -1
  12. package/dist/data/standards-guard-index.meta.json +2 -2
  13. package/dist/data/standards-registry.meta.json +1 -1
  14. package/dist/native/InstarWedgeCanary.app/Contents/MacOS/InstarWedgeCanary +0 -0
  15. package/dist/native/instar-desktop-host +0 -0
  16. package/dist/server/AgentServer.d.ts.map +1 -1
  17. package/dist/server/AgentServer.js +1 -0
  18. package/dist/server/AgentServer.js.map +1 -1
  19. package/dist/server/mobileChatServingAudit.d.ts +7 -0
  20. package/dist/server/mobileChatServingAudit.d.ts.map +1 -0
  21. package/dist/server/mobileChatServingAudit.js +40 -0
  22. package/dist/server/mobileChatServingAudit.js.map +1 -0
  23. package/dist/server/mobilePairingRoutes.d.ts +3 -0
  24. package/dist/server/mobilePairingRoutes.d.ts.map +1 -1
  25. package/dist/server/mobilePairingRoutes.js +5 -0
  26. package/dist/server/mobilePairingRoutes.js.map +1 -1
  27. package/package.json +1 -1
  28. package/src/data/awareness/mobile-chat-serving-refusal-audit.md +5 -0
  29. package/src/data/awareness/sql-command-context.md +5 -0
  30. package/src/data/builtin-manifest.json +22 -22
  31. package/src/data/standards-guard-index.json +1 -1
  32. package/src/data/standards-guard-index.meta.json +2 -2
  33. package/src/data/standards-registry.meta.json +1 -1
  34. package/src/templates/hooks/dangerous-command-guard.sh +177 -0
  35. package/upgrades/1.3.2029.md +20 -0
  36. package/upgrades/1.3.2030.md +20 -0
  37. package/upgrades/side-effects/app-send-refusal-audit.md +55 -0
  38. package/upgrades/side-effects/sql-command-context.md +55 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instar",
3
- "version": "1.3.2028",
3
+ "version": "1.3.2030",
4
4
  "description": "Coherence infrastructure for self-evolving AI agents — on the Claude Code or Codex subscription you already have.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -0,0 +1,5 @@
1
+ ---
2
+ title: App Chat Serving Refusals
3
+ ---
4
+
5
+ When an app send reports that messages are not being received, inspect server warning logs for `mobile-chat-not-serving`. Each record has server time, PID, a fixed observed lease verdict, renewal age and TTL. The sample is taken after the existing refusal and is labeled `after-refusal`; `holding` in that sample must not be rewritten as an expired lease. Null or unavailable means the diagnostic could not be obtained. A prior lead label does not prove the request-time lease was valid. Preserve the fence and uncertainty rules; these records contain no message or device data and authorize no resend or restart.
@@ -0,0 +1,5 @@
1
+ ---
2
+ title: SQL Text In Command Data
3
+ ---
4
+
5
+ The command safety hook distinguishes recognized literal search and file-writing data from executable SQL contexts. Unknown syntax, variables, executable expansions, rg subprocess flags and unsupported programs still receive the existing SQL check. A hook refusal is not permission to bypass it. When investigating another false positive, preserve the exact command and refusal, add both data and real-execution regressions, and repair the shared init/update classifier through normal review and release. Custom hooks remain unchanged.
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "$schema": "./builtin-manifest.schema.json",
3
3
  "schemaVersion": 1,
4
- "generatedAt": "2026-11-25T04:59:19.394Z",
5
- "instarVersion": "1.3.2028",
4
+ "generatedAt": "2026-11-25T05:57:06.217Z",
5
+ "instarVersion": "1.3.2030",
6
6
  "entryCount": 210,
7
7
  "entries": {
8
8
  "hook:session-start": {
@@ -11,7 +11,7 @@
11
11
  "domain": "identity",
12
12
  "sourcePath": "src/core/PostUpdateMigrator.ts",
13
13
  "installedPath": ".instar/hooks/instar/session-start.sh",
14
- "contentHash": "afba699ed5ed492f4ae87dc02ad3ad9de092b8ffe0852a3755850947b277670e",
14
+ "contentHash": "b7a2ae14c60589e7aaf8f57b66fb11c0ee07ebd60c221889580d1222301e748c",
15
15
  "since": "2025-01-01"
16
16
  },
17
17
  "hook:dangerous-command-guard": {
@@ -20,7 +20,7 @@
20
20
  "domain": "safety",
21
21
  "sourcePath": "src/core/PostUpdateMigrator.ts",
22
22
  "installedPath": ".instar/hooks/instar/dangerous-command-guard.sh",
23
- "contentHash": "afba699ed5ed492f4ae87dc02ad3ad9de092b8ffe0852a3755850947b277670e",
23
+ "contentHash": "b7a2ae14c60589e7aaf8f57b66fb11c0ee07ebd60c221889580d1222301e748c",
24
24
  "since": "2025-01-01"
25
25
  },
26
26
  "hook:grounding-before-messaging": {
@@ -29,7 +29,7 @@
29
29
  "domain": "safety",
30
30
  "sourcePath": "src/core/PostUpdateMigrator.ts",
31
31
  "installedPath": ".instar/hooks/instar/grounding-before-messaging.sh",
32
- "contentHash": "afba699ed5ed492f4ae87dc02ad3ad9de092b8ffe0852a3755850947b277670e",
32
+ "contentHash": "b7a2ae14c60589e7aaf8f57b66fb11c0ee07ebd60c221889580d1222301e748c",
33
33
  "since": "2025-01-01"
34
34
  },
35
35
  "hook:compaction-recovery": {
@@ -38,7 +38,7 @@
38
38
  "domain": "identity",
39
39
  "sourcePath": "src/core/PostUpdateMigrator.ts",
40
40
  "installedPath": ".instar/hooks/instar/compaction-recovery.sh",
41
- "contentHash": "afba699ed5ed492f4ae87dc02ad3ad9de092b8ffe0852a3755850947b277670e",
41
+ "contentHash": "b7a2ae14c60589e7aaf8f57b66fb11c0ee07ebd60c221889580d1222301e748c",
42
42
  "since": "2025-01-01"
43
43
  },
44
44
  "hook:external-operation-gate": {
@@ -47,7 +47,7 @@
47
47
  "domain": "safety",
48
48
  "sourcePath": "src/core/PostUpdateMigrator.ts",
49
49
  "installedPath": ".instar/hooks/instar/external-operation-gate.js",
50
- "contentHash": "afba699ed5ed492f4ae87dc02ad3ad9de092b8ffe0852a3755850947b277670e",
50
+ "contentHash": "b7a2ae14c60589e7aaf8f57b66fb11c0ee07ebd60c221889580d1222301e748c",
51
51
  "since": "2025-01-01"
52
52
  },
53
53
  "hook:deferral-detector": {
@@ -56,7 +56,7 @@
56
56
  "domain": "safety",
57
57
  "sourcePath": "src/core/PostUpdateMigrator.ts",
58
58
  "installedPath": ".instar/hooks/instar/deferral-detector.js",
59
- "contentHash": "afba699ed5ed492f4ae87dc02ad3ad9de092b8ffe0852a3755850947b277670e",
59
+ "contentHash": "b7a2ae14c60589e7aaf8f57b66fb11c0ee07ebd60c221889580d1222301e748c",
60
60
  "since": "2025-01-01"
61
61
  },
62
62
  "hook:self-stop-guard": {
@@ -65,7 +65,7 @@
65
65
  "domain": "coherence",
66
66
  "sourcePath": "src/core/PostUpdateMigrator.ts",
67
67
  "installedPath": ".instar/hooks/instar/self-stop-guard.js",
68
- "contentHash": "afba699ed5ed492f4ae87dc02ad3ad9de092b8ffe0852a3755850947b277670e",
68
+ "contentHash": "b7a2ae14c60589e7aaf8f57b66fb11c0ee07ebd60c221889580d1222301e748c",
69
69
  "since": "2025-01-01"
70
70
  },
71
71
  "hook:post-action-reflection": {
@@ -74,7 +74,7 @@
74
74
  "domain": "evolution",
75
75
  "sourcePath": "src/core/PostUpdateMigrator.ts",
76
76
  "installedPath": ".instar/hooks/instar/post-action-reflection.js",
77
- "contentHash": "afba699ed5ed492f4ae87dc02ad3ad9de092b8ffe0852a3755850947b277670e",
77
+ "contentHash": "b7a2ae14c60589e7aaf8f57b66fb11c0ee07ebd60c221889580d1222301e748c",
78
78
  "since": "2025-01-01"
79
79
  },
80
80
  "hook:external-communication-guard": {
@@ -83,7 +83,7 @@
83
83
  "domain": "safety",
84
84
  "sourcePath": "src/core/PostUpdateMigrator.ts",
85
85
  "installedPath": ".instar/hooks/instar/external-communication-guard.js",
86
- "contentHash": "afba699ed5ed492f4ae87dc02ad3ad9de092b8ffe0852a3755850947b277670e",
86
+ "contentHash": "b7a2ae14c60589e7aaf8f57b66fb11c0ee07ebd60c221889580d1222301e748c",
87
87
  "since": "2025-01-01"
88
88
  },
89
89
  "hook:telegram-origin-guard": {
@@ -101,7 +101,7 @@
101
101
  "domain": "coherence",
102
102
  "sourcePath": "src/core/PostUpdateMigrator.ts",
103
103
  "installedPath": ".instar/hooks/instar/scope-coherence-collector.js",
104
- "contentHash": "afba699ed5ed492f4ae87dc02ad3ad9de092b8ffe0852a3755850947b277670e",
104
+ "contentHash": "b7a2ae14c60589e7aaf8f57b66fb11c0ee07ebd60c221889580d1222301e748c",
105
105
  "since": "2025-01-01"
106
106
  },
107
107
  "hook:scope-coherence-checkpoint": {
@@ -110,7 +110,7 @@
110
110
  "domain": "coherence",
111
111
  "sourcePath": "src/core/PostUpdateMigrator.ts",
112
112
  "installedPath": ".instar/hooks/instar/scope-coherence-checkpoint.js",
113
- "contentHash": "afba699ed5ed492f4ae87dc02ad3ad9de092b8ffe0852a3755850947b277670e",
113
+ "contentHash": "b7a2ae14c60589e7aaf8f57b66fb11c0ee07ebd60c221889580d1222301e748c",
114
114
  "since": "2025-01-01"
115
115
  },
116
116
  "hook:free-text-guard": {
@@ -119,7 +119,7 @@
119
119
  "domain": "safety",
120
120
  "sourcePath": "src/core/PostUpdateMigrator.ts",
121
121
  "installedPath": ".instar/hooks/instar/free-text-guard.sh",
122
- "contentHash": "afba699ed5ed492f4ae87dc02ad3ad9de092b8ffe0852a3755850947b277670e",
122
+ "contentHash": "b7a2ae14c60589e7aaf8f57b66fb11c0ee07ebd60c221889580d1222301e748c",
123
123
  "since": "2025-01-01"
124
124
  },
125
125
  "hook:claim-intercept": {
@@ -128,7 +128,7 @@
128
128
  "domain": "coherence",
129
129
  "sourcePath": "src/core/PostUpdateMigrator.ts",
130
130
  "installedPath": ".instar/hooks/instar/claim-intercept.js",
131
- "contentHash": "afba699ed5ed492f4ae87dc02ad3ad9de092b8ffe0852a3755850947b277670e",
131
+ "contentHash": "b7a2ae14c60589e7aaf8f57b66fb11c0ee07ebd60c221889580d1222301e748c",
132
132
  "since": "2025-01-01"
133
133
  },
134
134
  "hook:claim-intercept-response": {
@@ -137,7 +137,7 @@
137
137
  "domain": "coherence",
138
138
  "sourcePath": "src/core/PostUpdateMigrator.ts",
139
139
  "installedPath": ".instar/hooks/instar/claim-intercept-response.js",
140
- "contentHash": "afba699ed5ed492f4ae87dc02ad3ad9de092b8ffe0852a3755850947b277670e",
140
+ "contentHash": "b7a2ae14c60589e7aaf8f57b66fb11c0ee07ebd60c221889580d1222301e748c",
141
141
  "since": "2025-01-01"
142
142
  },
143
143
  "hook:stop-gate-router": {
@@ -146,7 +146,7 @@
146
146
  "domain": "safety",
147
147
  "sourcePath": "src/core/PostUpdateMigrator.ts",
148
148
  "installedPath": ".instar/hooks/instar/stop-gate-router.js",
149
- "contentHash": "afba699ed5ed492f4ae87dc02ad3ad9de092b8ffe0852a3755850947b277670e",
149
+ "contentHash": "b7a2ae14c60589e7aaf8f57b66fb11c0ee07ebd60c221889580d1222301e748c",
150
150
  "since": "2025-01-01"
151
151
  },
152
152
  "hook:attribution-gate": {
@@ -155,7 +155,7 @@
155
155
  "domain": "safety",
156
156
  "sourcePath": "src/core/PostUpdateMigrator.ts",
157
157
  "installedPath": ".instar/hooks/instar/attribution-gate.js",
158
- "contentHash": "afba699ed5ed492f4ae87dc02ad3ad9de092b8ffe0852a3755850947b277670e",
158
+ "contentHash": "b7a2ae14c60589e7aaf8f57b66fb11c0ee07ebd60c221889580d1222301e748c",
159
159
  "since": "2025-01-01"
160
160
  },
161
161
  "hook:auto-approve-permissions": {
@@ -164,7 +164,7 @@
164
164
  "domain": "safety",
165
165
  "sourcePath": "src/core/PostUpdateMigrator.ts",
166
166
  "installedPath": ".instar/hooks/instar/auto-approve-permissions.js",
167
- "contentHash": "afba699ed5ed492f4ae87dc02ad3ad9de092b8ffe0852a3755850947b277670e",
167
+ "contentHash": "b7a2ae14c60589e7aaf8f57b66fb11c0ee07ebd60c221889580d1222301e748c",
168
168
  "since": "2025-01-01"
169
169
  },
170
170
  "job:health-check": {
@@ -1084,7 +1084,7 @@
1084
1084
  "type": "template",
1085
1085
  "domain": "safety",
1086
1086
  "sourcePath": "src/templates/hooks/dangerous-command-guard.sh",
1087
- "contentHash": "07f4aee354516334be55487b6d56412c13058fd360b8008e978209d0aa52b524",
1087
+ "contentHash": "9142a640087f82602c10c039e3dc95524aa7bef616c075a18c1e39a94ce6e4e9",
1088
1088
  "since": "2025-01-01"
1089
1089
  },
1090
1090
  "template:free-text-guard.sh": {
@@ -1596,7 +1596,7 @@
1596
1596
  "type": "subsystem",
1597
1597
  "domain": "server",
1598
1598
  "sourcePath": "src/server/AgentServer.ts",
1599
- "contentHash": "08fc2d102db632acbd8b84bce43cad6fa14e0f7b8881fab2f69bbe60eb49214e",
1599
+ "contentHash": "09cee39359410fa37aec36832ba342db7048a54838f4966a3597a31d02a981d7",
1600
1600
  "since": "2025-01-01"
1601
1601
  },
1602
1602
  "subsystem:session-manager": {
@@ -1628,7 +1628,7 @@
1628
1628
  "type": "subsystem",
1629
1629
  "domain": "updates",
1630
1630
  "sourcePath": "src/core/PostUpdateMigrator.ts",
1631
- "contentHash": "afba699ed5ed492f4ae87dc02ad3ad9de092b8ffe0852a3755850947b277670e",
1631
+ "contentHash": "b7a2ae14c60589e7aaf8f57b66fb11c0ee07ebd60c221889580d1222301e748c",
1632
1632
  "since": "2025-01-01"
1633
1633
  },
1634
1634
  "subsystem:scheduler": {
@@ -2,7 +2,7 @@
2
2
  "schemaVersion": 1,
3
3
  "generatedFrom": "source-tree",
4
4
  "registrySha256": "11e2a45ab1345e2ded6499404ee9962e4e48bcfed4677a4d31dac4492565d2fa",
5
- "packageVersion": "1.3.2028",
5
+ "packageVersion": "1.3.2030",
6
6
  "guards": [
7
7
  {
8
8
  "ref": "docs/audits/phase-b/f10-triage.md",
@@ -1,5 +1,5 @@
1
1
  {
2
- "sha256": "d61d5b6b0d73145a1043f759e29e180052a91bf86887a8cb4dd15d08abae023d",
2
+ "sha256": "eab2a6b115b673aa4bf68a3c7aa1d5722b12dc649d7f1eb32d84ef4209684ada",
3
3
  "registrySha256": "11e2a45ab1345e2ded6499404ee9962e4e48bcfed4677a4d31dac4492565d2fa",
4
- "packageVersion": "1.3.2028"
4
+ "packageVersion": "1.3.2030"
5
5
  }
@@ -2,5 +2,5 @@
2
2
  "sha256": "11e2a45ab1345e2ded6499404ee9962e4e48bcfed4677a4d31dac4492565d2fa",
3
3
  "articleCount": 102,
4
4
  "generatedFrom": "docs/STANDARDS-REGISTRY.md",
5
- "packageVersion": "1.3.2028"
5
+ "packageVersion": "1.3.2030"
6
6
  }
@@ -62,6 +62,175 @@ if echo "$INPUT" | grep -qE -e '(gh[pousr]_[A-Za-z0-9]{36}|github_pat_[A-Za-z0-9
62
62
  exit 2
63
63
  fi
64
64
 
65
+ # SQL context: only proven literal data operations bypass the SQL-shaped matcher.
66
+ sql_command_is_literal_data() {
67
+ python3 - "$INPUT" <<'INSTAR_SQL_CONTEXT_PY'
68
+ import ast, json, os, re, shlex, sys
69
+
70
+ def active_expansion(source):
71
+ quote = None
72
+ i = 0
73
+ while i < len(source):
74
+ c = source[i]
75
+ if quote == "'":
76
+ if c == "'": quote = None
77
+ elif c == '\\':
78
+ return True
79
+ elif c == "'" and quote is None:
80
+ quote = "'"
81
+ elif c == '"':
82
+ quote = None if quote == '"' else '"'
83
+ elif ord(c) == 96 or c == '$':
84
+ return True
85
+ elif quote is None and c in '*?[{~#':
86
+ return True
87
+ elif quote is None and (source.startswith('<(', i) or source.startswith('>(', i)):
88
+ return True
89
+ i += 1
90
+ return quote is not None
91
+
92
+ def tokens(source, posix=True):
93
+ lexer = shlex.shlex(source, posix=posix, punctuation_chars=';&|()<>\n')
94
+ lexer.whitespace = ' \t\r'
95
+ lexer.commenters = ''
96
+ return list(lexer)
97
+
98
+ def quoted_operator(source):
99
+ for raw in tokens(source, posix=False):
100
+ if raw and raw[0] in ("'", '"'):
101
+ values = shlex.split(raw, posix=True)
102
+ if len(values) == 1 and values[0] and all(c in ';&|()<>\n' for c in values[0]): return True
103
+ return False
104
+
105
+ def python_file_data(source):
106
+ tree = ast.parse(source)
107
+ if len(list(ast.walk(tree))) > 4096: return False
108
+ bindings = {}
109
+ constructors = set()
110
+
111
+ def kind(node):
112
+ if isinstance(node, ast.Constant):
113
+ return 'text' if isinstance(node.value, str) else 'bytes' if isinstance(node.value, bytes) else 'number' if isinstance(node.value, (int, float)) else None
114
+ if isinstance(node, ast.Name): return bindings.get(node.id)
115
+ if isinstance(node, ast.BinOp) and isinstance(node.op, ast.Add):
116
+ left, right = kind(node.left), kind(node.right)
117
+ return left if left == right and left in ('text', 'bytes') else None
118
+ if not isinstance(node, ast.Call) or any(k.arg is None for k in node.keywords): return None
119
+ if isinstance(node.func, ast.Name) and node.func.id == 'Path' and 'Path' in constructors:
120
+ return 'path' if node.args and all(kind(a) == 'text' for a in node.args) and not node.keywords else None
121
+ if isinstance(node.func, ast.Attribute):
122
+ owner, method = node.func.value, node.func.attr
123
+ if isinstance(owner, ast.Name) and owner.id == 'pathlib' and 'pathlib' in constructors and method == 'Path':
124
+ return 'path' if node.args and all(kind(a) == 'text' for a in node.args) and not node.keywords else None
125
+ receiver = kind(owner)
126
+ args = [kind(a) for a in node.args]
127
+ if any(kind(k.value) != 'text' or k.arg not in ('encoding', 'errors') for k in node.keywords): return None
128
+ if receiver == 'path':
129
+ if method == 'read_text' and not args: return 'text'
130
+ if method == 'read_bytes' and not args and not node.keywords: return 'bytes'
131
+ if method == 'write_text' and args == ['text']: return 'number'
132
+ if method == 'write_bytes' and args == ['bytes'] and not node.keywords: return 'number'
133
+ if receiver == 'text' and method == 'replace' and args == ['text', 'text'] and not node.keywords: return 'text'
134
+ return None
135
+
136
+ for statement in tree.body:
137
+ if isinstance(statement, ast.ImportFrom) and statement.module == 'pathlib' and statement.level == 0:
138
+ if any(a.name != 'Path' or a.asname for a in statement.names): return False
139
+ constructors.add('Path')
140
+ elif isinstance(statement, ast.Import):
141
+ if any(a.name != 'pathlib' or a.asname for a in statement.names): return False
142
+ constructors.add('pathlib')
143
+ elif isinstance(statement, ast.Assign):
144
+ value = kind(statement.value)
145
+ if value is None or any(not isinstance(t, ast.Name) or t.id in ('Path', 'pathlib') for t in statement.targets): return False
146
+ for target in statement.targets: bindings[target.id] = value
147
+ elif isinstance(statement, ast.Expr):
148
+ if kind(statement.value) is None: return False
149
+ else: return False
150
+ return True
151
+
152
+ def safe_command(raw, depth):
153
+ values = list(raw)
154
+ # Environment overrides can change a tool's execution configuration.
155
+ if values and re.match(r'^[A-Za-z_][A-Za-z0-9_]*=', values[0]): return False
156
+ if not values: return True
157
+ if values[0] == 'command':
158
+ values.pop(0)
159
+ if values and values[0] == '--': values.pop(0)
160
+ if not values: return False
161
+ name = os.path.basename(values[0])
162
+ args = values[1:]
163
+ if name in ('sh', 'bash'):
164
+ if os.environ.get('BASH_ENV') or os.environ.get('ENV'): return False
165
+ return len(args) == 2 and args[0] == '-c' and data_only(args[1], depth + 1)
166
+ if name in ('python', 'python3'):
167
+ return len(args) == 2 and args[0] == '-c' and python_file_data(args[1])
168
+ if name == 'rg' and (os.environ.get('RIPGREP_CONFIG_PATH') or any(a == '--pre' or a.startswith('--pre=') or a == '--hostname-bin' or a.startswith('--hostname-bin=') for a in args)): return False
169
+ if name == 'printf' and any(a.startswith('-v') for a in args): return False
170
+ return name in ('rg', 'grep', 'egrep', 'fgrep', 'cat', 'printf', 'echo', 'tee', 'head', 'tail', 'wc', 'true', 'false')
171
+
172
+ def safe_tokens(parts, depth):
173
+ command = []
174
+ i = 0
175
+ for_end = (';', '&&', '||', '|', '&', '\n')
176
+ while i < len(parts):
177
+ token = parts[i]
178
+ if token in for_end:
179
+ if command and not safe_command(command, depth): return False
180
+ command = []
181
+ elif token in ('>', '>>', '<'):
182
+ i += 1
183
+ if i >= len(parts) or parts[i] in for_end or parts[i] in ('(', ')', '<', '>', '>>', '<<'): return False
184
+ elif token and all(c in ';&|()<>\n' for c in token):
185
+ return False
186
+ else: command.append(token)
187
+ i += 1
188
+ return not command or safe_command(command, depth)
189
+
190
+ def data_only(source, depth=0):
191
+ if depth > 8 or len(source) > 262144: return False
192
+ if any((ord(c) < 32 and c not in ('\n', '\t')) or ord(c) in (127, 133, 8232, 8233) for c in source): return False
193
+ lines = source.splitlines(keepends=True)
194
+ first = tokens(lines[0].rstrip('\r\n')) if lines else []
195
+ if '<<' in first:
196
+ # Raw anchoring rejects quote concatenation and unsupported headers;
197
+ # semantic argv alone does not retain heredoc quoting provenance.
198
+ header = re.fullmatch(r'''[ \t]*(cat|tee|python3?)(?:[ \t]+-)?[ \t]*<<[ \t]*(['"])([A-Za-z_][A-Za-z0-9_]*)\2[ \t]*(?:>>?[ \t]*[A-Za-z0-9_./-]+[ \t]*)?''', lines[0].rstrip('\n'))
199
+ if header is None: return False
200
+ marker = header.group(3)
201
+ end = next((n for n in range(1, len(lines)) if lines[n].rstrip('\r\n') == marker), None)
202
+ if end is None: return False
203
+ body = ''.join(lines[1:end])
204
+ name = header.group(1)
205
+ if name in ('python', 'python3'):
206
+ if not python_file_data(body): return False
207
+ return data_only(''.join(lines[end + 1:]), depth + 1)
208
+ return not active_expansion(source) and not quoted_operator(source) and safe_tokens(tokens(source), depth)
209
+
210
+ try:
211
+ source = sys.argv[1]
212
+ try:
213
+ payload = json.loads(source)
214
+ if isinstance(payload, dict):
215
+ tool = payload.get('tool_input')
216
+ if tool is not None and not isinstance(tool, dict): sys.exit(1)
217
+ candidates = []
218
+ for container in (payload, tool or {}):
219
+ for field in ('command', 'cmd'):
220
+ value = container.get(field)
221
+ if value is not None and value != '':
222
+ if not isinstance(value, str): sys.exit(1)
223
+ candidates.append(value)
224
+ if len(set(candidates)) > 1: sys.exit(1)
225
+ source = candidates[0] if candidates else ''
226
+ except (ValueError, TypeError): pass
227
+ sys.exit(0 if isinstance(source, str) and data_only(source) else 1)
228
+ except Exception:
229
+ sys.exit(1)
230
+ INSTAR_SQL_CONTEXT_PY
231
+ }
232
+ SQL_LITERAL_DATA=""
233
+
65
234
  # --- Risky commands: behavior depends on safety level ---
66
235
  RISKY_PATTERNS=(
67
236
  "rm -rf \."
@@ -114,6 +283,14 @@ fi
114
283
 
115
284
  for pattern in "${RISKY_PATTERNS[@]}"; do
116
285
  if echo "$INPUT" | grep -qiE -e "$pattern"; then
286
+ case "$pattern" in
287
+ "D""ROP TABLE"|"D""ROP DATABASE"|"T""RUNCATE"|"D""ELETE FROM")
288
+ if [ -z "$SQL_LITERAL_DATA" ]; then
289
+ if sql_command_is_literal_data; then SQL_LITERAL_DATA=1; else SQL_LITERAL_DATA=0; fi
290
+ fi
291
+ if [ "$SQL_LITERAL_DATA" = "1" ]; then continue; fi
292
+ ;;
293
+ esac
117
294
  # Allow the safe force-with-lease-to-own-branch case past the force-push patterns.
118
295
  if [ "$FORCE_WITH_LEASE_OWN_BRANCH" -eq 1 ] && echo "$pattern" | grep -qiE 'git push (--force|-f)'; then
119
296
  continue
@@ -0,0 +1,20 @@
1
+ # Upgrade Guide — vNEXT
2
+
3
+ <!-- assembled-by: assemble-next-md -->
4
+ <!-- bump: patch -->
5
+
6
+ ## What Changed
7
+
8
+ The app chat preflight records a fixed-schema warning when the local serving-lease check refuses a new request. The warning names the server time and a subsequent read-only lease verdict, renewal age and lifetime. Diagnostic failure does not change the existing refusal. No message text, conversation/device/request identifier, credential or raw error is logged.
9
+
10
+ ## What to Tell Your User
11
+
12
+ When an app message is refused because the computer cannot currently receive it, the server now records the lease condition it observed so the interruption can be investigated.
13
+
14
+ ## Summary of New Capabilities
15
+
16
+ No new control or API. Server warning logs can show mobile-chat-not-serving records with bounded lease diagnostics.
17
+
18
+ ## Evidence
19
+
20
+ Allocated focused tests passed: 9 unit, 18 signed HTTP and 1 real-lease production-construction lifecycle case. The first lifecycle attempt failed on a fixture key-format mismatch; that fixture-only correction was independently reviewed and rerun under a fresh allocation. Runtime source stayed unchanged. Complete coordinator verification remains required. No cause or recovery claim is made for the historical 11:29 interruption.
@@ -0,0 +1,20 @@
1
+ # Upgrade Guide — vNEXT
2
+
3
+ <!-- assembled-by: assemble-next-md -->
4
+ <!-- bump: patch -->
5
+
6
+ ## What Changed
7
+
8
+ The command safety hook recognizes literal search arguments and simple source-file output as data before applying its existing SQL rule. Executable or uncertain contexts keep the original SQL matching. Active expansions, rg execution flags, mixed commands and unsupported programs are not blanket exemptions. Shared init/update logic and a byte-identical standalone template keep installation paths aligned.
9
+
10
+ ## What to Tell Your User
11
+
12
+ Read-only searches and ordinary source-file edits no longer get mistaken for database changes just because their text resembles SQL. Existing command protections remain in place.
13
+
14
+ ## Summary of New Capabilities
15
+
16
+ No new setting or authority. This repairs how the existing safety hook interprets command data.
17
+
18
+ ## Evidence
19
+
20
+ All 27 selected baseline literal-data regressions failed across the three writers. Independent final review concurred. The patched candidate passed 158 unit, 32 native-hook integration and 1 production hook-repair lifecycle case. The first lifecycle fixture-mode failure was preserved and corrected under a fresh allocation; production source did not change. Complete coordinator verification remains required. No command in the fixtures executes database operations, and no live hook was patched.
@@ -0,0 +1,55 @@
1
+ # Side-Effects Review — App send refusal audit
2
+
3
+ **Tier:** 1, SMALL, reversible observation. **Author:** Instar Agent (echo).
4
+
5
+ ## Summary
6
+
7
+ Add a fixed-schema warning on the existing device-authenticated app chat not-serving refusal. Connect existing coordinator leaseFreshness through MobilePairingService; sample after the unchanged boolean authority. No lease, response, request store, retry, policy, capacity or runtime setting changes. Historical 11:29 cause remains unknown.
8
+
9
+ ## Decision-point inventory
10
+
11
+ The original holdsLease boolean remains the sole preflight decision. Diagnostic field validation affects only what can be logged. A sample reporting holding after refusal remains visible as such.
12
+
13
+ ## 1. Over-block
14
+
15
+ No new block/allow surface. A throwing read, clock or writer cannot change the original 409.
16
+
17
+ ## 2. Under-block
18
+
19
+ This observes refusal rather than fixing its cause. A missing log or unavailable sample cannot prove lease health. The timestamp and verdict are sampled after the false preflight and may differ at a clock boundary. Record fields explicitly label that relation.
20
+
21
+ ## 3. Level-of-abstraction fit
22
+
23
+ The refusing route is the missing evidence boundary. Existing native leaseFreshness provides the reason categories; no parallel ownership policy or inferred cause is introduced.
24
+
25
+ ## 4. Signal versus authority
26
+
27
+ Reference: [signal versus authority](../../docs/signal-vs-authority.md). The warning is a signal only. Existing lease authority remains in control, and no diagnostic consumer actuates on the log.
28
+
29
+ ## 5. Interactions
30
+
31
+ The call is after request-store replay and owner/config validation but before rate and intake work, exactly on the original false branch. No request is admitted or reserved by logging. One warning per actual preflight refusal; successful sends and stored replays add none. The optional read is synchronous and contains no network access. Native server stderr retention applies; no new log store or repeating monitor.
32
+
33
+ ## 6. External surfaces
34
+
35
+ Fixed fields: kind, server time, PID, sample relation, allowlisted observed verdict, numeric renewal age and TTL. No request, device, topic, credential, raw error or arbitrary callback field. Invalid values become null/unavailable. Logging failure is isolated. No external calls or user notices.
36
+
37
+ ## 7. Multi-machine posture
38
+
39
+ Machine-local by design: each refusing server records its own process and lease sample. Existing warning-log collection remains the evidence path. No new durable state, URL, replicated authority or notification; there is no one-voice action.
40
+
41
+ ## 8. Rollback
42
+
43
+ Revert the helper, route call, dependency and awareness text in a normal patch. Existing logs remain historical observations; no migration or state repair.
44
+
45
+ ## Verification
46
+
47
+ Tests prepared for allowlisted categories, invalid/unavailable fields, throwing read/writer, strict privacy, signed HTTP refusal and replay behavior, and real coordinator/lease data through production AgentServer construction. Actual allocated unit 9/9 and signed HTTP 18/18 passed. Lifecycle first failed on a fixture wire-key versus PEM mismatch; stopped, preserved the failure, corrected only that fixture through independent review, then the separately authorized lifecycle rerun passed 1/1. Runtime, unit and HTTP hashes remained unchanged. Normal final build passed. Complete coordinator verification remains required; no release acceptance claimed.
48
+
49
+ ## Independent review
50
+
51
+ Dedicated reviewer app_refusal_audit_review found a misplaced production dependency, a repeated verdict accessor read, and missing awareness frontmatter. Each is corrected before test allocation; a changing-getter regression verifies one validated read, and lifecycle setup is covered by cleanup. Final actual reviewer readback concurs with corrected source and all artifacts. No tests were run by the reviewer and no test acceptance is claimed.
52
+
53
+ ## Class closure
54
+
55
+ No agent-authored-artifact defect. One warning follows one pre-existing request refusal; no autonomous action loop, retry, spawn, restart, notification or queue mutation is introduced.
@@ -0,0 +1,55 @@
1
+ # Side-Effects Review — SQL command context
2
+
3
+ **Tier:** 1 narrow reversible false-positive repair, SMALL with dedicated safety review. **Author:** Instar Agent (echo).
4
+
5
+ ## Summary
6
+
7
+ The existing whole-input SQL-shaped matcher refused literal rg searches and source-writing text. A shared embedded Python context check now exempts only recognized literal data operations before the original SQL action. New/update writers import the same snippet; standalone template contains identical bytes. Original patterns, safety levels and all non-SQL decisions are preserved per writer. Baseline actual 27 selected literal cases failed across all three writers; 24 other cases were excluded by selection.
8
+
9
+ ## Decision-point inventory
10
+
11
+ The original SQL matcher retains authority for anything not recognized as literal data. New recognition is intentionally small and bounded: standard data commands without uncertain expansion, literal shell wrappers, one structurally quoted heredoc with safe trailing commands, and a typed subset of Path/string Python operations. No new permission, automatic action, remote request or live installation change.
12
+
13
+ ## 1. Over-block
14
+
15
+ Unknown syntax/programs, variables, globs, comments, uncertain escape/operator forms, control/separator characters, environment overrides/configuration and unsupported Python retain original SQL matching and can still falsely refuse harmless commands. This conservative boundary is explicit. The repair does not claim a full shell interpreter.
16
+
17
+ ## 2. Under-block
18
+
19
+ Incorrect recognition could skip a real SQL check. The classifier rejects active dollar/backtick/process substitutions, uncertain pathname/brace/tilde expansion, rg execution flags and inherited ripgrep configuration. It also rejects printf variable assignment, wrappers with shell startup configuration, and unsupported shell programs. Compound/piped commands must all satisfy the data check. Python values must be literals, proven strings/bytes or real Path expressions from exact known imports; rebinding/dynamic calls/other imports/statements fall back. Unknown or failed classification never skips the original check. Existing policy does not inspect arbitrary script-file contents or independently validate executable binaries; this does not expand that claim.
20
+
21
+ ## 3. Level-of-abstraction fit
22
+
23
+ Command context belongs before the SQL-shaped text matcher. This patch leaves the existing catastrophic/credential/deployment/non-SQL authorities in place. It neither strips every quote nor grants an entire command based on its first word.
24
+
25
+ ## 4. Signal versus authority
26
+
27
+ Reference: [signal versus authority](../../docs/signal-vs-authority.md). This corrects an existing deterministic input classifier, not a new competing policy. Uncertainty preserves the original SQL decision. Dedicated independent review and both sides of each recognized boundary are required before publication.
28
+
29
+ ## 5. Interactions
30
+
31
+ The function is defined but invoked only after an existing SQL pattern matches; its result is cached per hook invocation. No extra interpreter process for ordinary commands without SQL matches. Hook stdin extraction is unchanged; positional JSON command/cmd/tool_input is normalized for context and description text is not promoted to execution. No changes to force-with-lease, catastrophic database flags or credential checks.
32
+
33
+ ## 6. External surfaces
34
+
35
+ No network call, API, setting or credential is added. A matched SQL-looking command may spawn one local Python context check. Input length and nested shell depth are bounded; unknown/parse/read failure keeps original matching. Source text is never evaluated and test command contents are never executed. Existing block or self-verification messages remain unchanged.
36
+
37
+ ## 7. Multi-machine posture
38
+
39
+ Machine-local by design: a command is classified on the machine receiving the hook call. Shipped init and always-overwrite update paths install the same shared classifier on each agent. Existing migration overwrites built-in hooks, preserves custom hooks and is checked twice for idempotence. No replicated state, authority, generated URL or one-voice notification.
40
+
41
+ ## 8. Rollback
42
+
43
+ Normal revert and hook refresh restore the previous matching behavior. No data migration or queue repair. Existing and new agents must both receive the reverted hook through their normal paths.
44
+
45
+ ## Review and verification
46
+
47
+ Reviewer sql_context_review identified argument-variable and glob expansion as execution uncertainty; those now retain the original check with regressions. Dedicated reviewer sql_context_review independently read the final implementation, all three writer paths, tests and artifact, and concurred after the argv, comment, operator, JSON and heredoc boundary corrections. No tests or classifier were run by the reviewer. Baseline 27 expected failures are preserved. Allocated GREEN passed all 158 unit cases across three files and all 32 native-hook integration cases. Lifecycle first failed because its stale-hook fixture was seeded with a non-installed file mode; the driver stopped and preserved that result. An independently reviewed fixture-only executable-mode correction retained the assertion and passed one lifecycle case under a fresh explicit allocation, with all other ten hashes unchanged. Normal build passed and compiled classifier bytes match frozen source. Complete coordinator verification remains required. Broader non-SQL patch-payload classification is a separate tracked next PR, ACT-501, due 2026-11-24T03:00Z; the rejected optional fixture edit remains unapplied and existing floor tests are included unchanged. Normal full verification remains required; no live safety hook is changed.
48
+
49
+ ## Proportion
50
+
51
+ The source classifier is shared by two generated writers and copied into the standalone template; byte parity is enforced. The larger line count is mostly the conservative recognizer, its required template copy and boundary tests. This is one policy-context repair with one independent review, not unrelated hook cleanup.
52
+
53
+ ## Class closure
54
+
55
+ No agent-authored-artifact defect. This is one existing hook evaluation per tool call with at most one context subprocess on a matching SQL input, no new autonomous loop, retry, notification, restart or state repair.