instar 1.3.2012 → 1.3.2013

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.
@@ -2,7 +2,7 @@
2
2
  "schemaVersion": 1,
3
3
  "generatedFrom": "source-tree",
4
4
  "registrySha256": "11e2a45ab1345e2ded6499404ee9962e4e48bcfed4677a4d31dac4492565d2fa",
5
- "packageVersion": "1.3.2012",
5
+ "packageVersion": "1.3.2013",
6
6
  "guards": [
7
7
  {
8
8
  "ref": "docs/audits/phase-b/f10-triage.md",
@@ -1,5 +1,5 @@
1
1
  {
2
- "sha256": "e5aa5b022b2c4654d0598a9af2564d7bf0b3e9a20d08b49c518b8b4f0154acc8",
2
+ "sha256": "4a8d19e0f9284988042d65a60642f58f9b938e03f8f71600d900b1c803f47334",
3
3
  "registrySha256": "11e2a45ab1345e2ded6499404ee9962e4e48bcfed4677a4d31dac4492565d2fa",
4
- "packageVersion": "1.3.2012"
4
+ "packageVersion": "1.3.2013"
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.2012"
5
+ "packageVersion": "1.3.2013"
6
6
  }
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instar",
3
- "version": "1.3.2012",
3
+ "version": "1.3.2013",
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",
@@ -88,14 +88,37 @@ def get_key(version=None):
88
88
  return bytes.fromhex(stdout)
89
89
 
90
90
 
91
+ # `security -i` reads at most 4096 bytes per line. A longer line is not refused: it is split, the first part
92
+ # runs as its own command and stores a truncated item, and only the rest fails (measured on macOS, SEC-155).
93
+ KEYCHAIN_STDIN_MAX_LINE = 4096
94
+
95
+
96
+ def _keychain_add_line(service, account, secret):
97
+ """The one `security -i` input line that adds the key, never trusting any app (-T "").
98
+
99
+ SEC-171: the key goes on standard input, hex-encoded behind -X (the same bytes -w stored), never in the
100
+ process arguments, which `ps` shows to every account on the Mac.
101
+ """
102
+ for name in (service, account):
103
+ if not name or any(c in name for c in '"\\$`') or any(ord(c) < 32 or ord(c) == 127 for c in name):
104
+ raise ValueError("keychain name cannot be passed safely")
105
+ line = f'add-generic-password -s "{service}" -a "{account}" -X "{secret.encode("utf-8").hex()}" -T ""\n'
106
+ if len(line.encode("utf-8")) > KEYCHAIN_STDIN_MAX_LINE:
107
+ raise ValueError("key too long for a safe stdin write")
108
+ return line
109
+
110
+
91
111
  def store_key(key_hex, version):
92
112
  account = f"{KEYCHAIN_ACCOUNT_PREFIX}{version}"
93
113
  _run_security_cmd(["delete-generic-password", "-s", KEYCHAIN_SERVICE, "-a", account])
94
- rc, stdout, stderr = _run_security_cmd([
95
- "add-generic-password", "-s", KEYCHAIN_SERVICE, "-a", account, "-w", key_hex, "-T", "",
96
- ])
97
- if rc != 0:
98
- print(f"Error storing key: {stderr}", file=sys.stderr)
114
+ try:
115
+ line = _keychain_add_line(KEYCHAIN_SERVICE, account, key_hex)
116
+ except ValueError as e:
117
+ print(f"Error storing key: {e}", file=sys.stderr)
118
+ sys.exit(1)
119
+ proc = subprocess.run(["/usr/bin/security", "-i"], input=line, capture_output=True, text=True)
120
+ if proc.returncode != 0:
121
+ print(f"Error storing key: {proc.stderr.strip()}", file=sys.stderr)
99
122
  sys.exit(1)
100
123
 
101
124
 
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "$schema": "./builtin-manifest.schema.json",
3
3
  "schemaVersion": 1,
4
- "generatedAt": "2026-11-24T19:38:37.015Z",
5
- "instarVersion": "1.3.2012",
4
+ "generatedAt": "2026-11-24T20:48:01.086Z",
5
+ "instarVersion": "1.3.2013",
6
6
  "entryCount": 210,
7
7
  "entries": {
8
8
  "hook:session-start": {
@@ -1444,7 +1444,7 @@
1444
1444
  "type": "playbook-script",
1445
1445
  "domain": "context",
1446
1446
  "sourcePath": "playbook-scripts/playbook-hmac.py",
1447
- "contentHash": "94798235ff0a15a171f5988843d6d719b44e5dfece3bfad2320f2462f86f0580",
1447
+ "contentHash": "952ba35a89e18b8bfb43241510b793d1f951372d3167434df93154a515a1634b",
1448
1448
  "since": "2025-01-01"
1449
1449
  },
1450
1450
  "playbook-script:playbook-lifecycle.py": {
@@ -2,7 +2,7 @@
2
2
  "schemaVersion": 1,
3
3
  "generatedFrom": "source-tree",
4
4
  "registrySha256": "11e2a45ab1345e2ded6499404ee9962e4e48bcfed4677a4d31dac4492565d2fa",
5
- "packageVersion": "1.3.2012",
5
+ "packageVersion": "1.3.2013",
6
6
  "guards": [
7
7
  {
8
8
  "ref": "docs/audits/phase-b/f10-triage.md",
@@ -1,5 +1,5 @@
1
1
  {
2
- "sha256": "e5aa5b022b2c4654d0598a9af2564d7bf0b3e9a20d08b49c518b8b4f0154acc8",
2
+ "sha256": "4a8d19e0f9284988042d65a60642f58f9b938e03f8f71600d900b1c803f47334",
3
3
  "registrySha256": "11e2a45ab1345e2ded6499404ee9962e4e48bcfed4677a4d31dac4492565d2fa",
4
- "packageVersion": "1.3.2012"
4
+ "packageVersion": "1.3.2013"
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.2012"
5
+ "packageVersion": "1.3.2013"
6
6
  }
@@ -0,0 +1,23 @@
1
+ # Upgrade Guide — vNEXT
2
+
3
+ <!-- assembled-by: assemble-next-md -->
4
+ <!-- bump: patch -->
5
+
6
+ ## What Changed
7
+
8
+ SEC-171. `playbook-scripts/playbook-hmac.py` stored its HMAC signing key in the macOS keychain with `security add-generic-password ... -w <key>`. That put the key in the process arguments, which `ps` shows to every account on the Mac. It now sends the command to `security -i` on standard input, with the key hex-encoded behind `-X`. That is the approach SEC-155 used for the agent's other keychain writes. The stored bytes and the "trust no app" setting (`-T ""`) are unchanged, so reading the key works as before. A line too long for `security -i` to read whole is refused rather than split into a truncated item. A failed write still fails the command.
9
+
10
+ ## What to Tell Your User
11
+
12
+ - **Signing key kept private**: "The key I use to sign my playbook no longer shows up in the list of running programs when I save it."
13
+
14
+ ## Summary of New Capabilities
15
+
16
+ | Capability | How to Use |
17
+ |-----------|-----------|
18
+ | Playbook key stored via standard input | Automatic |
19
+
20
+ ## Evidence
21
+
22
+ - `tests/unit/sec171-playbook-hmac-stdin.test.ts`: the real `store_key` runs with `subprocess.run` replaced by a recorder. The add goes to `security -i` with the exact stdin line and the key never appears as an argument. A failed write exits 1. An over-long line is refused before any add. Unsafe names are refused.
23
+ - A live run on a Mac with an unused key version stored the item and then deleted it.
@@ -0,0 +1,26 @@
1
+ # Side effects: playbook-hmac.py stores its key via `security -i` standard input (SEC-171)
2
+
3
+ In plain words: `store_key` passed the playbook HMAC key as `-w <key>`, so it sat in process arguments that `ps` shows to every account on the Mac. It now goes on standard input to `security -i`, hex-encoded behind `-X`, the approach SEC-155 used for the agent's other keychain writes.
4
+
5
+ Tier 1 by size, security-sensitive: an independent second-pass review is attached below. Size: one function in `playbook-scripts/playbook-hmac.py` plus a new helper, and 1 new unit test file.
6
+
7
+ ## What changes for running agents
8
+ - **`store_key`** still deletes the old item first. It then builds `add-generic-password -s "playbook-hmac" -a "playbook-hmac-v<N>" -X "<hex of the key text>" -T ""` with `_keychain_add_line` and runs `/usr/bin/security -i` with that line as input. The stored bytes are the key's hex text, exactly what `-w` stored, so `get_key()` (`find-generic-password -w`) reads the same value. `-T ""` (no app trusted) is unchanged, and a live probe confirmed `security -i` accepts it.
9
+ - **Guards.** A line over 4096 bytes is refused before any add, because `security -i` splits a longer line and stores a truncated item (measured for SEC-155). A real key is 64 hex characters, giving a line of about 200 bytes. Names containing a quote, backslash, `$`, backtick or control character are refused, though the service and account names are fixed.
10
+ - **Failure.** A non-zero exit still prints `Error storing key` and exits 1, as before.
11
+
12
+ ## Signal vs authority
13
+ Not applicable: this changes how a key reaches the keychain, not who may act.
14
+
15
+ ## Second-pass review
16
+ **Reviewer:** independent Claude Sonnet subagent (fresh context, read-only, given the finding and the diff), 2026-11-22. Verdict: CONCUR. No argument secret remains in `playbook-scripts`; the only `-w` left is the read in `get_key()`. Byte parity holds, so `bytes.fromhex` still works. The blocked characters and the produced line match the test exactly. Failure behavior is preserved. It ran the 4 tests and all pass. The harness uses only the standard library and never touches a keychain.
17
+
18
+ ## Rollback
19
+ Revert the commit. Stored items are unchanged.
20
+
21
+ ## Tests
22
+ - `tests/unit/sec171-playbook-hmac-stdin.test.ts` (new, 4 cases): the real module runs in an isolated Python with `subprocess.run` replaced by a recorder. The delete and then `security -i` are called with the exact input line and the key never appears as an argument. A failed write exits 1. An over-long key is refused before any add. Unsafe names are refused. It passes here.
23
+ - Live on this Mac: `store_key` with an unused version (999) stored the item, which was found and then deleted.
24
+
25
+ ## Class-Closure Declaration
26
+ - `unbounded-self-action`: closure n/a. The same single keychain write per call.