Skip to content

feat(hooks): let an agent propose a hook on a card the person creates - #47125

Open
buluoray wants to merge 2 commits into
mainfrom
crew/slack/hook-card-b
Open

buluoray wants to merge 2 commits into
mainfrom
crew/slack/hook-card-b

Conversation

@buluoray

@buluoray buluoray commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: An agent in any chat or bot can propose a PreToolUse hook on a card, and the person creates it with one press, choosing where it runs.

An agent that keeps making a mistake a rule could catch can only save a lesson, which works only when it is read, or describe a hook and send the person to the Hooks tab to type it in. Other gateway settings (goals, MCP servers, capabilities) already reach the person as a card they apply; hooks do not.

Why it matters

A hook stops the call every time; a lesson does not. Making the hook one press away turns "I made that mistake again" into a rule that holds, without the person writing a shell script by hand.

Not a goal

  • Editing, switching off or deleting hooks from an agent.
  • Hook templates or a hook library.
  • Creating a hook without a card.
  • Events other than PreToolUse on the card.

What changed (motivation → approach → change)

  • Goal: the card pattern other gateway changes use, for one hook.
  • propose_hook (kirocrew-core, so every chat and bot has it) sends a name, a one-sentence does line, matcher, command and reason to POST /api/cards/agent/request-hook. Only a turn the person sent in the dashboard raises the card; a task, schedule, sub-agent or channel turn gets a refusal saying who should ask instead. The body cannot name a scope.
  • The gateway offers the scope from the asking session: the bot it belongs to (by id) and the folder of the chat's project. The card (hook.create) shows the matcher, a Does row with the agent's plain sentence of what the hook stops (above the command, for a person who will not read the code; not stored with the hook), the whole command as a numbered code block that wraps (a wrapped part hangs in under its line, so every character is in view), the reason, and tick boxes: the bot and its tasks, chats working in the folder, all chats. The bot is ticked in a bot's chat, the folder in an ordinary chat. While All chats is ticked the other two are locked; unticking it brings back the earlier ticks. Each tick re-previews the card, so Create stores what the boxes show; a tick can only name the offered bot or folder.
  • A card whose stored values could differ from what it shows is refused when it is raised: a name, matcher, command or folder the create route would save differently (trimmed ends, Unicode normalized, stripped characters), any control or invisible format character, a space or tab at a line's end, a matcher holding a space, or a folder that is not already resolved. At the press, a folder that now resolves to another path is refused and nothing is stored.
  • Apply is the Hooks tab's own POST /api/hooks; on an admitted hook.create apply step (REQ_CARD_HOOK_CREATE) it also refuses a folder that now resolves elsewhere than the card showed. The hook is stored in hooks.json like any other and listed on the Hooks tab, where the person edits, switches off or deletes it. The card has no Undo (offers_no_undo): the Hooks tab is where a hook is removed. The yellow notice ends "Turn it off in Hooks.", where Hooks is a link to the Hooks page, and after Create the card's result line carries the same "Hooks" link. A refused press says why on the card, in the dashboard's own words: "That bot was deleted, so no hook was created. Ask for a new card." or "That folder now leads somewhere else, so no hook was created. Ask for a new card."; the person can close that line, and a later failure shows again. The card says what the hook does in its title (Add hook: {name}), and propose_hook's description asks for a name and a does line that say it in plain words. Only their shape is checked, so both may be in any language: a does line that is empty, more than one sentence (Latin, Devanagari or CJK stops) or only repeats the name is refused, and no word list or word count decides the rest. A matcher of plain tool names reads in the words the agent's Tools list uses (toolMeta): execute_bash|shell reads "Run shell commands" (KAS's shell is the same tool, said once), and fs_write|@git/push reads "Write files or @git/push"; a pattern stays as written. propose_hook asks for a does line that says the effect the person will see, not a list of commands. The card's first rows, above the yellow notice, are the bot's own words, labelled "{bot} says" (or "The bot says"), and "When it matches", which the system writes from the hook's event, never from agent text: "Can stop the call. The command decides each time, and the agent is told why." Then Runs before, Command, Why and Runs in. After a press refused because the bot was deleted (named when the card knows it) or the folder now leads elsewhere, the card shows no Create; other refusals keep it. The command stays whole. Each caption says whose chat raised the card: in a bot's chat the card offers that bot and the chat's folder; in an ordinary chat it has no bot row and offers the folder.
  • The shared prompt gets one line: propose a hook for a mistake a rule on a tool call can catch; save a lesson for what needs judgment.
  • builder-security checked: one route added under the existing strict-internal /api/cards/agent prefix, with the same verified-caller and user-turn gate request_server uses; no bind or listener change.

Backwards compatibility

Compatible: hooks in hooks.json load and save as before, and the create route behaves as before when from_card is absent.

Removes nothing: no field, route, hook or behaviour is taken away.

Tests

  • test/test_change_card_hook.py: hidden and control characters, text the route would store differently, a missing, two-sentence (CJK stops included) or name-repeating does line, a name and does line in Chinese, Japanese, Korean, Hindi and German accepted, and a tick naming another bot or folder are refused; the kind is raised only through propose_hook; the preview shows the whole command and plans the card's create; the Does row sits above Command and is not in the create body; the card offers no Undo; end to end over the real card routes and Hooks routes: nothing exists before the press, the agent cannot name a scope or create a hook as the card's itself, a re-tick re-previews, a replay of the earlier plan is refused, the press stores exactly the ticked scope in hooks.json, a cancelled card creates nothing, and a bot deleted while the card waited creates nothing.
  • website/src/cards/ConversationCard.test.tsx: a refused hook press shows the localized reason, closes on its ✕, and shows again on the next failure; a refused tick shows again after the same refusal was closed.
  • test/test_request_server_schema_parity.py: propose_hook's validator matches its advertised schema.
  • website/src/cards/HookCard.test.tsx: title, the scope drawn as boxes with the bot name and full folder, re-preview on each tick, all chats clears both and locks the other two, unticking it restores the earlier ticks, a long command wraps with one number per source line.

Proof: not provable -- other: feature PR, the base has no hook card for the tests to exercise

Manual verification

UI copy, signed off by the owner: kind label Hook · title "Add hook: {name}" · risk line "This command runs on this computer before each matching tool call. Turn it off in Hooks." (Hooks is a link) · refusals "That bot was deleted, so no hook was created. Ask for a new card." and "That folder now leads somewhere else, so no hook was created. Ask for a new card." · rows {bot} says / When it matches / Runs before / Command / Why · empty matcher "Every tool call" · Runs in boxes "{bot} and its tasks", "Chats working in {folder}", "All chats" · button Create hook. Tool and prompt text: propose_hook's description and the one prompt line.

Real-machine verification

Machine: a new throwaway cloud dev box (label hcb-c2833), Amazon Linux 2023, x86_64, with a scratch data home holding one bot, mate. Each side was installed from a git archive of its commit into a fresh venv on a standalone CPython 3.12.16.

Path: in process, not a live agent turn (the box has no model sign-in). The card is built by the gateway's own card catalog from an agent's propose_hook parameters (validate_params, then build_preview), as the request route does. The press is the card's planned apply step, POST /api/hooks with its create body; the script stores that body with ScriptHookStore.create, which the route calls. The created hook then fires through the gateway's PreToolUse gate, permission_pre_tool_block, with the real sandboxed runner. The hook's command is the card's own: grep -q 'git checkout' && { echo 'Work in a worktree instead.' >&2; exit 2; } || exit 0, a shell one-liner that starts inside the hook sandbox and reads the call. The bot's task is recorded with the real record writer (note_crewmate_worker_session). Script: proof-b.py, the same file on both sides.

Before (base: #47124's head bba91530a1): python proof-b.py ->

card: refused (CardCatalogError: unknown card kind 'hook.create')

After (head d46ced162d): same command ->

card title: Add hook “No git checkout in the live checkout” · runs in Mate and its tasks
card rows: {"hook_does": "Stops the agent from switching branches in this checkout", "hook_effect": "can_stop", "hook_matcher": "execute_bash"}
press: POST /api/hooks scope_bot=mate
mate's task: git checkout main               DENIED  (No git checkout in the live checkout: Work in a worktree instead.)
mate's task: git status                      ALLOWED
another chat: git checkout main              ALLOWED

The hook the card created runs its own check: it denies git checkout in the bot's task with its own reason, lets that task's git status through, and lets another chat's git checkout through because the card scoped it to the bot.

Cleanup: the box was deleted at 2026-12-05T15:01:18Z. The provider's listing filtered to its label (and the earlier box's), at 15:01:44Z:

$ <list dev boxes> | grep -e hcb-c2833 -e hcscope
(no rows, exit 1)

Screenshots / video

All from head d46ced1 (the card is unchanged at ae434b1, which only restacks it on #47124's rebase), rendered by the real ChangeCard. The Runs in rows are 28px apart, and each whole row is the press target. A long command wraps at spaces and after shell punctuation; it breaks inside a word only when one word is wider than the line. A refused press shows its reason in the dashboard's own words with a close (✕); the next failure shows again.

A bot's chat: bot ticked, desktop light
A bot's chat: a long command, phone dark
An ordinary chat (no bot row): folder ticked, phone light
A refused press: the bot was deleted, with its close, desktop
A refused press: the folder now leads elsewhere, with its close, phone

After a successful Create (head ae434b1450, the same capture page with the card's status set to applied): the card collapses to its result line, which links to the Hooks page (href="/hooks"), where the hook is turned off.

After Create: the result line with the Hooks link, desktop light
After Create: the result line with the Hooks link, phone dark

More

A bot's chat: a long command, desktop dark
A bot's chat: bot ticked, phone dark
An ordinary chat: folder ticked, desktop dark
A bot's chat: All chats ticked, phone dark
A refused press: the bot was deleted, phone
A refused press: the folder now leads elsewhere, desktop

Related Issues

Stacked on #47124 (hook scope); merge that first.

Checklist

  • A Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...); PR Hygiene does not count commits
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license.

@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/hook_runtime/hook_dispatch.py

  • src/kiro_crew/hook_runtime/script_hooks.py

  • src/kiro_crew/hooks.py

  • No reasoning template for 3a40d04 yet.

How to clear this check:

  1. The PR author posts the template below as a PR comment, with
    every field filled (N/A needs a reason). Keep the
    Head commit line: it must name the current head SHA.
  2. The check turns green within a minute, with no push.
  3. A new push resets this check: post it again for the new head.

Only the author's comment counts this way. A reviewer can instead
paste the filled template into an "Approve" review on this head.
Merging still needs a reviewer's approval.

## Sensitive change review
- Head commit: 3a40d04fbb3c41d9d940aad1dd372e4eb9c1744f
- What rule changed:
- Before -> after (what was allowed/blocked, now):
- Worst case if wrong (breaks commands / leaks secret / locks user out):
- Evidence checked (which sandbox result proves it):
- No regression:
  - Tools still work (which tools/commands were run, result):
  - Backward compatible (old config / old data / old callers still work, how checked):
  - Existing tests (which suites passed on this head):
- How to undo:

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Dec 4, 2026
@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 3a40d04fbb3c41d9d940aad1dd372e4eb9c1744f — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the change reuses the existing card-apply pattern, writes only through the Hooks tab's own create route, and changes nothing when the card flag is absent.

[DESIGN-REVIEWED] 3a40d04

Description read

[DESCRIPTION-READ] 1ef1a08c2c5dd84a4a160feb9e23915f851499c0bb200cc152b2d759b442e82f

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

UX-level review of 3a40d04fbb3c41d9d940aad1dd372e4eb9c1744f — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

Nothing blocks: the screenshots cover every new control and state, and the blind reader read the main controls (Create hook, Decline, Runs in) correctly.

Notes

  • "When it matches" / "Can stop the call. The command decides each time, and the agent is told why." The reader guessed at it: "I don't know what 'the call' or 'matches' means here". Try "Before each matching action" / "Can block the action and tell the agent why."
  • The locked "Runs in" boxes (shot-11) only look faded. The reader "can't tell whether the faded ones are locked or just unticked". Add a short note under All chats, such as "Covers the choices above".
  • "That folder now leads somewhere else…" doesn't say which folder ("no idea which folder"). Put the folder path in the message, and change "Ask for a new card" to "Ask the bot for a new card".

[UX-REVIEWED] 3a40d04

Description read

[DESCRIPTION-READ] e626fb7518034cebc5fb53b08f749c279971768faa326c89e71d667ac3256647

That sha256 names everything this verdict read: the PR description, plus the 16 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 3a40d04fbb3c41d9d940aad1dd372e4eb9c1744f — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. This is an additive card that only a person's press turns into a hook. No default changes, and no existing capability is removed.

Notes

  • Item 9 — rides along: the ✕ on the error line comes from onDismiss={() => setClosedProblem(failureKey)} in ChangeCard.tsx, which every card kind renders, but the description frames it as a hook-card behaviour ("the person can close that line").
  • Item 10 — second spelling: HOOKS_QUERY_KEY = ['hooks'] in api/cards.ts re-spells the literal queryKey: ['hooks'] at pages/HooksPage.tsx:501 (2 sites, grepped \['hooks'\]). Subtraction: make HooksPage import the constant so only one spelling remains.

What this change ships

Inventory (10 items) — 8 justified

Intent: let an agent turn a repeated mistake into a hook the person creates with one press. ADDITION.

  1. New propose_hook tool in every chat and bot; tasks, schedules, subagents and channels are refused — justified
  2. New hook.create card shows the matcher, the agent's Does line, a system-written "When it matches" row, the command and Why — justified
  3. Runs in tick boxes for the offered bot, the folder or all chats; each tick re-previews the card — justified
  4. A card whose text would be stored differently from how it shows is refused when raised — justified
  5. Create refuses a deleted bot or a moved folder, then hides Create — justified
  6. The card has no Undo; the warning and the result line link to Hooks — justified
  7. Shared prompt line: propose a hook for a mistake a rule can catch, save a lesson for one needing judgment — justified
  8. Matcher shown in the Tools list's words — justified
  9. The error line can be closed on every card kind — rides along
  10. Hooks list refreshes when a card creates a hook — duplicate of pages/HooksPage.tsx:501 key literal

[FIRST-PRINCIPLES-REVIEWED] 3a40d04

Description read

[DESCRIPTION-READ] 408006cdce24f66af3f4b40953ee32395ed31e81f916e6f43a88b37956736159

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 3a40d04fbb3c41d9d940aad1dd372e4eb9c1744f — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 3a40d04

Verdict parsed from the review's SHA-scoped output markers for commit 3a40d04fbb3c41d9d940aad1dd372e4eb9c1744f.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 3a40d04fbb3c41d9d940aad1dd372e4eb9c1744f false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — 🔴 changes requested (blocking)

GPT 6.1 found at least one blocking issue that must be resolved before merging 3a40d04fbb3c41d9d940aad1dd372e4eb9c1744f. Adjudication produced no [GPT-ADJUDICATED] marker for 3a40d04: the adjudication stage FAILED TO RUN (its raw output is in the Adjudication details block -- typically an API or setup error), so no proportionality review took place and GPT's blocking verdict stands unreviewed.

This comment is updated in place on each push.

BLOCKING -- test/test_change_card_hook.py:315 -- Supply a directory junction instead of skipping the folder-swap check

pytest.skip("this host cannot create a directory link")
Trigger: On Windows without symlink privileges, the probe raises OSError and skips the test before the folder-swap callback or refusal assertions run.
Outcome: The folder-swap check is omitted on a supported platform although make_dir_link supplies an unprivileged junction; the base rule explicitly forbids skipping link behavior the harness can supply.
Anchor: a-ratchet-may-only-tighten
Fix: Remove the probe and skip, and use kiro_crew.testing.links.make_dir_link(project, other) in the swap callback.
Sites: test/test_change_card_hook.py:313; test/test_change_card_hook.py:321

[BLOCK-MERGE] 3a40d04
[GPT-REVIEWED] 3a40d04
False positive or not applicable? A repository writer can comment:
/ai-review override gpt 3a40d04fbb3c41d9d940aad1dd372e4eb9c1744f false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Security Scope Review -- ✅ PASS

Which legitimate operations does 3a40d04fbb3c41d9d940aad1dd372e4eb9c1744f newly refuse? Updated in place on each push. A script-confirmed regression blocks; the model proposes candidates and never decides a refusal.

Verdict basis: adjudicated, zero confirmed regressions.

Security scope review -- adjudicated candidates

  • macos-latest (platform posix): 9 classified, 0 newly refused, 9 still allowed.
  • ubuntu-latest (platform posix): 9 classified, 0 newly refused, 9 still allowed.
  • windows-latest (platform windows): 6 classified, 0 newly refused, 6 still allowed.

No candidate flipped from allowed to refused.

Scope-Verdict: PASS

Reason: This diff leaves all three shell deny tiers unchanged (sensitive-bash, exfil, deny-rules). What it tightens is the new hook.create card validator and the card-press branch of POST /api/hooks, and the classifier has no verdict for either of those. I can't confirm an over-refusal there, and an empty adjudicated set doesn't show those guards are clean. The gap is named under UNADJUDICATED.

TIGHTENING: POST /api/hooks now refuses a card's apply step (gated on request.get(REQ_CARD_HOOK_CREATE) is True) when the folder moved or the bot was deleted. The threat is a card press storing a hook whose scope is wider than, or different from, what the person saw on the card: if confirmed_folder and resolved != folder: raise FolderMoved("the folder on the card now resolves to another path"), plus if bot and not await asyncio.to_thread(_bot_configured, bot): ... "code": "bot_deleted".

ADJUDICATED: 14 candidates. The harness has handed back no confirmed newly-refused rows, so this review reports none.

PLATFORM COVERAGE: Rows cover posix, windows and any.

  • posix: the touched area's test runs, the vitest card test, the capture script, and a jq | grep … exit 2 PreToolUse guard of the sh -c shape the new tool description asks agents to write. Also a read-only git -C <folder> status one token off what a proposed hook would stop, and a look at the state directory.
  • windows: the .venv\Scripts\python.exe test run, the npx.cmd shim, the powershell -NoProfile -Command "..." guard spelling the description tells agents to use under cmd /c, a drive-letter/backslash git -C, and %USERPROFILE%. These cover the one platform assumption the diff makes (_hook_shell(sys.platform): sh -c vs cmd /c).
  • any: kirocrew logs -n 100.

The diff's other platform assumption is in path resolution (os.path.realpath / os.path.normpath). That isn't shell text, so no row can probe it.

UNADJUDICATED:

  • Guard 1: change_card_hook.clean_params / _does_line / _stored_as_shown.
    • Call path: propose_hook MCP tool → POST /api/cards/agent/request-hook (api_cards_agent_request_hook) → propose_for_caller(kind="hook.create") → validate_params → clean_params.
    • Inputs I would have submitted:
      • a does sentence holding an abbreviation or a decimal, such as "Stops the agent from running e.g. git fetch." or "Stops pushes to v1. 2 branches". Both trip _MID_SENTENCE on ". ".
      • a CJK does with an inner "。".
      • a multi-line POSIX script command whose heredoc line ends in a space.
      • a matcher like execute_bash | shell with spaces around the pipe.
      • a reason ending in a closing quote or parenthesis after the full stop, which fails endswith(_SENTENCE_END).
    • These are all new surface with no prior allowed baseline, so none is a regression of an existing operation.
  • Guard 2: the card-press FolderMoved check in ScriptHookStore.create(..., confirmed_folder=True).
    • Call path: card Create → _arm_card_undo_cron_guard sets REQ_CARD_HOOK_CREATE → api_hooks_create → _apply_scope, comparing realpath(expanduser(folder)) to the offered string.
    • Inputs I would have submitted: a Windows project on a mapped drive (realpath may hand back the UNC spelling), a macOS project under /var or /tmp (which resolve to /private/...), and a case-only spelling difference on a case-insensitive volume.
    • The offered folder already comes through scope_of → normalize_folder, so the two resolutions should agree unless the filesystem changes between them. I can argue a narrowing here but can't confirm one.
    • Manual Hooks-tab creates skip this branch (card_press False), so the existing Hooks-page flow is not newly refused.

[SCOPE-REVIEWED] 3a40d04

@buluoray
buluoray force-pushed the crew/slack/hook-card branch from 166196a to 0f5c3df Compare December 4, 2026 09:29
@buluoray
buluoray force-pushed the crew/slack/hook-card-b branch from 5be6368 to bc6432d Compare December 4, 2026 09:32
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Dec 4, 2026
@buluoray
buluoray force-pushed the crew/slack/hook-card branch from 0f5c3df to 94a5e58 Compare December 4, 2026 10:43
@buluoray
buluoray force-pushed the crew/slack/hook-card-b branch from bc6432d to d9bd7c2 Compare December 4, 2026 10:43
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Dec 4, 2026
@buluoray
buluoray force-pushed the crew/slack/hook-card branch from 94a5e58 to c621f40 Compare December 4, 2026 11:01
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Dec 4, 2026
@buluoray
buluoray force-pushed the crew/slack/hook-card branch from c621f40 to 3ec500c Compare December 4, 2026 11:22
@buluoray
buluoray force-pushed the crew/slack/hook-card-b branch from d9bd7c2 to e0dab22 Compare December 4, 2026 11:22
@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Dec 4, 2026
@buluoray
buluoray force-pushed the crew/slack/hook-card branch from 3ec500c to cc0429c Compare December 4, 2026 12:23
@buluoray
buluoray force-pushed the crew/slack/hook-card-b branch from e0dab22 to a87e0af Compare December 4, 2026 12:23
@buluoray

buluoray commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

Review dispositions for a87e0af38f8fe9f1febba0d7272d7920d001bab9 (findings on e0dab22e1c1):

Opus / GPT F3 — card-created hooks missing from backup, export and restore — fixed. Class, every site that bundles, restores or switches off hooks.json: snapshot_build.py staging, portability_stream.py export writer and size estimate, snapshot_restore.py replace (CLI and dashboard import), snapshot.py hold-back, portability.py import, snapshot_components.py lists. The bundle keeps its one hooks.json member and the approved hooks are folded into its hooks list (approved_hooks.fold_for_bundle), so older versions restoring it get them too, the existing switch-off covers them, and a bundle never writes into the approved store. A replace restore saves the live approved file into the rollback directory and empties it; a failed replace puts it back; merge leaves both files. Tests: test_export_carries_card_approved_hooks_in_hooks_json, test_snapshot_carries_approved_hooks_and_restore_brings_them_back_off, test_replace_restore_drops_approved_hooks_the_snapshot_did_not_hold, test_failed_replace_puts_the_approved_hooks_back, test_merge_restore_keeps_existing_hooks_and_approved_hooks; each fix reverted turns its test red.

GPT F1 — a failed approved-file write leaves an ordinary change committed — fixed. A mutation of one hook now writes only the file that holds it (_save(approved=...)); a delete of an approved hook that hooks.json also holds a copy of rewrites both, so the copy cannot take its place. Test: test_an_edit_writes_only_the_file_that_holds_the_hook (red when reverted).

GPT F2 — Undo deletes a hook edited after creation — fixed. The card's state now includes the created hook's settings (name, event, matcher, command, skills, timeout, enabled, scope), not its run counts, so Undo after an edit on the Hooks tab answers 409 and keeps the edit. Test: test_undo_after_an_edit_on_the_hooks_tab_keeps_the_edit (red when reverted).

UX — "the card never says in plain words what the hook does" — rebutted, with two changes. The card states the effect in its title (Add hook: {name}, e.g. "No git writes in the live checkout"), when it runs (Runs before), why (Why) and where (Runs in). A second agent-written sentence would restate the title and add one more place where the agent's words can differ from the command the person approves. What this push does instead: propose_hook refuses a name that does not say what the hook does (fewer than three words, e.g. "guard"), and a matcher of plain tool names joined by | reads as "execute_bash or shell" (the language's own list format, no new string). The capture fixture's reason now fits its card. Please re-read on this head.

@buluoray
buluoray force-pushed the crew/slack/hook-card-b branch from a87e0af to 23ba2c9 Compare December 4, 2026 12:43
@buluoray

buluoray commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

Review dispositions for 23ba2c91247a92500634de3ad3b2e34ffa1e38e5 (findings on a87e0af38f8):

First Principles — the second hook store is oversized — removed as suggested. Card hooks are stored like any other hook: the card's apply posts to POST /api/hooks with from_card, accepted only on an admitted hook.create apply step, and the hook lands in hooks.json. approved_hooks.py, its leaf rows, the two-file save and the backup/export/restore changes that existed only for it are gone. The Undo fix (409 when the hook was edited after the press) stays.

UX — a plain-words line saying what the hook does. The previous review read the earlier description. The card states the effect in its title (Add hook: {name}), propose_hook now refuses a name that does not say what the hook does, and a matcher of plain tool names reads as "execute_bash or shell". The description's screenshots are from this head.

@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Dec 4, 2026
@buluoray
buluoray force-pushed the crew/slack/hook-card-b branch from fa10cf4 to 2327768 Compare December 4, 2026 17:43
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Dec 4, 2026
@buluoray
buluoray force-pushed the crew/slack/hook-card branch from a3b1e33 to 3295cae Compare December 4, 2026 20:32
@buluoray
buluoray force-pushed the crew/slack/hook-card-b branch from 2327768 to dcebc6d Compare December 4, 2026 20:32
@buluoray
buluoray force-pushed the crew/slack/hook-card branch from 3295cae to 4537074 Compare December 4, 2026 20:46
@buluoray
buluoray force-pushed the crew/slack/hook-card-b branch from dcebc6d to 2104887 Compare December 4, 2026 20:46
@buluoray
buluoray force-pushed the crew/slack/hook-card branch from 4537074 to 3b1c2db Compare December 4, 2026 21:31
@buluoray
buluoray force-pushed the crew/slack/hook-card-b branch from 2104887 to f1b8f53 Compare December 4, 2026 21:31
@buluoray
buluoray force-pushed the crew/slack/hook-card branch from 3b1c2db to 993301b Compare December 4, 2026 21:58
@buluoray
buluoray force-pushed the crew/slack/hook-card-b branch from f1b8f53 to 5ac2d08 Compare December 4, 2026 22:01
@buluoray

buluoray commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

Review dispositions for 5ac2d0823a2a8a30fc94240c74955e78201550d3 (findings on f1b8f535f40):

GPT — a descriptive hook name in Chinese or Japanese is refused as too short — fixed. A name with at least 4 letters from a script written without spaces (CJK, Hiragana, Katakana, Thai, Lao, Khmer, Myanmar) now passes. Test: test_a_descriptive_name_in_an_unspaced_language_is_accepted.

GPT — applying a card for a bot deleted while the card waited creates a hook that never runs — fixed. The card step of api_hooks_create returns 409 bot_deleted when the bot is no longer configured, and writes nothing. Test: test_a_card_for_a_bot_deleted_while_it_waited_creates_nothing.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Dec 4, 2026
@buluoray
buluoray force-pushed the crew/slack/hook-card branch from 993301b to 495a700 Compare December 4, 2026 23:10
@buluoray
buluoray force-pushed the crew/slack/hook-card-b branch from 5ac2d08 to 8e1e4c0 Compare December 4, 2026 23:10
@buluoray

buluoray commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Review dispositions for 7256cd863ac645b34f4a504f855595a58ca4c1e0 (findings on f7aac6bff47):

GPT F1 — a POSIX hook proposed on Windows runs through cmd.exe and denies every call — fixed. The propose_hook description and its command field now name the shell this computer runs hooks with (_hook_shell(sys.platform)): on Windows, one line that cmd.exe runs, with a PowerShell guard as the example; elsewhere, a POSIX shell command or script, as before. Both sites the finding listed (the tool text and the field) use it. Test: test_the_proposed_command_is_described_in_the_shell_this_computer_runs.

Also in this push:

  • The _bot_configured helper from the earlier bot_deleted fix is now named in the hooks facade's manifest. test_facade_mirror_guards had flagged it.
  • The routes test's read-only store double now takes the if_unchanged keyword the delete route passes.

@buluoray

buluoray commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Disposition for the review round on 30e3f8d. Fixed in d9ae478, which is rebased onto A's 7f0f60b.

  • GPT: a closed refusal hides the same refusal on the next tick (ChangeCard.tsx:278). Fixed for the whole class. Every failure the card reports now goes through one report helper: preview, the name field, apply, cancel, dismiss and recover all use it, and it reopens a closed line. Test: ConversationCard.test.tsx "shows a refused tick again after the person closed the same refusal". It fails with the reopen removed.
  • First Principles: the description promised an Undo the diff does not ship. Fixed in the description. ## What changed and ## Tests now say the card has no Undo and that the Hooks tab removes a hook.
  • FP note, item 8: the doc said "POSIX shells only" while Windows agents are told to write PowerShell. Fixed. The doc now says the command runs through sh -c, or cmd /c on Windows.
  • FP note, item 9: changedHooks checked 'undone', which this card never reaches. Fixed. The arm is gone, and the test checks undone among the states that do not re-read the list.

@buluoray

buluoray commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Disposition for the UX review on d9ae478. Fixed in c776c17, which is rebased onto A's 1f4485c.

  • Blocker: a reader would not press Create hook. Fixed in two places.
    • Order. The Does row is now the card's lead row, read right under the title and above the yellow notice (leadField in cardRegistry.ts, rendered by ChangeCard). Runs before, Command and Why follow below the notice. No new string. Test: ConversationCard.test.tsx "reads what a hook does above the warning…". It fails with the lead row removed.
    • Why. propose_hook now requires reason as the agent's own account, one full first-person sentence, for example "I ran git fetch in the live checkout twice today." change_card_hook.reason_line sends a fragment back to the agent before a card is raised, the same way a bad Does line goes back. The label stays "Why". Tests: test_a_why_that_is_not_the_agents_own_full_sentence_is_refused, test_a_first_person_sentence_is_the_cards_why (English, German, Chinese) and test_a_fragment_why_goes_back_to_the_agent_and_raises_no_card.
  • Evidence gap: no frame of a refused press. Closed on d9ae478 with frames in the description. New frames of this head replace them.
  • Note: Runs in reads as single choice. Kept. In HookScopeOptions the bot and folder boxes tick on their own, and both can be on. "All chats" clears and locks the other two, and unticking it brings back the earlier ticks (HookCard.test.tsx). That is the behaviour the owner approved.
  • Note: Decline looks faint in dark mode. Not changed here. Decline is the shared card button, text-muted at 5.24:1 on the dark card, which passes AA. Tracked for every card kind in Change card Decline reads as disabled in dark themes #47665.

@buluoray

buluoray commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Disposition for head 8e20ad5 (rebased on #47124's new head).

GPT: the first-person word list for reason refused Korean, Hindi and pro-drop sentences. Agreed. The word list is gone. change_card_hook.reason_line checks only the shape: present, one line, one sentence, ending punctuation (Latin, Devanagari or CJK), no hidden characters. The first-person ask lives in propose_hook's description. A sentence like "Ran git fetch twice." passes; that is accepted, because no list knows every language a reason is written in.

Same assumption, two more places, fixed in this push.

  • The does line had an English list of "generic" words. It is gone. _does_line now checks only shape: one line, one sentence (CJK stops now count as sentence ends too), and more than the hook's name again.
  • The name check counted spaced words and refused a name under three words unless it was in an unspaced script. That refused a short Korean or German name ("체크아웃 보호", "Live-Checkout schützen"). It is gone; the plain-words ask stays in the tool's description.

test_a_name_and_does_line_in_any_language_are_accepted (Chinese, Japanese, Korean, Hindi, German) and a CJK two-sentence does case fail on the previous head and pass on this one. The spec says the same.

@buluoray

buluoray commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Disposition for the UX Review BLOCK on 8e20ad5, fixed on head 2c815a1. The frames in the body are new, from this head.

Blocker: "Runs before" showed internal tool ids, and Does read as technical as the code. Fixed.

  • Runs before now names plain tools in the words the agent's Tools list already uses (toolMeta). execute_bash|shell reads "Run shell commands": KAS's shell is the same tool, so it is said once. fs_write reads "Write files". A tool with no such words (an MCP tool) keeps its id, and a pattern stays as written. Tests: HookCard.test.tsx and ConversationCard.test.tsx.
  • propose_hook now asks for a does line that says the effect the person will see, in their words, not a list of commands or tool names; the refusal text gives the same example. The capture fixture reads "Stops the agent from switching, resetting or pulling branches in this checkout".

The command itself stays on the card whole: it is what runs, and the Does row above the notice is the plain-words line for a reader who does not read it.

Notes.

  • "{name} and its tasks" and the folder refusal's wording stay as decided for this PR.
  • Create hook after a refusal: not changed. The error line says to ask for a new card; a second press returns the same refusal and shows the line again.

@buluoray

buluoray commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Disposition for head 95cbdf1.

UX Review round 3 (2c815a1): the reader would not press Create hook.

  • The frames that round read were from an older head. The body now carries frames shot from this head (the card capture in website/capture/): "Runs before" reads "Run shell commands", not tool ids.
  • The yellow notice now ends "Turn it off in Hooks.", where "Hooks" is a link to the Hooks page (/hooks), in all 12 locales. After Create, the card's result line carries the same "Hooks" link. So the way back is one press from the card, before and after the press. Tests: ConversationCard.test.tsx checks both links' targets.
  • Create hook stays pressable after a refusal: a second press returns the same refusal and shows its line again, and the line says to ask for a new card.

First Principles blocker: a second lookup of a bot by member_id. Fixed. request_hook._bot_label now resolves the bot through execution_context.member_config_for_id, the lookup the press checks it with, so a missing or ambiguous id names no bot on the card and is refused at the press. test_the_card_names_a_bot_by_the_same_lookup_the_press_checks covers one bot, two bots sharing the id, and none; it fails on the old loop.

First Principles note on item 6 (raise-time checks). Kept. Those checks compare what the card shows with what the Hooks create route would store, so the card never shows one command and stores another; they are not a second schema. A hook command is the one place where a hidden character or a trimmed space would change what runs.

@buluoray

buluoray commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Disposition for head d46ced1. The frames in the body are from this head (website/capture/), replacing every earlier set.

UX Review round 4 (95cbdf1): a reader who cannot read the command had nothing from the system to decide on. Redesigned rather than reworded:

  • A new row, When it matches, written by the system from the hook's event and never from agent text. The card only creates PreToolUse hooks, whose command decides each time whether the call goes on, so it has one value: "Can stop the call. The command decides each time, and the agent is told why." (hook_effect row in change_card_hook.preview; tests in test_change_card_hook.py and ConversationCard.test.tsx).
  • The agent's own sentence is labelled as the bot's: "{bot} says", or "The bot says" when the card does not know the bot. It reads first, then When it matches, then the yellow notice with its Hooks link.
  • After a refusal no retry can clear (the bot was deleted, or the folder now leads elsewhere), the card no longer shows Create; its line already asks for a new card. Any other refusal keeps Create. The deleted-bot line names the bot when the card knows it: "Release Helper was deleted, so no hook was created. Ask for a new card." Tests for both cases in ConversationCard.test.tsx.
  • Not taken: a note that the Runs in boxes combine. They are checkboxes.

GPT security-class finding: a matcher named like an Object property crashed the card. Fixed. Both lookups (TOOL_ALIASES in CardChanges.tsx, TOOL_CLASS in toolMeta.ts) read own keys only, so toString, __proto__ or constructor reads as an unknown tool, kept as written. Test in HookCard.test.tsx; it fails on the previous head.

buluoray and others added 2 commits December 5, 2026 19:48
Any chat or bot can call propose_hook with a PreToolUse hook's name,
matcher and command. The gateway raises a hook.create card in that
chat with the whole command and tick boxes for where it runs: the
bot and its tasks, the folder of the chat's project, or all chats.
The bot or folder that fits the chat is ticked; the person changes
the ticks and presses Create, which stores what the card shows in
hooks.json like any other hook, through the Hooks create route.

The name must say what the hook does, since it is the card's title.
A command the create route would save differently, or one holding a
character the card cannot show, is refused when the card is raised.
Undo deletes the hook unless it was edited after the press. The
shared prompt gains one line telling agents to propose a hook for a
mistake a rule can catch.
A hook.create card press checked that the confirmed folder still
resolved to itself, then waited on the bot check, and the store
resolved the folder a second time. A link swapped in between saved
the other tree as the hook's scope.

The store now does the check where it resolves the folder
(ScriptHookStore.create(confirmed_folder=True) raises
hook_scope.FolderMoved) and saves the value that passed, so nothing
after the handler's waits can widen the scope.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant