@@ -215,3 +215,55 @@ func TestEnableDefaultStrategy(t *testing.T) {
215215 t .Errorf ("Expected status to show 'manual-commit', got: %s" , stdout )
216216 }
217217}
218+
219+ // TestHooksRunAfterLocalOnlyEnable is a full-flow reproduction of the
220+ // `entire enable --local` regression: only .entire/settings.local.json
221+ // exists, and the hooks (gated on settings.IsSetUpAndEnabled) silently
222+ // no-op'd because that check only looked at settings.json — so a commit
223+ // produced no checkpoint.
224+ //
225+ // This drives the real hook binary end-to-end: a session, a
226+ // user-prompt-submit, a file change, a stop, and a commit — then asserts the
227+ // commit actually carries an Entire-Checkpoint trailer (i.e. the hooks ran
228+ // and a checkpoint was saved). Complements TestHooksSilentWhenDisabled above,
229+ // which covers the opposite case.
230+ func TestHooksRunAfterLocalOnlyEnable (t * testing.T ) {
231+ t .Parallel ()
232+ env := NewTestEnv (t )
233+ defer env .Cleanup ()
234+
235+ env .InitRepo ()
236+ env .WriteFile ("README.md" , "# Test" )
237+ env .GitAdd ("README.md" )
238+ env .GitCommit ("Initial commit" )
239+ env .GitCheckoutNewBranch ("feature/local-only" )
240+
241+ // Simulate `entire enable --local`: only settings.local.json exists.
242+ entireDir := filepath .Join (env .RepoDir , ".entire" )
243+ if err := os .MkdirAll (filepath .Join (entireDir , "tmp" ), 0o755 ); err != nil {
244+ t .Fatalf ("mkdir .entire/tmp: %v" , err )
245+ }
246+ localSettings := `{"enabled":true,"local_dev":true,"strategy_options":{"filtered_fetches":true}}`
247+ if err := os .WriteFile (filepath .Join (entireDir , "settings.local.json" ), []byte (localSettings ), 0o644 ); err != nil {
248+ t .Fatalf ("write settings.local.json: %v" , err )
249+ }
250+ if _ , err := os .Stat (filepath .Join (entireDir , "settings.json" )); err == nil {
251+ t .Fatal ("precondition: settings.json must not exist for the enable --local scenario" )
252+ }
253+
254+ session := env .NewSession ()
255+ if err := env .SimulateUserPromptSubmitWithPrompt (session .ID , "Create a hello file" ); err != nil {
256+ t .Fatalf ("user-prompt-submit: %v" , err )
257+ }
258+ env .WriteFile ("hello.txt" , "hello" )
259+ session .CreateTranscript ("Create a hello file" , []FileChange {{Path : "hello.txt" , Content : "hello" }})
260+ if err := env .SimulateStop (session .ID , session .TranscriptPath ); err != nil {
261+ t .Fatalf ("stop: %v" , err )
262+ }
263+ env .GitCommitWithShadowHooksAsAgent ("add hello" , "hello.txt" )
264+
265+ cpID := env .GetCheckpointIDFromCommitMessage (env .GetHeadHash ())
266+ if cpID == "" {
267+ t .Fatal ("commit has no Entire-Checkpoint trailer — hooks silently no-op'd with only settings.local.json" )
268+ }
269+ }
0 commit comments