1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//! Checking a deployed document against the schema files its own archive
//! carries.
//!
//! # Why the server projects, instead of the console re-checking
//!
//! `/awl/check` resolves a document's `schema("…")` imports against the
//! OPERATOR'S WORKSPACE. Sending deployed source through it would render a
//! composite that exists nowhere: deployed statements checked against whatever
//! files happen to sit beside a same-named workspace document. The archived
//! schemas are the only schemas that version was ever checked with, so the
//! projection is computed here, from them.
//!
//! # The staging directory
//!
//! The AWL checker resolves imports through the filesystem, so archived schema
//! bytes have to reach one. This module writes them into a process-private
//! temporary directory (0700, unique name) that is created inside this call and
//! removed before it returns. It holds only bytes that are being returned to
//! the caller in the same response. Nothing durable is created or modified:
//! not the operator's workspace, not the package store, no cache. That is the
//! whole of this surface's filesystem use, and
//! `deployed_projection_leaves_no_directory_behind` pins it.
use BTreeMap;
use ;
use ;
use DeployedError;
/// Projects `source`, resolving its schema imports against `schemas`.
///
/// A document that imports nothing needs no filesystem at all and is checked
/// directly.
///
/// # Errors
///
/// Returns [`DeployedError::UnsafeSchemaPath`] for an archived schema whose
/// path is not a relative in-document path, and [`DeployedError::Staging`]
/// when the staging directory cannot be created or written.
pub
/// [`project`], with the directory the staging directory is created inside
/// stated explicitly.
///
/// Production passes the system temporary directory. The parameter exists so
/// the staging invariant can be pinned against a directory the pin owns
/// outright — a pin that scanned the shared system temp directory could not
/// tell this call's leavings from a concurrent one's.
///
/// # Errors
///
/// Returns [`DeployedError::UnsafeSchemaPath`] for an archived schema whose
/// path is not a relative in-document path, and [`DeployedError::Staging`]
/// when the staging directory cannot be created or written.
pub
/// Accepts only a non-empty relative path built from ordinary components.
///
/// The archive writer already refuses anything else, so this is defence in
/// depth at the point where archived names become filesystem paths: a `..` or
/// absolute component would place a staged file outside the staging directory.