https://arxiv.org/pdf/2604.14228 architecture of claude code - A 7-mode permission system acting as a security harness. - A 5-layer context compaction pipeline to store memory. - A subagent delegation mechanism with strict worktree isolation. - Four different extensibility hooks to manage external tools safely.