feat(metatag-dirs): nested directory hierarchy via path metatag + flags

Implements the source PDF's prescribed model for directory structure:
'treat the CZYX cube as the only persistent store, with system calls that
operate on CZYX records and Null-space flags rather than paths and inodes.'
Nested dirs are RECONSTRUCTED from a per-record `path` metatag, so the
filesystem does not need recursive inode trees.

- cubecoords: add CubeHeader.path (Option<String>) + HAS_PATH flag bit (1<<8);
  refresh_flags() sets it. Cubestore TLV codec now serializes/deserializes the
  path as tag 13 (persists across checkpoint/reopen).
- cubestore: scan_by_path (exact), scan_by_path_prefix (dir listing by path
  prefix; bare '/etc' normalized to '/etc/'), plus query_by_path/_prefix
  returning decoded (coord,header,body).
- cubesys: `put` verb gains path=<p>;
  new `query-path <dir>` verb reconstructs a directory listing from metatags.
- ConcurrentStore: query_by_path(_prefix) delegate to inner CubeStore.

Verified live in VM: migrated /etc/passwd, /etc/network/interfaces, /usr/bin/ls
at unrelated coordinates; 'query-path /etc' returns the two /etc files,
'/usr/bin/ls' correctly excluded. cubestore 8/8 tests pass.

Refs: OS-in-CUBE migration, query-layer prototype.
This commit is contained in:
CUBELinux-2
2026-08-13 18:26:58 -04:00
parent 2ff1dff02b
commit 94681bbdc0
5 changed files with 203 additions and 0 deletions
+17
View File
@@ -185,6 +185,13 @@ impl HeaderFlags {
pub const PERM_REMOTE_USER: u16 = 1 << 6;
/// Flag 8: has outgoing association links.
pub const HAS_ASSOCIATIONS: u16 = 1 << 7;
/// Flag 9: carries a POSIX `path` metatag (the original filesystem path
/// the record was migrated from). Lets the associative query layer
/// reconstruct a directory hierarchy WITHOUT the filesystem needing to
/// support arbitrary recursive nesting — the path is data, addressed by
/// flag, exactly as the source PDF prescribes ("operate on CZYX records
/// and Null-space flags rather than paths and inodes").
pub const HAS_PATH: u16 = 1 << 8;
// Flag 255 (conceptual end-of-header) is represented out-of-band by the
// record serializer; there is no bit for it.
@@ -245,6 +252,13 @@ pub struct CubeHeader {
pub owner_remote_user: Option<String>,
/// Association links to other records (flags 5–19).
pub linked_records: Vec<Czyx>,
/// POSIX path metatag: the original filesystem path this record was
/// migrated from (e.g. "/etc/network/interfaces"). Empty/absent means the
/// record has no path identity. When present, the `HAS_PATH` flag bit is
/// set so `scan_by_path`/`query_by_path` can recover the hierarchy from
/// metatags alone (see cubestore). This is the PDF's "path is a view over
/// coordinates + flags" made concrete.
pub path: Option<String>,
/// Total local accesses (from the PDF's association/permission flags).
pub total_accesses: u64,
/// Total remote accesses.
@@ -292,6 +306,9 @@ impl CubeHeader {
if !self.linked_records.is_empty() {
f |= HeaderFlags::HAS_ASSOCIATIONS;
}
if self.path.is_some() {
f |= HeaderFlags::HAS_PATH;
}
// Preserve spare/out-of-band flag bits (bits 8..=15) that are not
// derived from structured fields. This includes
// `cubecrypt::HEADER_FLAG_ENCRYPTED` (bit 12) and the behavior-descriptor