<commit_before>local proxy  = require "cosy.util.proxy"
local copy   = require "cosy.util.shallow_copy"
local tags   = require "cosy.util.tags"

local PATH  = tags.PATH

local remember_path = proxy {}

local forward = remember_path.__index

local path = proxy {}

function path.__concat (lhs, rhs)
  local result = copy (lhs)
  result [#result + 1] = rhs
  return path (result)
end

function remember_path:__index (key)
  if not rawget (self, PATH) then
    rawset (self, PATH, path { self })
    return self [key]
  end
  local result = forward (self, key)
  if type (result) ~= "table" then
    return result
  end
  local p = self [PATH] .. key
  rawset (result, PATH, p)
  return result
end

return remember_path
<commit_msg>Fix the volatile detection.<commit_after>local proxy  = require "cosy.util.proxy"
local copy   = require "cosy.util.shallow_copy"
local tags   = require "cosy.util.tags"

local PATH        = tags.PATH
local IS_VOLATILE = tags.IS_VOLATILE

local remember_path = proxy {}

local forward = remember_path.__index

local path = proxy {}

function path.__concat (lhs, rhs)
  local result = copy (lhs)
  result [#result + 1] = rhs
  return path (result)
end

function remember_path:__index (key)
  if not rawget (self, PATH) then
    rawset (self, PATH, path { self })
    return self [key]
  end
  local volatile = rawget (self, IS_VOLATILE) or (type (key) == "table" and key [IS_VOLATILE])
  local result = forward (self, key)
  if type (result) ~= "table" then
    return result
  end
  local p = self [PATH] .. key
  rawset (result, PATH, p)
  rawset (result, IS_VOLATILE, volatile)
  return result
end

return remember_path

{'fraction_non_alphanumeric': 0.10357359176256814, 'fraction_numerical': 0.0012113870381586917, 'mean_word_length': 3.588888888888889, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3082124', 'n_tokens_mistral': 561, 'n_tokens_neox': 550, 'n_words': 192}