Skip to content

SessionStart: 50-git-restore.sh runs as a foreground child and re-sources the whole lib chain even when git_restore is disabled (Part of #660) #663

Closed

Description

@fdaviddpt

Part of #660.

Observed

session-start-hook.sh:302 dispatches before_session_start hooks through log.sh:1014-1166. For the one shipped hook, hooks.d/before_session_start/50-git-restore.sh, the dispatcher spawns $(id -u) (log.sh:1033), two $(config) calls, $(stat -c %u) (:1060), $(find "$hook" -maxdepth 0 -perm -002) (:1066), two rm -f, a supervise watcher subshell with sleep 1 (:955-985), and then a whole child bash (:1111) which the parent waits on.

In legacy layout the child exits at 50-git-restore.sh:12 before spawning anything. In external data_dir layout it runs git rev-parse --show-toplevel, two $(cd; pwd -P), then source log.sh -- and because _LIB_MEMORY_DIR_LOADED is not exported, the child re-runs the full lib-memory-dir.sh + log.sh chain: mktemp, jq -s merge, jq flatten, six $(config) calls, trap plumbing (~25-30 spawns) -- before it reads $(config .git_restore.enabled) at :25 and exits if false.

Also: find at log.sh:1066 and bootstrap-dirs.sh:143 is exposed to the System32 find.exe PATH-shadow on Windows.

Cost

Estimated 0.5-1.5s legacy, 2-5s external mode, per start (reasoned, not measured on Windows).

Fix shape

  • In the hook: test git_restore.enabled before source log.sh -- cheapest is to have the parent export the flattened config (the _RCFG_* cache, or one REMEMBER_CFG_FLAT string) so the child skips _config_load and the merge entirely; or a plain grep on the exported $REMEMBER_CONFIG path.
  • In dispatch: $EUID instead of $(id -u); fold stat %u and find -perm -002 into one stat -c '%u %a' and test the world-writable bit in bash.
  • Larger option, if the above is not enough: run git-restore in the detached phase and emit a "restored, memory will be re-read next start" notice.

Positive control: a test that flips git_restore.enabled and shows the child still runs the restore; negative: with it disabled, the child spawns nothing beyond the exit.

[AI-generated]

Activity

  1. added
    priority:high
    filed-by-loop
    lane-capture
    on Sep 11, 2026
  2. self-assigned this
    on Sep 12, 2026
  3. removed their assignment
    on Sep 12, 2026
  4. added 2 commits that reference this issue on Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    filed-by-looplane-capturepriority:high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions