Hexwood by Diana Wynne Jones

In a world where reality is manipulated by the enigmatic Bannus machine, a young girl named Ann discovers a mysterious forest near her home that defies the laws of time and space. As she ventures deeper, she encounters a cast of characters, including a knight, a dragon, and a boy with a hidden past, all drawn into a complex web of intrigue and deception. As the boundaries between illusion and reality blur, Ann must navigate a labyrinth of secrets and power struggles to uncover the truth about her own identity and the forces controlling her world.